From 6dc64c7050c410e0979e520bbbd6b60ba46fb485 Mon Sep 17 00:00:00 2001 From: cheapie Date: Thu, 30 Aug 2018 18:13:59 -0500 Subject: Add remote strobe and old-fashioned horn/light plate --- firealarm_common/init.lua | 2 + firealarm_hornstrobe/init.lua | 189 +++++++++++++++++++++ firealarm_hornstrobe/sounds/firealarm_horn_old.ogg | Bin 0 -> 38903 bytes .../firealarm_hornstrobe_old_front_off.png | Bin 0 -> 2882 bytes .../textures/firealarm_hornstrobe_old_front_on.png | Bin 0 -> 2835 bytes ...firealarm_hornstrobe_remotestrobe_front_off.png | Bin 0 -> 1622 bytes firealarm_panel/init.lua | 8 + 7 files changed, 199 insertions(+) create mode 100644 firealarm_hornstrobe/sounds/firealarm_horn_old.ogg create mode 100644 firealarm_hornstrobe/textures/firealarm_hornstrobe_old_front_off.png create mode 100644 firealarm_hornstrobe/textures/firealarm_hornstrobe_old_front_on.png create mode 100644 firealarm_hornstrobe/textures/firealarm_hornstrobe_remotestrobe_front_off.png diff --git a/firealarm_common/init.lua b/firealarm_common/init.lua index ae2a2a0..34ab2ca 100644 --- a/firealarm_common/init.lua +++ b/firealarm_common/init.lua @@ -4,6 +4,7 @@ firealarm.devices = { panel = {}, signaling = {}, notification = {}, + annunciator = {}, } function firealarm.loadNode(pos) @@ -23,6 +24,7 @@ function firealarm.loadDevLists() file:close() local data = minetest.deserialize(serdata) if type(data) == "table" then + if not data.annunciator then data.annunciator = {} end firealarm.devices = data else error("Fire alarm devices table is corrupted or contains invalid data") diff --git a/firealarm_hornstrobe/init.lua b/firealarm_hornstrobe/init.lua index 8f48912..fc7ac13 100644 --- a/firealarm_hornstrobe/init.lua +++ b/firealarm_hornstrobe/init.lua @@ -77,6 +77,156 @@ minetest.register_node(":firealarm:hornstrobe_on",{ }, }) +minetest.register_node(":firealarm:remotestrobe_off",{ + description = "Fire Alarm Remote Strobe", + groups = { oddly_breakable_by_hand = 1 }, + tiles = { + "firealarm_hornstrobe_top.png", + "firealarm_hornstrobe_top.png", + "firealarm_hornstrobe_side.png", + "firealarm_hornstrobe_side.png", + "firealarm_hornstrobe_back.png", + "firealarm_hornstrobe_remotestrobe_front_off.png", + }, + paramtype = "light", + paramtype2 = "facedir", + drawtype = "nodebox", + node_box = { + type = "fixed", + fixed = { + {-0.15,-0.02,0.4,0.18,0.37,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, + after_place_node = function(pos) + firealarm.setDevInfo("notification",pos,{strobeActive = false,hornActive = false}) + end, + after_dig_node = function(pos) + firealarm.setDevInfo("notification",pos,nil) + end, +}) + +local remoteStrobeOnFrontTexture = "[combine:32x320".. + ":0,0=firealarm_hornstrobe_front_on.png".. + ":0,32=firealarm_hornstrobe_remotestrobe_front_off.png".. + ":0,64=firealarm_hornstrobe_remotestrobe_front_off.png".. + ":0,96=firealarm_hornstrobe_remotestrobe_front_off.png".. + ":0,128=firealarm_hornstrobe_remotestrobe_front_off.png".. + ":0,160=firealarm_hornstrobe_remotestrobe_front_off.png".. + ":0,192=firealarm_hornstrobe_remotestrobe_front_off.png".. + ":0,224=firealarm_hornstrobe_remotestrobe_front_off.png".. + ":0,256=firealarm_hornstrobe_remotestrobe_front_off.png".. + ":0,288=firealarm_hornstrobe_remotestrobe_front_off.png" + +minetest.register_node(":firealarm:remotestrobe_on",{ + drop = "firealarm:remotestrobe_off", + description = "Fire Alarm Remote Strobe (on state - you hacker you!)", + groups = { oddly_breakable_by_hand = 1,not_in_creative_inventory = 1 }, + tiles = { + "firealarm_hornstrobe_top.png", + "firealarm_hornstrobe_top.png", + "firealarm_hornstrobe_side.png", + "firealarm_hornstrobe_side.png", + "firealarm_hornstrobe_back.png", + { + name = remoteStrobeOnFrontTexture, + animation = + { + type = "vertical_frames", + aspect_w = 32, + aspect_h = 32, + length = 1, + }, + } + }, + paramtype = "light", + paramtype2 = "facedir", + light_source = 8, + use_texture_alpha = true, + drawtype = "nodebox", + node_box = { + type = "fixed", + fixed = { + {-0.5,-0.5,0.4,0.5,0.5,0.401}, + {-0.15,-0.02,0.4,0.18,0.37,0.5}, + }, + }, +}) + +minetest.register_node(":firealarm:hornstrobe_old_off",{ + description = "Fire Alarm Horn/Light Plate", + groups = { oddly_breakable_by_hand = 1 }, + tiles = { + "firealarm_hornstrobe_top.png", + "firealarm_hornstrobe_top.png", + "firealarm_hornstrobe_side.png", + "firealarm_hornstrobe_side.png", + "firealarm_hornstrobe_back.png", + "firealarm_hornstrobe_old_front_off.png", + }, + paramtype = "light", + paramtype2 = "facedir", + drawtype = "nodebox", + node_box = { + type = "fixed", + fixed = { + {-0.15,-0.02,0.4,0.18,0.37,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, + after_place_node = function(pos) + firealarm.setDevInfo("notification",pos,{strobeActive = false,hornActive = false}) + end, + after_dig_node = function(pos) + firealarm.setDevInfo("notification",pos,nil) + end, +}) + +local oldHornStrobeOnFrontTexture = "[combine:64x128".. + ":0,0=firealarm_hornstrobe_old_front_on.png".. + ":0,64=firealarm_hornstrobe_old_front_off.png" + +minetest.register_node(":firealarm:hornstrobe_old_on",{ + drop = "firealarm:hornstrobe_old_off", + description = "Fire Alarm Horn/Light Plate (on state - you hacker you!)", + groups = { oddly_breakable_by_hand = 1,not_in_creative_inventory = 1 }, + tiles = { + "firealarm_hornstrobe_top.png", + "firealarm_hornstrobe_top.png", + "firealarm_hornstrobe_side.png", + "firealarm_hornstrobe_side.png", + "firealarm_hornstrobe_back.png", + { + name = oldHornStrobeOnFrontTexture, + animation = + { + type = "vertical_frames", + aspect_w = 64, + aspect_h = 64, + length = 0.6, + }, + } + }, + paramtype = "light", + paramtype2 = "facedir", + light_source = 8, + use_texture_alpha = true, + drawtype = "nodebox", + node_box = { + type = "fixed", + fixed = { + {-0.5,-0.5,0.4,0.5,0.5,0.401}, + {-0.15,-0.02,0.4,0.18,0.37,0.5}, + }, + }, +}) + minetest.register_abm({ label = "Update horn/strobe state", nodenames = {"firealarm:hornstrobe_off","firealarm:hornstrobe_on"}, @@ -97,3 +247,42 @@ minetest.register_abm({ end end, }) + +minetest.register_abm({ + label = "Update remote strobe state", + nodenames = {"firealarm:remotestrobe_off","firealarm:remotestrobe_on"}, + interval = 1, + chance = 1, + action = function(pos,node) + local devInfo = firealarm.getDevInfo("notification",pos) + if not devInfo then return end + if node.name == "firealarm:remotestrobe_off" and devInfo.strobeActive then + node.name = "firealarm:remotestrobe_on" + minetest.set_node(pos,node) + elseif node.name == "firealarm:remotestrobe_on" and not devInfo.strobeActive then + node.name = "firealarm:remotestrobe_off" + minetest.set_node(pos,node) + end + end, +}) + +minetest.register_abm({ + label = "Update horn/light plate state", + nodenames = {"firealarm:hornstrobe_old_off","firealarm:hornstrobe_old_on"}, + interval = 3, + chance = 1, + action = function(pos,node) + local devInfo = firealarm.getDevInfo("notification",pos) + if not devInfo then return end + if node.name == "firealarm:hornstrobe_old_off" and devInfo.strobeActive then + node.name = "firealarm:hornstrobe_old_on" + minetest.set_node(pos,node) + elseif node.name == "firealarm:hornstrobe_old_on" and not devInfo.strobeActive then + node.name = "firealarm:hornstrobe_old_off" + minetest.set_node(pos,node) + end + if devInfo.hornActive then + minetest.sound_play("firealarm_horn_old",{pos=pos}) + end + end, +}) diff --git a/firealarm_hornstrobe/sounds/firealarm_horn_old.ogg b/firealarm_hornstrobe/sounds/firealarm_horn_old.ogg new file mode 100644 index 0000000..0c1dead Binary files /dev/null and b/firealarm_hornstrobe/sounds/firealarm_horn_old.ogg differ diff --git a/firealarm_hornstrobe/textures/firealarm_hornstrobe_old_front_off.png b/firealarm_hornstrobe/textures/firealarm_hornstrobe_old_front_off.png new file mode 100644 index 0000000..0dfb6ae Binary files /dev/null and b/firealarm_hornstrobe/textures/firealarm_hornstrobe_old_front_off.png differ diff --git a/firealarm_hornstrobe/textures/firealarm_hornstrobe_old_front_on.png b/firealarm_hornstrobe/textures/firealarm_hornstrobe_old_front_on.png new file mode 100644 index 0000000..234c527 Binary files /dev/null and b/firealarm_hornstrobe/textures/firealarm_hornstrobe_old_front_on.png differ diff --git a/firealarm_hornstrobe/textures/firealarm_hornstrobe_remotestrobe_front_off.png b/firealarm_hornstrobe/textures/firealarm_hornstrobe_remotestrobe_front_off.png new file mode 100644 index 0000000..6c18b97 Binary files /dev/null and b/firealarm_hornstrobe/textures/firealarm_hornstrobe_remotestrobe_front_off.png differ diff --git a/firealarm_panel/init.lua b/firealarm_panel/init.lua index 28955ab..7adc1ea 100644 --- a/firealarm_panel/init.lua +++ b/firealarm_panel/init.lua @@ -261,6 +261,7 @@ minetest.register_node(":firealarm:panel",{ firealarm.setDevInfo("panel",pos,{ associatedSignalingDevices = {}, associatedNotificationDevices = {}, + associatedAnnunciators = {}, removeMenuDevList = {}, alarm = {}, supervisory = {}, @@ -533,6 +534,7 @@ function firealarm.panelABM(pos) local node = minetest.get_node(pos) local devInfo = firealarm.getDevInfo("panel",pos) if not devInfo then return end + if not devInfo.associatedAnnunciators then devInfo.associatedAnnunciators = {} end local hornsActive = #devInfo.alarm > 0 and not devInfo.silenced local strobesActive = #devInfo.alarm > 0 for i in pairs(devInfo.associatedNotificationDevices) do @@ -560,6 +562,12 @@ function firealarm.panelABM(pos) end end end + for i,v in pairs(devInfo.associatedAnnunciators) do + local dev = firealarm.getDevInfo("annunciator",minetest.get_position_from_hash(i)) + if not dev then + trouble(pos,minetest.get_position_from_hash(i)) + end + end local currentName = node.name local newName = "firealarm:panel" if #devInfo.alarm > 0 then newName = newName.."_alarm" end -- cgit v1.2.3