1 local function above_or_under(placer, pointed_thing)
2 if placer:get_player_control().sneak then
3 return pointed_thing.above
5 return pointed_thing.under
9 minetest.register_tool(":worldedit:wand", {
10 description = "WorldEdit Wand tool, Left-click to set 1st position, right-click to set 2nd",
11 inventory_image = "worldedit_wand.png",
12 stack_max = 1, -- there is no need to have more than one
13 liquids_pointable = true, -- ground with only water on can be selected as well
15 on_use = function(itemstack, placer, pointed_thing)
16 if placer ~= nil and pointed_thing ~= nil and pointed_thing.type == "node" then
17 local name = placer:get_player_name()
18 worldedit.pos1[name] = above_or_under(placer, pointed_thing)
19 worldedit.mark_pos1(name)
21 return itemstack -- nothing consumed, nothing changed
24 on_place = function(itemstack, placer, pointed_thing) -- Left Click
25 if placer ~= nil and pointed_thing ~= nil and pointed_thing.type == "node" then
26 local name = placer:get_player_name()
27 worldedit.pos2[name] = above_or_under(placer, pointed_thing)
28 worldedit.mark_pos2(name)
30 return itemstack -- nothing consumed, nothing changed