diff options
author | Vanessa Ezekowitz <vanessaezekowitz@gmail.com> | 2016-04-01 20:02:19 -0400 |
---|---|---|
committer | Vanessa Ezekowitz <vanessaezekowitz@gmail.com> | 2016-04-01 21:09:33 -0400 |
commit | da66780a569712c23ae4f2996cfb4608a9f9d69d (patch) | |
tree | 217556029a78bc23ad4564720afc86de97228a04 /xban2/serialize.lua | |
parent | 615b22df4d423aded3613db7716943a2f389b047 (diff) | |
download | dreambuilder_modpack-da66780a569712c23ae4f2996cfb4608a9f9d69d.tar dreambuilder_modpack-da66780a569712c23ae4f2996cfb4608a9f9d69d.tar.gz dreambuilder_modpack-da66780a569712c23ae4f2996cfb4608a9f9d69d.tar.bz2 dreambuilder_modpack-da66780a569712c23ae4f2996cfb4608a9f9d69d.tar.xz dreambuilder_modpack-da66780a569712c23ae4f2996cfb4608a9f9d69d.zip |
copy all standard Dreambuilder mods in from the old subgame
(exactly as last supplied there, updates to these mods will follow later)
Diffstat (limited to 'xban2/serialize.lua')
-rw-r--r-- | xban2/serialize.lua | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/xban2/serialize.lua b/xban2/serialize.lua new file mode 100644 index 0000000..c159141 --- /dev/null +++ b/xban2/serialize.lua @@ -0,0 +1,31 @@ + +local function repr(x) + if type(x) == "string" then + return ("%q"):format(x) + else + return tostring(x) + end +end + +local function my_serialize_2(t, level) + level = level or 0 + local lines = { } + local indent = ("\t"):rep(level) + for k, v in pairs(t) do + local typ = type(v) + if typ == "table" then + table.insert(lines, + indent..("[%s] = {\n"):format(repr(k)) + ..my_serialize_2(v, level + 1).."\n" + ..indent.."},") + else + table.insert(lines, + indent..("[%s] = %s,"):format(repr(k), repr(v))) + end + end + return table.concat(lines, "\n") +end + +function xban.serialize(t) + return "return {\n"..my_serialize_2(t, 1).."\n}" +end |