Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[ Heat detector
- If a hot node is detected within 30 metres, sound the alarm!
- --]]
- local hotNodes = {"fire:basic_flame","default:lava_source", "default:torch" }
- local ruleset = {
- {x = 1, y = 0, z = 0}, -- x-positive
- {x = -1, y = 0, z = 0}, -- x-negative
- {x = 0, y = 1, z = 0}, -- y-positive
- {x = 0, y = -1, z = 0}, -- y-negative
- {x = 0, y = 0, z = 1}, -- z-positive
- {x = 0, y = 0, z = -1} -- z-negative
- }
- minetest.register_node("firesafety:heatdetector", {
- on_timer = function(pos)
- local thereAreFires = minetest.find_node_near(pos, 5, hotNodes)
- print("detected FIRE!!!!")
- if thereAreFires then
- local setchan = minetest.get_meta(pos):get_string("channel")
- digiline:receptor_send(position_of_message, ruleset, setchan, "fire")
- end
- end,
- on_construct = function(pos)
- local timer = minetest.get_node_timer(pos)
- timer:start(1)
- local meta = minetest.get_meta(pos)
- meta:set_string("formspec", "field[channel;Channel;${channel}]")
- end,
- on_receive_fields = function(pos, _, fields, sender)
- local name = sender:get_player_name()
- if minetest.is_protected(pos, name) and not minetest.check_player_privs(name, {protection_bypass=true}) then
- minetest.record_protection_violation(pos, name)
- return
- end
- if (fields.channel) then
- minetest.get_meta(pos):set_string("channel", fields.channel)
- end
- end
- })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement