Skip to content
Snippets Groups Projects
Commit 3668b45e authored by dg's avatar dg
Browse files

fix

git-svn-id: http://svn.net-core.org/repos/t-engine4@2868 51575b47-30f0-44d4-a5cc-537603b46e54
parent e24c425a
No related branches found
No related tags found
No related merge requests found
......@@ -96,7 +96,7 @@ function _M:loaded()
self:updateZoom()
-- Serialize arguments for passing into the particles threads
local args = table.serialize(self.args or {})
local args = table.serialize(self.args or {}, nil, true)
args = args.."tile_w="..engine.Map.tile_w.."\ntile_h="..engine.Map.tile_h
self.update = fct
......
......@@ -75,20 +75,26 @@ end
--- This is a really naive algorithm, it will not handle objects and such.
-- Use only for small tables
function table.serialize(src, sub)
function table.serialize(src, sub, no_G)
local str = ""
if sub then str = "{" end
for k, e in pairs(src) do
local nk, ne = k, e
local tk, te = type(k), type(e)
if tk == "table" then nk = "["..table.serialize(nk, true).."]"
elseif tk == "string" then nk = string.format("[%q]", nk)
else nk = "["..nk.."]"
if no_G then
if tk == "table" then nk = "["..table.serialize(nk, true).."]"
elseif tk == "string" then -- nothing
else nk = "["..nk.."]"
end
else
if tk == "table" then nk = "["..table.serialize(nk, true).."]"
elseif tk == "string" then nk = string.format("[%q]", nk)
else nk = "["..nk.."]"
end
if not sub then nk = "_G"..nk end
end
if not sub then nk = "_G"..nk end
if te == "table" then
str = str..string.format("%s=%s ", nk, table.serialize(ne, true))
elseif te == "number" then
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment