]> git.lizzy.rs Git - worldedit.git/commitdiff
Load first node too with LuaJIT
authorest31 <MTest31@outlook.com>
Thu, 12 Mar 2015 01:21:01 +0000 (02:21 +0100)
committerest31 <MTest31@outlook.com>
Thu, 12 Mar 2015 01:40:19 +0000 (02:40 +0100)
Before, the first node would have had the version number prepended (e.g. "5:"), and therefore wouldn't be loaded.

worldedit/serialization.lua

index bec7e0902219b12eb20313f882214f35085b5bd2..00d984d099d6e9b07eccc5b38c12180aea0d29e0 100644 (file)
@@ -159,20 +159,20 @@ local function load_schematic(value)
                else\r
                        -- XXX: This is a filthy hack that works surprisingly well - in LuaJIT, `minetest.deserialize` will fail due to the register limit\r
                        nodes = {}\r
-                       value = value:gsub("return%s*{", "", 1):gsub("}%s*$", "", 1) -- remove the starting and ending values to leave only the node data\r
-                       local escaped = value:gsub("\\\\", "@@"):gsub("\\\"", "@@"):gsub("(\"[^\"]*\")", function(s) return string.rep("@", #s) end)\r
+                       content = content:gsub("return%s*{", "", 1):gsub("}%s*$", "", 1) -- remove the starting and ending values to leave only the node data\r
+                       local escaped = content:gsub("\\\\", "@@"):gsub("\\\"", "@@"):gsub("(\"[^\"]*\")", function(s) return string.rep("@", #s) end)\r
                        local startpos, startpos1, endpos = 1, 1\r
                        while true do -- go through each individual node entry (except the last)\r
                                startpos, endpos = escaped:find("},%s*{", startpos)\r
                                if not startpos then\r
                                        break\r
                                end\r
-                               local current = value:sub(startpos1, startpos)\r
+                               local current = content:sub(startpos1, startpos)\r
                                local entry = minetest.deserialize("return " .. current)\r
                                table.insert(nodes, entry)\r
                                startpos, startpos1 = endpos, endpos\r
                        end\r
-                       local entry = minetest.deserialize("return " .. value:sub(startpos1)) -- process the last entry\r
+                       local entry = minetest.deserialize("return " .. content:sub(startpos1)) -- process the last entry\r
                        table.insert(nodes, entry)\r
                end\r
        else\r