summaryrefslogtreecommitdiff
path: root/firealarm_panel
diff options
context:
space:
mode:
authorcheapie <no-email-for-you@example.com>2018-08-31 23:28:21 -0500
committercheapie <no-email-for-you@example.com>2018-08-31 23:28:21 -0500
commitb1419ed0906cfc912add7f53ac4dc67d64becef4 (patch)
treeee2c97ffddbc2645c1879e7dd2f6f449fb8a79df /firealarm_panel
parent6dc64c7050c410e0979e520bbbd6b60ba46fb485 (diff)
downloadfirealarm-b1419ed0906cfc912add7f53ac4dc67d64becef4.tar
firealarm-b1419ed0906cfc912add7f53ac4dc67d64becef4.tar.gz
firealarm-b1419ed0906cfc912add7f53ac4dc67d64becef4.tar.bz2
firealarm-b1419ed0906cfc912add7f53ac4dc67d64becef4.tar.xz
firealarm-b1419ed0906cfc912add7f53ac4dc67d64becef4.zip
Add annunciator and re-alarm
Diffstat (limited to 'firealarm_panel')
-rw-r--r--firealarm_panel/init.lua36
1 files changed, 34 insertions, 2 deletions
diff --git a/firealarm_panel/init.lua b/firealarm_panel/init.lua
index 7adc1ea..3071e31 100644
--- a/firealarm_panel/init.lua
+++ b/firealarm_panel/init.lua
@@ -66,6 +66,11 @@ local function setFormspec(pos)
table.insert(devInfo.removeMenuDevList,dev)
fs = fs..minetest.formspec_escape(v.name)..","
end
+ for k,v in pairs(devInfo.associatedAnnunciators) do
+ local dev = {type = "annunciator",hash = k}
+ table.insert(devInfo.removeMenuDevList,dev)
+ fs = fs..minetest.formspec_escape(v.name)..","
+ end
fs = string.sub(fs,1,-1).."]"
else
fs = fs.."label[0.5,5;No Devices Associated]"
@@ -90,6 +95,7 @@ local function alarm(pos,initiator)
end
table.insert(devInfo.alarm,{initiator = initiatorHash,name = name})
devInfo.acked = false
+ devInfo.silenced = false
firealarm.setDevInfo("panel",pos,devInfo)
setFormspec(pos)
end
@@ -125,6 +131,9 @@ local function trouble(pos,initiator)
if devInfo.associatedNotificationDevices[initiatorHash] then
name = devInfo.associatedNotificationDevices[initiatorHash].name
end
+ if devInfo.associatedAnnunciators[initiatorHash] then
+ name = devInfo.associatedAnnunciators[initiatorHash].name
+ end
table.insert(devInfo.trouble,{initiator = initiatorHash,name = name})
devInfo.acked = false
firealarm.setDevInfo("panel",pos,devInfo)
@@ -197,7 +206,22 @@ local function handleFields(pos,_,fields,sender)
devInfo.associatedNotificationDevices[minetest.hash_node_position(targetPos)] = devParams
end
else
- minetest.chat_send_player(name,"Not a valid fire alarm device")
+ targetInfo = firealarm.getDevInfo("annunciator",targetPos)
+ if targetInfo then
+ if (minetest.is_protected(pos,name) and not minetest.check_player_privs(name,"protection_bypass")) or targetInfo.associated then
+ minetest.chat_send_player(name,"Device is protected or already associated")
+ else
+ targetInfo.associated = minetest.hash_node_position(pos)
+ local devParams = {}
+ devParams.name = fields.name
+ if not devInfo.associatedAnnunciators then
+ devInfo.associatedAnnunciators = {}
+ end
+ devInfo.associatedAnnunciators[minetest.hash_node_position(targetPos)] = devParams
+ end
+ else
+ minetest.chat_send_player(name,"Not a valid fire alarm device")
+ end
end
end
else
@@ -229,6 +253,14 @@ local function handleFields(pos,_,fields,sender)
targetInfo.strobeActive = false
firealarm.setDevInfo("notification",targetPos,targetInfo)
end
+ elseif dev.type == "annunciator" then
+ devInfo.associatedAnnunciators[dev.hash] = nil
+ local targetPos = minetest.get_position_from_hash(dev.hash)
+ local targetInfo = firealarm.getDevInfo("annunciator",targetPos)
+ if targetInfo then
+ targetInfo.associated = nil
+ firealarm.setDevInfo("annunciator",targetPos,targetInfo)
+ end
end
end
end
@@ -579,8 +611,8 @@ function firealarm.panelABM(pos)
if currentName ~= newName then
node.name = newName
minetest.set_node(pos,node)
- setFormspec(pos)
end
+ setFormspec(pos)
end
minetest.register_abm({