]> git.lizzy.rs Git - worldedit.git/blob - worldedit_commands/wand.lua
078080199fb1802b7a3915215b0c4e15bdb7a106
[worldedit.git] / worldedit_commands / wand.lua
1 minetest.register_tool(":worldedit:wand", {
2         description = "WorldEdit Wand tool, Left-click to set 1st position, right-click to set 2nd",
3         inventory_image = "worldedit_wand.png",
4         stack_max = 1, -- there is no need to have more than one
5         liquids_pointable = true, -- ground with only water on can be selected as well
6
7         on_use = function(itemstack, placer, pointed_thing)
8                 if placer ~= nil and pointed_thing ~= nil and pointed_thing.type == "node" then
9                         local name = placer:get_player_name()
10                         worldedit.pos1[name] = pointed_thing.under
11                         worldedit.mark_pos1(name)
12                 end
13                 return itemstack -- nothing consumed, nothing changed
14         end,
15
16         on_place = function(itemstack, placer, pointed_thing) -- Left Click
17                 if placer ~= nil and pointed_thing ~= nil and pointed_thing.type == "node" then
18                         local name = placer:get_player_name()
19                         worldedit.pos2[name] = pointed_thing.under
20                         worldedit.mark_pos2(name)
21                 end
22                 return itemstack -- nothing consumed, nothing changed
23         end,
24 })