Skip to content

Commit 09de34a

Browse files
committedMar 12, 2015
Load first node too with LuaJIT
Before, the first node would have had the version number prepended (e.g. "5:"), and therefore wouldn't be loaded.
1 parent c1bd498 commit 09de34a

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed
 

Diff for: ‎worldedit/serialization.lua

+4-4
Original file line numberDiff line numberDiff line change
@@ -159,20 +159,20 @@ local function load_schematic(value)
159159
else
160160
-- XXX: This is a filthy hack that works surprisingly well - in LuaJIT, `minetest.deserialize` will fail due to the register limit
161161
nodes = {}
162-
value = value:gsub("return%s*{", "", 1):gsub("}%s*$", "", 1) -- remove the starting and ending values to leave only the node data
163-
local escaped = value:gsub("\\\\", "@@"):gsub("\\\"", "@@"):gsub("(\"[^\"]*\")", function(s) return string.rep("@", #s) end)
162+
content = content:gsub("return%s*{", "", 1):gsub("}%s*$", "", 1) -- remove the starting and ending values to leave only the node data
163+
local escaped = content:gsub("\\\\", "@@"):gsub("\\\"", "@@"):gsub("(\"[^\"]*\")", function(s) return string.rep("@", #s) end)
164164
local startpos, startpos1, endpos = 1, 1
165165
while true do -- go through each individual node entry (except the last)
166166
startpos, endpos = escaped:find("},%s*{", startpos)
167167
if not startpos then
168168
break
169169
end
170-
local current = value:sub(startpos1, startpos)
170+
local current = content:sub(startpos1, startpos)
171171
local entry = minetest.deserialize("return " .. current)
172172
table.insert(nodes, entry)
173173
startpos, startpos1 = endpos, endpos
174174
end
175-
local entry = minetest.deserialize("return " .. value:sub(startpos1)) -- process the last entry
175+
local entry = minetest.deserialize("return " .. content:sub(startpos1)) -- process the last entry
176176
table.insert(nodes, entry)
177177
end
178178
else

0 commit comments

Comments
 (0)
Please sign in to comment.