mirror of
https://github.com/sbrl/Minetest-WorldEditAdditions.git
synced 2024-10-31 21:33:02 +00:00
pos: avoid calling worldedit.marker_update unless necessary
This commit is contained in:
parent
2c30ed8634
commit
693fc145d5
1 changed files with 13 additions and 5 deletions
|
@ -78,16 +78,21 @@ end
|
||||||
--- Sets pos1/pos2 in worldedit for compatibility.
|
--- Sets pos1/pos2 in worldedit for compatibility.
|
||||||
-- @param player_name string The name of the player to set the position for.
|
-- @param player_name string The name of the player to set the position for.
|
||||||
-- @param i number The index of the position to set.
|
-- @param i number The index of the position to set.
|
||||||
-- @returns Vector3? The position to set.
|
-- @param pos Vector3 The position to set.
|
||||||
local function compat_worldedit_set(player_name, i, pos)
|
-- @param do_update=true bool Whether to call worldedit.marker_update() or not.
|
||||||
|
-- @returns nil
|
||||||
|
local function compat_worldedit_set(player_name, i, pos, do_update)
|
||||||
|
if do_update == nil then do_update = false end
|
||||||
if not worldedit then return end
|
if not worldedit then return end
|
||||||
if i == 1 and worldedit.pos1 then
|
if i == 1 and worldedit.pos1 then
|
||||||
worldedit.pos1[player_name] = nil
|
worldedit.pos1[player_name] = nil
|
||||||
if worldedit.marker_update then worldedit.marker_update(player_name) end
|
if do_update and worldedit.marker_update then
|
||||||
|
worldedit.marker_update(player_name) end
|
||||||
worldedit.pos1[player_name] = pos:clone()
|
worldedit.pos1[player_name] = pos:clone()
|
||||||
elseif i == 2 and worldedit.pos2 then
|
elseif i == 2 and worldedit.pos2 then
|
||||||
worldedit.pos2[player_name] = nil
|
worldedit.pos2[player_name] = nil
|
||||||
if worldedit.marker_update then worldedit.marker_update(player_name) end
|
if do_update and worldedit.marker_update then
|
||||||
|
worldedit.marker_update(player_name) end
|
||||||
worldedit.pos2[player_name] = pos:clone()
|
worldedit.pos2[player_name] = pos:clone()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -231,7 +236,10 @@ local function pop(player_name)
|
||||||
local last_pos = table.remove(positions[player_name])
|
local last_pos = table.remove(positions[player_name])
|
||||||
if worldedit then
|
if worldedit then
|
||||||
if pos_count == 2 and worldedit.pos2 then worldedit.pos2[player_name] = nil
|
if pos_count == 2 and worldedit.pos2 then worldedit.pos2[player_name] = nil
|
||||||
elseif pos_count == 1 and worldedit.pos1 then worldedit.pos1[player_name] = nil end
|
elseif pos_count == 1 and worldedit.pos1 then
|
||||||
|
worldedit.pos1[player_name] = nil
|
||||||
|
worldedit.marker_update(player_name)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
anchor:emit("pop", { player_name = player_name, pos = last_pos, i = pos_count })
|
anchor:emit("pop", { player_name = player_name, pos = last_pos, i = pos_count })
|
||||||
|
|
Loading…
Reference in a new issue