Advertisement
Guest User

Untitled

a guest
Aug 15th, 2023
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.46 KB | None | 0 0
  1.  --[[ Heat detector
  2. If a hot node is detected within 30 metres, sound the alarm!
  3. --]]
  4.  
  5. local hotNodes = {"fire:basic_flame","default:lava_source", "default:torch" }
  6.  
  7. local ruleset = {
  8.     {x = 1, y = 0, z = 0},  -- x-positive
  9.     {x = -1, y = 0, z = 0}, -- x-negative
  10.     {x = 0, y = 1, z = 0},  -- y-positive
  11.     {x = 0, y = -1, z = 0}, -- y-negative
  12.     {x = 0, y = 0, z = 1},  -- z-positive
  13.     {x = 0, y = 0, z = -1}  -- z-negative
  14. }
  15.  
  16. minetest.register_node("firesafety:heatdetector", {
  17.     on_timer = function(pos)
  18.         local thereAreFires = minetest.find_node_near(pos, 5, hotNodes)
  19.        
  20.         print("detected FIRE!!!!")
  21.        
  22.         if thereAreFires then
  23.             local setchan = minetest.get_meta(pos):get_string("channel")
  24.            
  25.             digiline:receptor_send(position_of_message, ruleset, setchan, "fire")
  26.         end
  27.     end,
  28.    
  29.     on_construct = function(pos)
  30.         local timer = minetest.get_node_timer(pos)
  31.         timer:start(1)
  32.         local meta = minetest.get_meta(pos)
  33.         meta:set_string("formspec", "field[channel;Channel;${channel}]")
  34.     end,
  35.    
  36.     on_receive_fields = function(pos, _, fields, sender)
  37.         local name = sender:get_player_name()
  38.         if minetest.is_protected(pos, name) and not minetest.check_player_privs(name, {protection_bypass=true}) then
  39.             minetest.record_protection_violation(pos, name)
  40.             return
  41.         end
  42.         if (fields.channel) then
  43.             minetest.get_meta(pos):set_string("channel", fields.channel)
  44.         end
  45.     end
  46. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement