summaryrefslogtreecommitdiff
path: root/firealarm_pullstation/init.lua
diff options
context:
space:
mode:
Diffstat (limited to 'firealarm_pullstation/init.lua')
-rw-r--r--firealarm_pullstation/init.lua90
1 files changed, 90 insertions, 0 deletions
diff --git a/firealarm_pullstation/init.lua b/firealarm_pullstation/init.lua
new file mode 100644
index 0000000..b212ec8
--- /dev/null
+++ b/firealarm_pullstation/init.lua
@@ -0,0 +1,90 @@
+minetest.register_node(":firealarm:pullstation_off",{
+ description = "Fire Alarm Pull Station",
+ groups = { oddly_breakable_by_hand = 1 },
+ tiles = {
+ "firealarm_pullstation_back.png",
+ "firealarm_pullstation_back.png",
+ "firealarm_pullstation_back.png",
+ "firealarm_pullstation_back.png",
+ "firealarm_pullstation_back.png",
+ "firealarm_pullstation_front_off.png",
+ },
+ paramtype = "light",
+ paramtype2 = "facedir",
+ drawtype = "nodebox",
+ node_box = {
+ type = "fixed",
+ fixed = {
+ {-0.15,-0.5,0.4,0.18,-0.11,0.5},
+ },
+ },
+ on_punch = function(pos,_,player)
+ local name = player:get_player_name()
+ minetest.chat_send_player(name,string.format("Position: %d,%d,%d",pos.x,pos.y,pos.z))
+ end,
+ on_rightclick = function(pos,node)
+ local devInfo = firealarm.getDevInfo("signaling",pos)
+ if devInfo then
+ devInfo.active = true
+ node.name = "firealarm:pullstation_on"
+ minetest.set_node(pos,node)
+ minetest.sound_play("firealarm_pullstation_pull",{pos=pos})
+ if devInfo.associated then
+ local panelPos = minetest.get_position_from_hash(devInfo.associated)
+ if panelPos then firealarm.loadNode(panelPos) end
+ if type(firealarm.panelABM) == "function" then firealarm.panelABM(pos) end
+ end
+ end
+ end,
+ after_place_node = function(pos)
+ firealarm.setDevInfo("signaling",pos,{active = false,manualReset = true})
+ end,
+ after_dig_node = function(pos)
+ firealarm.setDevInfo("signaling",pos,nil)
+ end,
+})
+
+minetest.register_node(":firealarm:pullstation_on",{
+ drop = "firealarm:pullstation_off",
+ description = "Fire Alarm Pull Station (pulled state - you hacker you!)",
+ groups = { oddly_breakable_by_hand = 1,not_in_creative_inventory = 1 },
+ tiles = {
+ "firealarm_pullstation_back.png",
+ "firealarm_pullstation_back.png",
+ "firealarm_pullstation_back.png",
+ "firealarm_pullstation_back.png",
+ "firealarm_pullstation_back.png",
+ "firealarm_pullstation_front_on.png",
+ },
+ paramtype = "light",
+ paramtype2 = "facedir",
+ drawtype = "nodebox",
+ node_box = {
+ type = "fixed",
+ fixed = {
+ {-0.15,-0.5,0.4,0.18,-0.11,0.5},
+ },
+ },
+ on_punch = function(pos,_,player)
+ local name = player:get_player_name()
+ minetest.chat_send_player(name,string.format("Position: %d,%d,%d",pos.x,pos.y,pos.z))
+ end,
+ on_rightclick = function(pos,node,name)
+ --local name = minetest.get_player_name(clicker)
+ if minetest.is_protected(pos,name) and not minetest.check_player_privs(name,"protection_bypass") then
+ minetest.record_protection_violation(pos,name)
+ minetest.chat_send_player(name,"You are not authorized to reset this pull station")
+ return
+ end
+ local devInfo = firealarm.getDevInfo("signaling",pos)
+ if devInfo then
+ devInfo.active = false
+ node.name = "firealarm:pullstation_off"
+ minetest.set_node(pos,node)
+ minetest.sound_play("firealarm_pullstation_reset",{pos=pos})
+ end
+ end,
+ after_dig_node = function(pos)
+ firealarm.setDevInfo("signaling",pos,nil)
+ end,
+})