diff options
author | Anthony Zhang <azhang9@gmail.com> | 2013-04-29 19:52:00 -0400 |
---|---|---|
committer | Anthony Zhang <azhang9@gmail.com> | 2013-04-29 19:52:00 -0400 |
commit | 18bc4e68153e8a37113e38d088a1420c7d0cc0e2 (patch) | |
tree | ea16b216e10aeb2ed77de70d54e8fe3e20d3761e /worldedit/serialization.lua | |
parent | 98c5bc5c5fbd0205b3b3e4ef6c529d88c4960815 (diff) |
Fix deserialization for real this time.
Diffstat (limited to 'worldedit/serialization.lua')
-rw-r--r-- | worldedit/serialization.lua | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/worldedit/serialization.lua b/worldedit/serialization.lua index 9d201d8..6481fae 100644 --- a/worldedit/serialization.lua +++ b/worldedit/serialization.lua @@ -51,7 +51,7 @@ worldedit.serialize = function(pos1, pos2) --wip: check for ItemStacks and wheth --convert metadata itemstacks to itemstrings
for name, inventory in pairs(meta.inventory) do
for index, stack in ipairs(inventory) do
- inventory[index] = stack:to_string()
+ inventory[index] = stack.to_string and stack:to_string() or stack
end
end
@@ -228,13 +228,21 @@ worldedit.deserialize = function(originpos, value, env) table.insert(nodes, minetest.deserialize("return " .. current))
startpos, startpos1 = endpos, endpos
end
+ table.insert(nodes, minetest.deserialize("return " .. value:sub(startpos1)))
--local nodes = minetest.deserialize(value) --wip: this is broken for larger tables in the current version of LuaJIT
+
+ --load the nodes
count = #nodes
for index = 1, count do
local entry = nodes[index]
entry.x, entry.y, entry.z = originx + entry.x, originy + entry.y, originz + entry.z
env:add_node(entry, entry) --entry acts both as position and as node
+ end
+
+ --load the metadata
+ for index = 1, count do
+ local entry = nodes[index]
env:get_meta(entry):from_table(entry.meta)
end
end
|