hole.lua 710 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. local function make_hole(pos, depth)
  2. for d = 0,depth do
  3. local p = {x=pos.x, y=pos.y-d, z=pos.z}
  4. minetest.set_node(p, {name="default:ladder", param2 = 3})
  5. end
  6. end
  7. minetest.register_craftitem("potions:instant_hole", {
  8. description = "Instant Hole",
  9. inventory_image = "default_dirt_with_grass.png",
  10. wield_image = "default_dirt_with_grass.png",
  11. on_use = function(itemstack, player, pointed_thing)
  12. local pos = pointed_thing.under
  13. if not pos then
  14. return
  15. end
  16. local dist = 100 -- vector.distance(pos, pos2)
  17. dist = potions.use_manna(player, dist)
  18. if dist < 2 then
  19. return
  20. end
  21. make_hole(pos, dist)
  22. itemstack:take_item()
  23. return itemstack
  24. end,
  25. })