Add function to dump tables as string
This commit is contained in:
parent
c951d0b164
commit
9ff1c3abf2
17
script.lua
17
script.lua
@ -11,6 +11,23 @@ offset_u_face=64
|
||||
offset_v_face=0
|
||||
armor_enabled=true
|
||||
|
||||
-- utility functions -- {{{
|
||||
--- dump table --
|
||||
function dumpTable(o)
|
||||
if type(o) == 'table' then
|
||||
local s = '{ '
|
||||
for k,v in pairs(o) do
|
||||
if type(k) ~= 'number' then k = '"'..k..'"' end
|
||||
s = s .. '['..k..'] = ' .. dumpTable(v) .. ','
|
||||
end
|
||||
return s .. '} '
|
||||
else
|
||||
return tostring(o)
|
||||
end
|
||||
end
|
||||
-- }}}
|
||||
|
||||
|
||||
-- initialize values --
|
||||
function player_init()
|
||||
old_health=player.getHealth()
|
||||
|
Loading…
x
Reference in New Issue
Block a user