aboutsummaryrefslogtreecommitdiff
path: root/advtrains
diff options
context:
space:
mode:
authororwell96 <orwell@bleipb.de>2018-10-29 19:21:28 +0100
committerorwell96 <orwell@bleipb.de>2018-10-29 19:32:43 +0100
commit60b725499289c810eaf045ed22a1100402a0b8c9 (patch)
treefff03d1c10d2ed912fee3777350da7b20a492a50 /advtrains
parent0ae0b6a768ebb33d3835875e3a3b5dc30379c92b (diff)
downloadadvtrains-60b725499289c810eaf045ed22a1100402a0b8c9.tar.gz
advtrains-60b725499289c810eaf045ed22a1100402a0b8c9.tar.bz2
advtrains-60b725499289c810eaf045ed22a1100402a0b8c9.zip
atdump() to treat certain values special
Diffstat (limited to 'advtrains')
-rw-r--r--advtrains/init.lua58
1 files changed, 36 insertions, 22 deletions
diff --git a/advtrains/init.lua b/advtrains/init.lua
index fc7e423..3d420e6 100644
--- a/advtrains/init.lua
+++ b/advtrains/init.lua
@@ -58,6 +58,41 @@ end
advtrains.modpath = minetest.get_modpath("advtrains")
+--Advtrains dump (special treatment of pos and sigd)
+function atdump(t, intend)
+ local str
+ if type(t)=="table" then
+ if t.x and t.y and t.z then
+ str=minetest.pos_to_string(t)
+ elseif t.p and t.s then -- interlocking sigd
+ str="S["..minetest.pos_to_string(t.p).."/"..t.s.."]"
+ else
+ str="{"
+ local intd = (intend or "") .. " "
+ for k,v in pairs(t) do
+ if type(k)~="string" or not string.match(k, "^path[_]?") then
+ -- do not print anything path-related
+ str = str .. "\n" .. intd .. atdump(k, intd) .. " = " ..atdump(v, intd)
+ end
+ end
+ str = str .. "\n" .. (intend or "") .. "}"
+ end
+ elseif type(t)=="boolean" then
+ if t then
+ str="true"
+ else
+ str="false"
+ end
+ elseif type(t)=="function" then
+ str="<function>"
+ elseif type(t)=="userdata" then
+ str="<userdata>"
+ else
+ str=""..t
+ end
+ return str
+end
+
function advtrains.print_concat_table(a)
local str=""
local stra=""
@@ -69,28 +104,7 @@ function advtrains.print_concat_table(a)
else
str=str..stra
stra=""
- if type(t)=="table" then
- if t.x and t.y and t.z then
- str=str..minetest.pos_to_string(t)
- elseif t.p and t.s then -- interlocking sigd
- str=str.."("..minetest.pos_to_string(t.p).."/"..t.s..")"
- else
- str=str..dump(t)
- end
- elseif type(t)=="boolean" then
- if t then
- str=str.."true"
- else
- str=str.."false"
- end
- elseif type(t)=="function" then
- str=str.."<function>"
- elseif type(t)=="userdata" then
- str=str.."<userdata>"
- else
- str=str..t
- end
- str=str.." "
+ str=str..atdump(t).." "
end
end
return str