mirror of
https://github.com/luanti-org/luanti.git
synced 2025-08-26 18:21:04 +00:00
Rework dumping functions
Changes: * Add comments to explain the dumping code * Add support for dumping values of any type (as '<' <type> '>') * Add support for tables as keys in dump2() * Make dump2() return it's result (like dump()) rather than printing it * Simplify and optimize function serialization via serialize()
This commit is contained in:
parent
660e636887
commit
882e12f8ab
2 changed files with 71 additions and 49 deletions
|
@ -113,7 +113,7 @@ function core.serialize(x)
|
|||
elseif t=="string" then return string.format("%q", x)
|
||||
elseif t=="boolean" then return x and "true" or "false"
|
||||
elseif t=="function" then
|
||||
return "loadstring("..string.format("%q", string.dump(x))..")"
|
||||
return string.format("loadstring(%q)", string.dump(x))
|
||||
elseif t=="table" then
|
||||
local acc = { }
|
||||
local idx_dumped = { }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue