nodes.lua 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. if not minetest.global_exists("teleports") then teleports = {} end
  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',
  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. on_metadata_inventory_put = function(...) return teleports.on_metadata_inventory_put(...) end,
  20. on_metadata_inventory_take = function(...) return teleports.on_metadata_inventory_take(...) end,
  21. -- Called by rename LBM.
  22. _on_update_infotext = function(pos)
  23. local meta = minetest.get_meta(pos)
  24. local owner = meta:get_string("owner")
  25. -- Nobody placed this block.
  26. if owner == "" then
  27. return
  28. end
  29. local dname = rename.gpn(owner)
  30. meta:set_string("rename", dname)
  31. -- Update infotext.
  32. teleports.write_infotext(pos)
  33. end,
  34. })
  35. -- Redefine diamond.
  36. minetest.override_item("default:diamondblock", {
  37. on_place = function(...) return teleports.on_diamond_place(...) end,
  38. })