]> git.lizzy.rs Git - worldedit.git/commitdiff
Move worldedit.marker_update
authorsfan5 <sfan5@live.de>
Mon, 6 Apr 2020 22:14:31 +0000 (00:14 +0200)
committersfan5 <sfan5@live.de>
Mon, 6 Apr 2020 22:14:31 +0000 (00:14 +0200)
Markers are part of the UI (`worldedit_chatcommands`) and do not belong in `worldedit`.

worldedit/cuboid.lua
worldedit_brush/init.lua
worldedit_commands/init.lua
worldedit_commands/mark.lua

index d98e25c3e16feef5bc9c22f48046eb58e6270e1f..d27e2333accd838646d44255a440da44c02e54a6 100644 (file)
@@ -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)
index 0c1ff950baf5a8fa24464d96dd5e416dea82f237..369b6b5332ef731126016e86a3caae310fbd6057 100644 (file)
@@ -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
index 91c16443711fbbbf202c273a7584b3c0b2ea47da..32bbc6c1e98abb566a3596e66e44aea86207e310 100644 (file)
@@ -333,8 +333,7 @@ worldedit.register_command("reset", {
        func = function(name)\r
                worldedit.pos1[name] = nil\r
                worldedit.pos2[name] = nil\r
-               worldedit.mark_pos1(name)\r
-               worldedit.mark_pos2(name)\r
+               worldedit.marker_update(name)\r
                worldedit.set_pos[name] = nil\r
                --make sure the user does not try to confirm an operation after resetting pos:\r
                reset_pending(name)\r
@@ -347,8 +346,7 @@ worldedit.register_command("mark", {
        description = "Show markers at the region positions",\r
        privs = {worldedit=true},\r
        func = function(name)\r
-               worldedit.mark_pos1(name)\r
-               worldedit.mark_pos2(name)\r
+               worldedit.marker_update(name)\r
                worldedit.player_notify(name, "region marked")\r
        end,\r
 })\r
@@ -361,8 +359,7 @@ worldedit.register_command("unmark", {
                local pos1, pos2 = worldedit.pos1[name], worldedit.pos2[name]\r
                worldedit.pos1[name] = nil\r
                worldedit.pos2[name] = nil\r
-               worldedit.mark_pos1(name)\r
-               worldedit.mark_pos2(name)\r
+               worldedit.marker_update(name)\r
                worldedit.pos1[name] = pos1\r
                worldedit.pos2[name] = pos2\r
                worldedit.player_notify(name, "region unmarked")\r
@@ -945,8 +942,7 @@ worldedit.register_command("move", {
 \r
                pos1[axis] = pos1[axis] + amount\r
                pos2[axis] = pos2[axis] + amount\r
-               worldedit.mark_pos1(name)\r
-               worldedit.mark_pos2(name)\r
+               worldedit.marker_update(name)\r
                worldedit.player_notify(name, count .. " nodes moved")\r
        end,\r
 })\r
@@ -1037,8 +1033,7 @@ worldedit.register_command("stretch", {
                --reset markers to scaled positions\r
                worldedit.pos1[name] = pos1\r
                worldedit.pos2[name] = pos2\r
-               worldedit.mark_pos1(name)\r
-               worldedit.mark_pos2(name)\r
+               worldedit.marker_update(name)\r
 \r
                worldedit.player_notify(name, count .. " nodes stretched")\r
        end,\r
@@ -1068,8 +1063,7 @@ worldedit.register_command("transpose", {
                --reset markers to transposed positions\r
                worldedit.pos1[name] = pos1\r
                worldedit.pos2[name] = pos2\r
-               worldedit.mark_pos1(name)\r
-               worldedit.mark_pos2(name)\r
+               worldedit.marker_update(name)\r
 \r
                worldedit.player_notify(name, count .. " nodes transposed")\r
        end,\r
@@ -1119,8 +1113,7 @@ worldedit.register_command("rotate", {
                --reset markers to rotated positions\r
                worldedit.pos1[name] = pos1\r
                worldedit.pos2[name] = pos2\r
-               worldedit.mark_pos1(name)\r
-               worldedit.mark_pos2(name)\r
+               worldedit.marker_update(name)\r
 \r
                worldedit.player_notify(name, count .. " nodes rotated")\r
        end,\r
@@ -1346,9 +1339,8 @@ worldedit.register_command("allocate", {
                end\r
 \r
                worldedit.pos1[name] = nodepos1\r
-               worldedit.mark_pos1(name)\r
                worldedit.pos2[name] = nodepos2\r
-               worldedit.mark_pos2(name)\r
+               worldedit.marker_update(name)\r
 \r
                worldedit.player_notify(name, count .. " nodes allocated")\r
        end,\r
index cb45075c48848a6bdfc90c07107fec5d3e9d765f..874999d4949227fdc802dadf67e2090f291f7c26 100644 (file)
@@ -3,7 +3,7 @@ worldedit.marker2 = {}
 worldedit.marker_region = {}\r
 \r
 --marks worldedit region position 1\r
-worldedit.mark_pos1 = function(name)\r
+worldedit.mark_pos1 = function(name, region_too)\r
        local pos1, pos2 = worldedit.pos1[name], worldedit.pos2[name]\r
 \r
        if pos1 ~= nil then\r
@@ -22,11 +22,13 @@ worldedit.mark_pos1 = function(name)
                        worldedit.marker1[name]:get_luaentity().player_name = name\r
                end\r
        end\r
-       worldedit.mark_region(name)\r
+       if region_too == nil or region_too then\r
+               worldedit.mark_region(name)\r
+       end\r
 end\r
 \r
 --marks worldedit region position 2\r
-worldedit.mark_pos2 = function(name)\r
+worldedit.mark_pos2 = function(name, region_too)\r
        local pos1, pos2 = worldedit.pos1[name], worldedit.pos2[name]\r
 \r
        if pos2 ~= nil then\r
@@ -45,7 +47,9 @@ worldedit.mark_pos2 = function(name)
                        worldedit.marker2[name]:get_luaentity().player_name = name\r
                end\r
        end\r
-       worldedit.mark_region(name)\r
+       if region_too == nil or region_too then\r
+               worldedit.mark_region(name)\r
+       end\r
 end\r
 \r
 worldedit.mark_region = function(name)\r
@@ -111,6 +115,13 @@ worldedit.mark_region = function(name)
        end\r
 end\r
 \r
+--convenience function that calls everything\r
+worldedit.marker_update = function(name)\r
+       worldedit.mark_pos1(name, false)\r
+       worldedit.mark_pos2(name, false)\r
+       worldedit.mark_region(name)\r
+end\r
+\r
 minetest.register_entity(":worldedit:pos1", {\r
        initial_properties = {\r
                visual = "cube",\r