I often put common funtions in helpers section of the global_data script, this works fine but when I want write a reentrant function I get an error when trying to reference the function inside the script itself.
Example this function to pretty print any lua table:
Code: Select all
dumpTable = function (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
Any body knows how to write the reference properly ?