nodes.lua 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. teleports = teleports or {}
  2. minetest.register_node("teleports:teleport", {
  3. description = "Teleport Machine\n\nWarning: device is sensitive to shocks.\nIt will be destroyed if dug.",
  4. drawtype = "normal",
  5. tiles = {"teleports_teleport_top.png"},
  6. groups = utility.dig_groups("machine", {
  7. immovable=1,
  8. }),
  9. drop = 'default:diamond 8',
  10. sounds = default.node_sound_metal_defaults(),
  11. can_dig = function(...) return teleports.can_dig(...) end,
  12. after_place_node = function(...) return teleports.after_place_node(...) end,
  13. on_destruct = function(...) return teleports.on_destruct(...) end,
  14. on_punch = function(...) return teleports.on_punch(...) end,
  15. on_receive_fields = function(...) return teleports.on_receive_fields(...) end,
  16. allow_metadata_inventory_put = function(...) return teleports.allow_metadata_inventory_put(...) end,
  17. allow_metadata_inventory_take = function(...) return teleports.allow_metadata_inventory_take(...) end,
  18. allow_metadata_inventory_move = function(...) return teleports.allow_metadata_inventory_move(...) end,
  19. -- Called by rename LBM.
  20. _on_rename_check = function(pos)
  21. local meta = minetest.get_meta(pos)
  22. local owner = meta:get_string("owner")
  23. -- Nobody placed this block.
  24. if owner == "" then
  25. return
  26. end
  27. local dname = rename.gpn(owner)
  28. meta:set_string("rename", dname)
  29. -- Update infotext.
  30. teleports.write_infotext(pos)
  31. end,
  32. })
  33. -- Redefine diamond.
  34. minetest.override_item("default:diamondblock", {
  35. on_place = function(...) return teleports.on_diamond_place(...) end,
  36. })