update worldedit
parent
e5c6ef8546
commit
9d602197a6
|
@ -231,13 +231,21 @@ function worldedit.deserialize(origin_pos, value, backup, name)
|
|||
local count = 0
|
||||
local f = {x = 0, y = 0, z = 0}
|
||||
|
||||
if backup and worldedit.pos1[name] and worldedit.pos2[name] then
|
||||
local file_pos = io.open(minetest.get_worldpath() .. "/schems/backup_pos_" .. name, "r")
|
||||
local content = file_pos:read("*a")
|
||||
file_pos:close()
|
||||
|
||||
local pos_markers = minetest.deserialize(content)
|
||||
local pos_marker1 = pos_markers.marker1
|
||||
local pos_marker2 = pos_markers.marker2
|
||||
|
||||
if backup and pos_marker1 and pos_marker2 then
|
||||
for i, entry in ipairs(nodes) do
|
||||
if entry.x > f.x then
|
||||
f.x = entry.x
|
||||
end
|
||||
|
||||
if worldedit.pos1[name].y > worldedit.pos2[name].y then
|
||||
if pos_marker1.y > pos_marker2.y then
|
||||
f.y = entry.y
|
||||
end
|
||||
|
||||
|
@ -246,11 +254,11 @@ function worldedit.deserialize(origin_pos, value, backup, name)
|
|||
end
|
||||
end
|
||||
|
||||
if worldedit.pos1[name].x < worldedit.pos2[name].x then
|
||||
if pos_marker1.x < pos_marker2.x then
|
||||
f.x = 0
|
||||
end
|
||||
|
||||
if worldedit.pos1[name].z < worldedit.pos2[name].z then
|
||||
if pos_marker1.z < pos_marker2.z then
|
||||
f.z = 0
|
||||
end
|
||||
end
|
||||
|
|
|
@ -70,7 +70,7 @@ local function save_region(name, param, backup)
|
|||
-- Create directory if it does not already exist
|
||||
mkdir(path)
|
||||
|
||||
local filename = path .. "/" .. (backup and name or param) .. ".we"
|
||||
local filename = path .. "/" .. (backup and "backup_" .. name or param) .. ".we"
|
||||
|
||||
local f = io.open(filename, "r")
|
||||
if f then
|
||||
|
@ -89,13 +89,26 @@ local function save_region(name, param, backup)
|
|||
file2:flush()
|
||||
file2:close()
|
||||
|
||||
if not backup then
|
||||
if backup then
|
||||
local file_pos = io.open(minetest.get_worldpath() .. "/schems/backup_pos_" .. name, "w")
|
||||
local pos = {
|
||||
marker1 = worldedit.pos1[name],
|
||||
marker2 = worldedit.pos2[name],
|
||||
}
|
||||
|
||||
file_pos:write(minetest.serialize(pos))
|
||||
file_pos:close()
|
||||
else
|
||||
worldedit.player_notify(name, count .. " nodes saved")
|
||||
end
|
||||
end
|
||||
|
||||
local function load_region(name, param, backup)
|
||||
local pos = get_position(name)
|
||||
local file_pos = io.open(minetest.get_worldpath() .. "/schems/backup_pos_" .. name, "r")
|
||||
local content = file_pos:read("*a")
|
||||
file_pos:close()
|
||||
|
||||
local pos = minetest.deserialize(content).marker1
|
||||
if not pos then return end
|
||||
|
||||
if not backup and param == "" then
|
||||
|
@ -110,9 +123,9 @@ local function load_region(name, param, backup)
|
|||
|
||||
--find the file in the world path
|
||||
local testpaths = {
|
||||
minetest.get_worldpath() .. "/schems/" .. (backup and name or param),
|
||||
minetest.get_worldpath() .. "/schems/" .. (backup and name or param) .. ".we",
|
||||
minetest.get_worldpath() .. "/schems/" .. (backup and name or param) .. ".wem",
|
||||
minetest.get_worldpath() .. "/schems/" .. (backup and "backup_" .. name or param),
|
||||
minetest.get_worldpath() .. "/schems/" .. (backup and "backup_" .. name or param) .. ".we",
|
||||
minetest.get_worldpath() .. "/schems/" .. (backup and "backup_" .. name or param) .. ".wem",
|
||||
}
|
||||
|
||||
local file, err
|
||||
|
@ -122,7 +135,8 @@ local function load_region(name, param, backup)
|
|||
end
|
||||
|
||||
if err then
|
||||
worldedit.player_notify(name, "could not open file \"" .. (backup and name or param) .. "\"")
|
||||
worldedit.player_notify(name, "could not open file \"" ..
|
||||
(backup and "backup_" .. name or param) .. "\"")
|
||||
return
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue