diff options
Diffstat (limited to 'data/scripts/default.lua')
-rw-r--r-- | data/scripts/default.lua | 63 |
1 files changed, 0 insertions, 63 deletions
diff --git a/data/scripts/default.lua b/data/scripts/default.lua index 4197cd788..0b9f8b913 100644 --- a/data/scripts/default.lua +++ b/data/scripts/default.lua @@ -1,66 +1,3 @@ ---[[function basicSerialize(o) - if type(o) == "number" then - return tostring(o) - else -- assume it is a string - return string.format("%q", o) - end -end - -function dump2(name, value, saved) - saved = saved or {} -- initial value - io.write(name, " = ") - if type(value) == "number" or type(value) == "string" then - io.write(basicSerialize(value), "\n") - elseif type(value) == "table" then - if saved[value] then -- value already saved? - io.write(saved[value], "\n") -- use its previous name - else - saved[value] = name -- save name for next time - io.write("{}\n") -- create a new table - for k,v in pairs(value) do -- save its fields - local fieldname = string.format("%s[%s]", name, - basicSerialize(k)) - save(fieldname, v, saved) - end - end - else - error("cannot save a " .. type(value)) - end -end]] - ---[[function dump(o, name, dumped, s) - name = name or "_" - dumped = dumped or {} - s = s or "" - s = s .. name .. " = " - if type(o) == "number" then - s = s .. tostring(o) - elseif type(o) == "string" then - s = s .. string.format("%q", o) - elseif type(o) == "boolean" then - s = s .. tostring(o) - elseif type(o) == "function" then - s = s .. "<function>" - elseif type(o) == "nil" then - s = s .. "nil" - elseif type(o) == "table" then - if dumped[o] then - s = s .. dumped[o] - else - dumped[o] = name - local t = {} - for k,v in pairs(o) do - t[#t+1] = dump(v, k, dumped) - end - s = s .. "{" .. table.concat(t, ", ") .. "}" - end - else - error("cannot dump a " .. type(o)) - return nil - end - return s -end]] - function basic_dump2(o) if type(o) == "number" then return tostring(o) |