wand.lua 976 B

12345678910111213141516171819202122232425
  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. on_use = function(itemstack, placer, pointed_thing)
  7. if placer ~= nil and pointed_thing ~= nil and pointed_thing.type == "node" then
  8. local name = placer:get_player_name()
  9. worldedit.pos1[name] = pointed_thing.under
  10. worldedit.mark_pos1(name)
  11. end
  12. return itemstack -- nothing consumed, nothing changed
  13. end,
  14. on_place = function(itemstack, placer, pointed_thing) -- Left Click
  15. if placer ~= nil and pointed_thing ~= nil and pointed_thing.type == "node" then
  16. local name = placer:get_player_name()
  17. worldedit.pos2[name] = pointed_thing.under
  18. worldedit.mark_pos2(name)
  19. end
  20. return itemstack -- nothing consumed, nothing changed
  21. end,
  22. })