mirror of
https://github.com/Uberi/Minetest-WorldEdit.git
synced 2024-12-26 02:30:40 +01:00
Merge pull request #76 from est31/fixserialisation
Load first node too with LuaJIT
This commit is contained in:
commit
78915d4a54
@ -159,20 +159,20 @@ local function load_schematic(value)
|
|||||||
else
|
else
|
||||||
-- XXX: This is a filthy hack that works surprisingly well - in LuaJIT, `minetest.deserialize` will fail due to the register limit
|
-- XXX: This is a filthy hack that works surprisingly well - in LuaJIT, `minetest.deserialize` will fail due to the register limit
|
||||||
nodes = {}
|
nodes = {}
|
||||||
value = value:gsub("return%s*{", "", 1):gsub("}%s*$", "", 1) -- remove the starting and ending values to leave only the node data
|
content = content:gsub("return%s*{", "", 1):gsub("}%s*$", "", 1) -- remove the starting and ending values to leave only the node data
|
||||||
local escaped = value:gsub("\\\\", "@@"):gsub("\\\"", "@@"):gsub("(\"[^\"]*\")", function(s) return string.rep("@", #s) end)
|
local escaped = content:gsub("\\\\", "@@"):gsub("\\\"", "@@"):gsub("(\"[^\"]*\")", function(s) return string.rep("@", #s) end)
|
||||||
local startpos, startpos1, endpos = 1, 1
|
local startpos, startpos1, endpos = 1, 1
|
||||||
while true do -- go through each individual node entry (except the last)
|
while true do -- go through each individual node entry (except the last)
|
||||||
startpos, endpos = escaped:find("},%s*{", startpos)
|
startpos, endpos = escaped:find("},%s*{", startpos)
|
||||||
if not startpos then
|
if not startpos then
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
local current = value:sub(startpos1, startpos)
|
local current = content:sub(startpos1, startpos)
|
||||||
local entry = minetest.deserialize("return " .. current)
|
local entry = minetest.deserialize("return " .. current)
|
||||||
table.insert(nodes, entry)
|
table.insert(nodes, entry)
|
||||||
startpos, startpos1 = endpos, endpos
|
startpos, startpos1 = endpos, endpos
|
||||||
end
|
end
|
||||||
local entry = minetest.deserialize("return " .. value:sub(startpos1)) -- process the last entry
|
local entry = minetest.deserialize("return " .. content:sub(startpos1)) -- process the last entry
|
||||||
table.insert(nodes, entry)
|
table.insert(nodes, entry)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
|
Loading…
Reference in New Issue
Block a user