Minetest mod that adds scifi themed nodes https://content.minetest.net/packages/D00Med/scifi_nodes/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

113 lines
3.6 KiB

  1. -----------------------------------------------
  2. -- Palm scanner --
  3. -----------------------------------------------
  4. -- /!\ When "overriding" a callback function --
  5. -- re-use all the parameters in same order ! --
  6. -----------------------------------------------
  7. local has_mesecons = minetest.get_modpath("mesecons")
  8. local function activate_palm_scanner(pos, node, player)
  9. local name = player and player:get_player_name()
  10. name = name or ""
  11. node.name = "scifi_nodes:palm_scanner_checking"
  12. minetest.swap_node(pos, node)
  13. minetest.sound_play("scifi_nodes_palm_scanner", {max_hear_distance = 8, pos = pos, gain = 1.0})
  14. minetest.chat_send_player(name, "Checking : please wait.")
  15. -- check protection
  16. minetest.after(2, function()
  17. if minetest.is_protected(pos, name or "") then
  18. -- clicker has no access to area
  19. minetest.chat_send_player(name, "Access denied !")
  20. minetest.sound_play("scifi_nodes_scanner_refused", {max_hear_distance = 8, pos = pos, gain = 1.0})
  21. else
  22. -- clicker can build here
  23. minetest.chat_send_player(name, "Access granted !")
  24. mesecon.receptor_on(pos, scifi_nodes.get_switch_rules(node.param2))
  25. end
  26. -- reset state
  27. minetest.after(1, function()
  28. node.name = "scifi_nodes:palm_scanner_off"
  29. minetest.swap_node(pos, node)
  30. mesecon.receptor_off(pos, scifi_nodes.get_switch_rules(node.param2))
  31. end)
  32. end)
  33. end
  34. minetest.register_node("scifi_nodes:palm_scanner_off", {
  35. description = "Palm scanner",
  36. tiles = {"scifi_nodes_palm_scanner_off.png",},
  37. inventory_image = "scifi_nodes_palm_scanner_off.png",
  38. wield_image = "scifi_nodes_palm_scanner_on.png",
  39. drawtype = "signlike",
  40. sunlight_propagates = true,
  41. buildable_to = false,
  42. node_box = {type = "wallmounted",},
  43. selection_box = {type = "wallmounted",},
  44. paramtype = "light",
  45. paramtype2 = "wallmounted",
  46. groups = {cracky=1, oddly_breakable_by_hand=1, mesecon_needs_receiver = 1},
  47. mesecons = {
  48. receptor = {
  49. state = (has_mesecons and mesecon.state.off)
  50. }
  51. },
  52. on_rightclick = (has_mesecons and activate_palm_scanner),
  53. sounds = default.node_sound_glass_defaults(),
  54. })
  55. minetest.register_node("scifi_nodes:palm_scanner_checking", {
  56. description = "Palm scanner",
  57. tiles = {{
  58. name = "scifi_nodes_palm_scanner_checking.png",
  59. animation = {type = "vertical_frames",aspect_w = 16,aspect_h = 16,length = 1.5}
  60. }},
  61. drawtype = "signlike",
  62. sunlight_propagates = true,
  63. buildable_to = false,
  64. node_box = {type = "wallmounted",},
  65. selection_box = {type = "wallmounted",},
  66. paramtype = "light",
  67. paramtype2 = "wallmounted",
  68. groups = {cracky=1, oddly_breakable_by_hand=1, not_in_creative_inventory=1, mesecon_needs_receiver = 1},
  69. drop = "scifi_nodes:palm_scanner_off",
  70. sounds = default.node_sound_glass_defaults()
  71. })
  72. minetest.register_node("scifi_nodes:palm_scanner_on", {
  73. description = "Palm scanner",
  74. sunlight_propagates = true,
  75. buildable_to = false,
  76. tiles = {"scifi_nodes_palm_scanner_on.png",},
  77. inventory_image = "scifi_nodes_palm_scanner_on.png",
  78. wield_image = "scifi_nodes_palm_scanner_on.png",
  79. drawtype = "signlike",
  80. node_box = {type = "wallmounted",},
  81. selection_box = {type = "wallmounted",},
  82. paramtype = "light",
  83. paramtype2 = "wallmounted",
  84. light_source = 5,
  85. groups = {cracky=1, oddly_breakable_by_hand=1, not_in_creative_inventory=1, mesecon_needs_receiver = 1},
  86. drop = "scifi_nodes:palm_scanner_off",
  87. mesecons = {
  88. receptor = {
  89. state = (has_mesecons and mesecon.state.on)
  90. }
  91. },
  92. sounds = default.node_sound_glass_defaults(),
  93. })
  94. minetest.register_craft({
  95. output = "scifi_nodes:palm_scanner_off 2",
  96. recipe = {{"mesecons_powerplant:power_plant", "scifi_nodes:grey", ""}}
  97. })