Move worldedit.marker_update

Markers are part of the UI (`worldedit_chatcommands`) and do not belong in `worldedit`.
This commit is contained in:
sfan5 2020-04-07 00:14:31 +02:00
parent 963a9f6b96
commit 9b26034aea
4 changed files with 24 additions and 36 deletions

@ -98,21 +98,6 @@ worldedit.marker_move = function(name, marker, deltavector)
return true
end
-- Updates the location ingame of the markers
worldedit.marker_update = function(name, marker)
if marker == nil then
worldedit.mark_pos1(name)
worldedit.mark_pos2(name)
elseif marker == 1 then
worldedit.mark_pos1(name)
elseif marker == 2 then
worldedit.mark_pos2(name)
else
minetest.debug(
"worldedit: Invalid execution of function update_markers")
end
end
-- Returns two vectors with the directions for volumetric expansion
worldedit.get_expansion_directions = function(mark1, mark2)

@ -39,7 +39,7 @@ local brush_on_use = function(itemstack, placer)
assert(pointed_thing.type == "node")
worldedit.pos1[name] = pointed_thing.under
worldedit.pos2[name] = nil
worldedit.mark_region(name)
worldedit.marker_update(name)
-- this isn't really clean...
local player_notify_old = worldedit.player_notify

@ -333,8 +333,7 @@ worldedit.register_command("reset", {
func = function(name)
worldedit.pos1[name] = nil
worldedit.pos2[name] = nil
worldedit.mark_pos1(name)
worldedit.mark_pos2(name)
worldedit.marker_update(name)
worldedit.set_pos[name] = nil
--make sure the user does not try to confirm an operation after resetting pos:
reset_pending(name)
@ -347,8 +346,7 @@ worldedit.register_command("mark", {
description = "Show markers at the region positions",
privs = {worldedit=true},
func = function(name)
worldedit.mark_pos1(name)
worldedit.mark_pos2(name)
worldedit.marker_update(name)
worldedit.player_notify(name, "region marked")
end,
})
@ -361,8 +359,7 @@ worldedit.register_command("unmark", {
local pos1, pos2 = worldedit.pos1[name], worldedit.pos2[name]
worldedit.pos1[name] = nil
worldedit.pos2[name] = nil
worldedit.mark_pos1(name)
worldedit.mark_pos2(name)
worldedit.marker_update(name)
worldedit.pos1[name] = pos1
worldedit.pos2[name] = pos2
worldedit.player_notify(name, "region unmarked")
@ -945,8 +942,7 @@ worldedit.register_command("move", {
pos1[axis] = pos1[axis] + amount
pos2[axis] = pos2[axis] + amount
worldedit.mark_pos1(name)
worldedit.mark_pos2(name)
worldedit.marker_update(name)
worldedit.player_notify(name, count .. " nodes moved")
end,
})
@ -1037,8 +1033,7 @@ worldedit.register_command("stretch", {
--reset markers to scaled positions
worldedit.pos1[name] = pos1
worldedit.pos2[name] = pos2
worldedit.mark_pos1(name)
worldedit.mark_pos2(name)
worldedit.marker_update(name)
worldedit.player_notify(name, count .. " nodes stretched")
end,
@ -1068,8 +1063,7 @@ worldedit.register_command("transpose", {
--reset markers to transposed positions
worldedit.pos1[name] = pos1
worldedit.pos2[name] = pos2
worldedit.mark_pos1(name)
worldedit.mark_pos2(name)
worldedit.marker_update(name)
worldedit.player_notify(name, count .. " nodes transposed")
end,
@ -1119,8 +1113,7 @@ worldedit.register_command("rotate", {
--reset markers to rotated positions
worldedit.pos1[name] = pos1
worldedit.pos2[name] = pos2
worldedit.mark_pos1(name)
worldedit.mark_pos2(name)
worldedit.marker_update(name)
worldedit.player_notify(name, count .. " nodes rotated")
end,
@ -1346,9 +1339,8 @@ worldedit.register_command("allocate", {
end
worldedit.pos1[name] = nodepos1
worldedit.mark_pos1(name)
worldedit.pos2[name] = nodepos2
worldedit.mark_pos2(name)
worldedit.marker_update(name)
worldedit.player_notify(name, count .. " nodes allocated")
end,

@ -3,7 +3,7 @@ worldedit.marker2 = {}
worldedit.marker_region = {}
--marks worldedit region position 1
worldedit.mark_pos1 = function(name)
worldedit.mark_pos1 = function(name, region_too)
local pos1, pos2 = worldedit.pos1[name], worldedit.pos2[name]
if pos1 ~= nil then
@ -22,11 +22,13 @@ worldedit.mark_pos1 = function(name)
worldedit.marker1[name]:get_luaentity().player_name = name
end
end
worldedit.mark_region(name)
if region_too == nil or region_too then
worldedit.mark_region(name)
end
end
--marks worldedit region position 2
worldedit.mark_pos2 = function(name)
worldedit.mark_pos2 = function(name, region_too)
local pos1, pos2 = worldedit.pos1[name], worldedit.pos2[name]
if pos2 ~= nil then
@ -45,7 +47,9 @@ worldedit.mark_pos2 = function(name)
worldedit.marker2[name]:get_luaentity().player_name = name
end
end
worldedit.mark_region(name)
if region_too == nil or region_too then
worldedit.mark_region(name)
end
end
worldedit.mark_region = function(name)
@ -111,6 +115,13 @@ worldedit.mark_region = function(name)
end
end
--convenience function that calls everything
worldedit.marker_update = function(name)
worldedit.mark_pos1(name, false)
worldedit.mark_pos2(name, false)
worldedit.mark_region(name)
end
minetest.register_entity(":worldedit:pos1", {
initial_properties = {
visual = "cube",