]> git.lizzy.rs Git - worldedit.git/commitdiff
Allow easily setting pos1 + 2 to the same node using the wand
authorsfan5 <sfan5@live.de>
Wed, 18 Sep 2019 22:06:30 +0000 (00:06 +0200)
committersfan5 <sfan5@live.de>
Wed, 18 Sep 2019 22:06:30 +0000 (00:06 +0200)
Though right-click currently doesn't work due to an engine bug.

worldedit_commands/wand.lua

index 9104b7d565492fdd917a452f00e535bba5da382f..fccc86366114e8788a9e1877e5bb91529200b9ed 100644 (file)
@@ -28,16 +28,31 @@ minetest.register_tool(":worldedit:wand", {
                                minetest.registered_chatcommands["/reset"].func(name, "")
                        end
                        punched_air_time[name] = now
+               elseif pointed_thing.type == "object" then
+                       local entity = pointed_thing.ref:get_luaentity()
+                       if entity and entity.name == "worldedit:pos2" then
+                               -- set pos1 = pos2
+                               worldedit.pos1[name] = worldedit.pos2[name]
+                               worldedit.mark_pos1(name)
+                       end
                end
                return itemstack -- nothing consumed, nothing changed
        end,
 
        on_place = function(itemstack, placer, pointed_thing)
-               if placer ~= nil and pointed_thing ~= nil and pointed_thing.type == "node" then
+               if placer == nil or pointed_thing == nil then return itemstack end
+               local name = placer:get_player_name()
+               if pointed_thing.type == "node" then
                        -- set and mark pos2
-                       local name = placer:get_player_name()
                        worldedit.pos2[name] = above_or_under(placer, pointed_thing)
                        worldedit.mark_pos2(name)
+               elseif pointed_thing.type == "object" then
+                       local entity = pointed_thing.ref:get_luaentity()
+                       if entity and entity.name == "worldedit:pos1" then
+                               -- set pos2 = pos1
+                               worldedit.pos2[name] = worldedit.pos1[name]
+                               worldedit.mark_pos2(name)
+                       end
                end
                return itemstack -- nothing consumed, nothing changed
        end,