1
0
mirror of https://github.com/Uberi/Minetest-WorldEdit.git synced 2024-12-25 02:00:39 +01:00

Allow easily setting pos1 + 2 to the same node using the wand

Though right-click currently doesn't work due to an engine bug.
This commit is contained in:
sfan5 2019-09-19 00:06:30 +02:00
parent 79097dc6c8
commit 63a7069671

View File

@ -28,16 +28,31 @@ minetest.register_tool(":worldedit:wand", {
minetest.registered_chatcommands["/reset"].func(name, "") minetest.registered_chatcommands["/reset"].func(name, "")
end end
punched_air_time[name] = now 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 end
return itemstack -- nothing consumed, nothing changed return itemstack -- nothing consumed, nothing changed
end, end,
on_place = function(itemstack, placer, pointed_thing) 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 -- set and mark pos2
local name = placer:get_player_name()
worldedit.pos2[name] = above_or_under(placer, pointed_thing) worldedit.pos2[name] = above_or_under(placer, pointed_thing)
worldedit.mark_pos2(name) 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 end
return itemstack -- nothing consumed, nothing changed return itemstack -- nothing consumed, nothing changed
end, end,