diff options
author | Anthony Zhang <azhang9@gmail.com> | 2013-04-20 20:28:21 -0400 |
---|---|---|
committer | Anthony Zhang <azhang9@gmail.com> | 2013-04-20 20:28:21 -0400 |
commit | f5145d6ba13aaf48a8bf10c8cef7d1a8ea6f2708 (patch) | |
tree | 0603905a39b26f5b4536880fe86665bc208bcb76 /worldedit/serialization.lua | |
parent | 0317deb10143bd59a78fcba8b0334ffec877e0c7 (diff) |
Horrible, vile, disgusting hack. But it works.
Diffstat (limited to 'worldedit/serialization.lua')
-rw-r--r-- | worldedit/serialization.lua | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/worldedit/serialization.lua b/worldedit/serialization.lua index cc3297e..985e3d7 100644 --- a/worldedit/serialization.lua +++ b/worldedit/serialization.lua @@ -214,7 +214,22 @@ worldedit.deserialize = function(originpos, value) count = count + 1
end
elseif version == 4 then --current nested table format
- local nodes = minetest.deserialize(value)
+ --wip: this is a filthy hack that works surprisingly well
+ value = value:gsub("return%s*{", "", 1):gsub("}%s*$", "", 1)
+ local escaped = value:gsub("\\\\", "@@"):gsub("\\\"", "@@"):gsub("(\"[^\"]+\")", function(s) return string.rep("@", #s) end)
+ local startpos, startpos1, endpos = 1, 1
+ local nodes = {}
+ while true do
+ startpos, endpos = escaped:find("},%s*{", startpos)
+ if not startpos then
+ break
+ end
+ local current = value:sub(startpos1, startpos)
+ table.insert(nodes, minetest.deserialize("return " .. current))
+ startpos, startpos1 = endpos, endpos
+ end
+
+ --local nodes = minetest.deserialize(value) --wip: this is broken for larger tables in the current version of LuaJIT
count = #nodes
for index = 1, count do
local entry = nodes[index]
|