]> git.lizzy.rs Git - worldedit.git/blob - worldedit_commands/wand.lua
Make compatibility error in worldedit_brush fatal again
[worldedit.git] / worldedit_commands / wand.lua
1 local function above_or_under(placer, pointed_thing)
2         if placer:get_player_control().sneak then
3                 return pointed_thing.above
4         else
5                 return pointed_thing.under
6         end
7 end
8
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
14
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)
20                 end
21                 return itemstack -- nothing consumed, nothing changed
22         end,
23
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)
29                 end
30                 return itemstack -- nothing consumed, nothing changed
31         end,
32 })