summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcheapie <no-email-for-you@example.com>2018-08-26 14:31:22 -0500
committercheapie <no-email-for-you@example.com>2018-08-26 14:31:22 -0500
commit869c82fb25ce9885b61e2128846902a932982b92 (patch)
tree28930bce9332624a74542649a96dd17699d4a13b
parentd69e2c7295543435983c89a1277cec1d17fc9182 (diff)
downloadfirealarm-869c82fb25ce9885b61e2128846902a932982b92.tar
firealarm-869c82fb25ce9885b61e2128846902a932982b92.tar.gz
firealarm-869c82fb25ce9885b61e2128846902a932982b92.tar.bz2
firealarm-869c82fb25ce9885b61e2128846902a932982b92.tar.xz
firealarm-869c82fb25ce9885b61e2128846902a932982b92.zip
Add more devices
Mesecons I/O modules and smoke detectors
-rw-r--r--firealarm_meseconsio/depends.txt2
-rw-r--r--firealarm_meseconsio/init.lua175
-rw-r--r--firealarm_meseconsio/textures/firealarm_meseconsio_input_off.pngbin0 -> 232 bytes
-rw-r--r--firealarm_meseconsio/textures/firealarm_meseconsio_input_on.pngbin0 -> 231 bytes
-rw-r--r--firealarm_meseconsio/textures/firealarm_meseconsio_output_off.pngbin0 -> 232 bytes
-rw-r--r--firealarm_meseconsio/textures/firealarm_meseconsio_output_on.pngbin0 -> 232 bytes
-rw-r--r--firealarm_meseconsio/textures/firealarm_meseconsio_sides.pngbin0 -> 146 bytes
-rw-r--r--firealarm_smokedetector/depends.txt1
-rw-r--r--firealarm_smokedetector/init.lua132
-rw-r--r--firealarm_smokedetector/textures/firealarm_smokedetector_bottom_off.pngbin0 -> 216 bytes
-rw-r--r--firealarm_smokedetector/textures/firealarm_smokedetector_bottom_on.pngbin0 -> 216 bytes
-rw-r--r--firealarm_smokedetector/textures/firealarm_smokedetector_sides.pngbin0 -> 146 bytes
12 files changed, 310 insertions, 0 deletions
diff --git a/firealarm_meseconsio/depends.txt b/firealarm_meseconsio/depends.txt
new file mode 100644
index 0000000..72bf846
--- /dev/null
+++ b/firealarm_meseconsio/depends.txt
@@ -0,0 +1,2 @@
+firealarm_common
+mesecons
diff --git a/firealarm_meseconsio/init.lua b/firealarm_meseconsio/init.lua
new file mode 100644
index 0000000..b14b350
--- /dev/null
+++ b/firealarm_meseconsio/init.lua
@@ -0,0 +1,175 @@
+minetest.register_node(":firealarm:mesecons_input_off",{
+ description = "Fire Alarm Mesecons Input Module",
+ groups = { oddly_breakable_by_hand = 1 },
+ tiles = {
+ "firealarm_meseconsio_input_off.png",
+ "firealarm_meseconsio_sides.png",
+ "firealarm_meseconsio_sides.png",
+ "firealarm_meseconsio_sides.png",
+ "firealarm_meseconsio_sides.png",
+ "firealarm_meseconsio_sides.png",
+ },
+ paramtype = "light",
+ paramtype2 = "facedir",
+ drawtype = "nodebox",
+ node_box = {
+ type = "fixed",
+ fixed = {
+ {-0.5,-0.5,-0.5,0.5,-0.4,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,
+ mesecons = {
+ effector = {
+ action_on = function(pos,node)
+ local devInfo = firealarm.getDevInfo("signaling",pos)
+ if devInfo then
+ devInfo.active = true
+ node.name = "firealarm:mesecons_input_on"
+ minetest.set_node(pos,node)
+ 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:mesecons_input_on",{
+ description = "Fire Alarm Mesecons Input Module (on state - you hacker you!)",
+ drop = "firealarm:mesecons_input_off",
+ groups = { oddly_breakable_by_hand = 1, not_in_creative_inventory = 1 },
+ tiles = {
+ "firealarm_meseconsio_input_on.png",
+ "firealarm_meseconsio_sides.png",
+ "firealarm_meseconsio_sides.png",
+ "firealarm_meseconsio_sides.png",
+ "firealarm_meseconsio_sides.png",
+ "firealarm_meseconsio_sides.png",
+ },
+ paramtype = "light",
+ paramtype2 = "facedir",
+ drawtype = "nodebox",
+ node_box = {
+ type = "fixed",
+ fixed = {
+ {-0.5,-0.5,-0.5,0.5,-0.4,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,
+ mesecons = {
+ effector = {
+ action_off = function(pos,node)
+ local devInfo = firealarm.getDevInfo("signaling",pos)
+ if devInfo then
+ devInfo.active = false
+ node.name = "firealarm:mesecons_input_off"
+ minetest.set_node(pos,node)
+ end
+ end,
+ },
+ },
+ after_dig_node = function(pos)
+ firealarm.setDevInfo("signaling",pos,nil)
+ end,
+})
+
+minetest.register_node(":firealarm:mesecons_output_off",{
+ description = "Fire Alarm Mesecons Output Module",
+ groups = { oddly_breakable_by_hand = 1 },
+ tiles = {
+ "firealarm_meseconsio_output_off.png",
+ "firealarm_meseconsio_sides.png",
+ "firealarm_meseconsio_sides.png",
+ "firealarm_meseconsio_sides.png",
+ "firealarm_meseconsio_sides.png",
+ "firealarm_meseconsio_sides.png",
+ },
+ paramtype = "light",
+ paramtype2 = "facedir",
+ drawtype = "nodebox",
+ node_box = {
+ type = "fixed",
+ fixed = {
+ {-0.5,-0.5,-0.5,0.5,-0.4,0.5},
+ },
+ },
+ mesecons = {
+ receptor = {
+ state = mesecon.state.off,
+ },
+ },
+ 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,
+})
+
+minetest.register_node(":firealarm:mesecons_output_on",{
+ drop = "firealarm:mesecons_output_off",
+ description = "Fire Alarm Mesecons Output Module (on state - you hacker you!)",
+ groups = { oddly_breakable_by_hand = 1,not_in_creative_inventory = 1 },
+ tiles = {
+ "firealarm_meseconsio_output_on.png",
+ "firealarm_meseconsio_sides.png",
+ "firealarm_meseconsio_sides.png",
+ "firealarm_meseconsio_sides.png",
+ "firealarm_meseconsio_sides.png",
+ "firealarm_meseconsio_sides.png",
+ },
+ paramtype = "light",
+ paramtype2 = "facedir",
+ drawtype = "nodebox",
+ node_box = {
+ type = "fixed",
+ fixed = {
+ {-0.5,-0.5,-0.5,0.5,-0.4,0.5},
+ },
+ },
+ mesecons = {
+ receptor = {
+ state = mesecon.state.on,
+ },
+ },
+})
+
+minetest.register_abm({
+ label = "Update mesecons output state",
+ nodenames = {"firealarm:mesecons_output_off","firealarm:mesecons_output_on"},
+ interval = 2,
+ chance = 1,
+ action = function(pos,node)
+ local devInfo = firealarm.getDevInfo("notification",pos)
+ if not devInfo then return end
+ if node.name == "firealarm:mesecons_output_off" and devInfo.strobeActive then
+ node.name = "firealarm:mesecons_output_on"
+ minetest.set_node(pos,node)
+ mesecon.receptor_on(pos)
+ elseif node.name == "firealarm:mesecons_output_on" and not devInfo.strobeActive then
+ node.name = "firealarm:mesecons_output_off"
+ minetest.set_node(pos,node)
+ mesecon.receptor_off(pos)
+ end
+ end,
+})
diff --git a/firealarm_meseconsio/textures/firealarm_meseconsio_input_off.png b/firealarm_meseconsio/textures/firealarm_meseconsio_input_off.png
new file mode 100644
index 0000000..10e89cc
--- /dev/null
+++ b/firealarm_meseconsio/textures/firealarm_meseconsio_input_off.png
Binary files differ
diff --git a/firealarm_meseconsio/textures/firealarm_meseconsio_input_on.png b/firealarm_meseconsio/textures/firealarm_meseconsio_input_on.png
new file mode 100644
index 0000000..dab9038
--- /dev/null
+++ b/firealarm_meseconsio/textures/firealarm_meseconsio_input_on.png
Binary files differ
diff --git a/firealarm_meseconsio/textures/firealarm_meseconsio_output_off.png b/firealarm_meseconsio/textures/firealarm_meseconsio_output_off.png
new file mode 100644
index 0000000..4677b80
--- /dev/null
+++ b/firealarm_meseconsio/textures/firealarm_meseconsio_output_off.png
Binary files differ
diff --git a/firealarm_meseconsio/textures/firealarm_meseconsio_output_on.png b/firealarm_meseconsio/textures/firealarm_meseconsio_output_on.png
new file mode 100644
index 0000000..e965f2f
--- /dev/null
+++ b/firealarm_meseconsio/textures/firealarm_meseconsio_output_on.png
Binary files differ
diff --git a/firealarm_meseconsio/textures/firealarm_meseconsio_sides.png b/firealarm_meseconsio/textures/firealarm_meseconsio_sides.png
new file mode 100644
index 0000000..4beaa00
--- /dev/null
+++ b/firealarm_meseconsio/textures/firealarm_meseconsio_sides.png
Binary files differ
diff --git a/firealarm_smokedetector/depends.txt b/firealarm_smokedetector/depends.txt
new file mode 100644
index 0000000..d4798ab
--- /dev/null
+++ b/firealarm_smokedetector/depends.txt
@@ -0,0 +1 @@
+firealarm_common
diff --git a/firealarm_smokedetector/init.lua b/firealarm_smokedetector/init.lua
new file mode 100644
index 0000000..3cd2d60
--- /dev/null
+++ b/firealarm_smokedetector/init.lua
@@ -0,0 +1,132 @@
+local smokeDetectorOffBottomTexture = "[combine:32x320"..
+ ":0,0=firealarm_smokedetector_bottom_on.png"..
+ ":0,32=firealarm_smokedetector_bottom_off.png"..
+ ":0,64=firealarm_smokedetector_bottom_off.png"..
+ ":0,96=firealarm_smokedetector_bottom_off.png"..
+ ":0,128=firealarm_smokedetector_bottom_off.png"..
+ ":0,160=firealarm_smokedetector_bottom_off.png"..
+ ":0,192=firealarm_smokedetector_bottom_off.png"..
+ ":0,224=firealarm_smokedetector_bottom_off.png"..
+ ":0,256=firealarm_smokedetector_bottom_off.png"..
+ ":0,288=firealarm_smokedetector_bottom_off.png"
+
+minetest.register_node(":firealarm:smokedetector_off",{
+ description = "Fire Alarm Smoke Detector",
+ groups = { oddly_breakable_by_hand = 1 },
+ tiles = {
+ "firealarm_smokedetector_sides.png",
+ {
+ name = smokeDetectorOffBottomTexture,
+ animation =
+ {
+ type = "vertical_frames",
+ aspect_w = 32,
+ aspect_h = 32,
+ length = 5,
+ },
+ },
+ "firealarm_smokedetector_sides.png",
+ "firealarm_smokedetector_sides.png",
+ "firealarm_smokedetector_sides.png",
+ "firealarm_smokedetector_sides.png",
+ },
+ paramtype = "light",
+ paramtype2 = "facedir",
+ drawtype = "nodebox",
+ node_box = {
+ type = "fixed",
+ fixed = {
+ {-0.2,0.4,-0.2,0.2,0.5,0.2},
+ {-0.075,0.35,-0.075,0.075,0.4,0.075},
+ },
+ },
+ on_punch = function(pos,node,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("signaling",pos,{active = false,manualReset = false})
+ minetest.get_meta(pos):set_int("agressive",1)
+ end,
+ after_dig_node = function(pos)
+ firealarm.setDevInfo("signaling",pos,nil)
+ end,
+})
+
+minetest.register_node(":firealarm:smokedetector_on",{
+ drop = "firealarm:smokedetector_off",
+ description = "Fire Alarm Smoke Detector (on state - you hacker you!)",
+ groups = { oddly_breakable_by_hand = 1,not_in_creative_inventory = 1 },
+ tiles = {
+ "firealarm_smokedetector_sides.png",
+ "firealarm_smokedetector_bottom_on.png",
+ "firealarm_smokedetector_sides.png",
+ "firealarm_smokedetector_sides.png",
+ "firealarm_smokedetector_sides.png",
+ "firealarm_smokedetector_sides.png",
+ },
+ paramtype = "light",
+ paramtype2 = "facedir",
+ drawtype = "nodebox",
+ node_box = {
+ type = "fixed",
+ fixed = {
+ {-0.2,0.4,-0.2,0.2,0.5,0.2},
+ {-0.075,0.35,-0.075,0.075,0.4,0.075},
+ },
+ },
+ 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_dig_node = function(pos)
+ firealarm.setDevInfo("signaling",pos,nil)
+ end,
+})
+
+minetest.register_abm({
+ label = "Check for fire",
+ nodenames = {"firealarm:smokedetector_off"},
+ interval = 5,
+ chance = 1,
+ action = function(pos,node)
+ local devInfo = firealarm.getDevInfo("signaling",pos)
+ if not devInfo then return end
+ local minp = vector.add(pos,vector.new(-10,-10,-10))
+ local maxp = vector.add(pos,vector.new(10,0,10))
+ local fire = false
+ local fire_nodes = {["fire:permanent_flame"] = true,["fire:basic_flame"] = true}
+ for x=minp.x,maxp.x,1 do
+ for y=minp.y,maxp.y,1 do
+ for z=minp.z,maxp.z,1 do
+ if fire_nodes[minetest.get_node({x=x,y=y,z=z}).name] then fire = true end
+ end
+ end
+ end
+ if fire or minetest.get_meta(pos):get_int("agressive") == 0 then
+ devInfo.active = true
+ firealarm.setDevInfo("signaling",pos,devInfo)
+ node.name = "firealarm:smokedetector_on"
+ minetest.set_node(pos,node)
+ 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,
+})
+
+minetest.register_abm({
+ label = "Reset LED",
+ nodenames = {"firealarm:smokedetector_on"},
+ interval = 1,
+ chance = 1,
+ action = function(pos,node)
+ local devInfo = firealarm.getDevInfo("signaling",pos)
+ if (not devInfo) or devInfo.active then return end
+ node.name = "firealarm:smokedetector_off"
+ minetest.set_node(pos,node)
+ minetest.get_meta(pos):set_int("agressive",1)
+ end,
+})
diff --git a/firealarm_smokedetector/textures/firealarm_smokedetector_bottom_off.png b/firealarm_smokedetector/textures/firealarm_smokedetector_bottom_off.png
new file mode 100644
index 0000000..3885b58
--- /dev/null
+++ b/firealarm_smokedetector/textures/firealarm_smokedetector_bottom_off.png
Binary files differ
diff --git a/firealarm_smokedetector/textures/firealarm_smokedetector_bottom_on.png b/firealarm_smokedetector/textures/firealarm_smokedetector_bottom_on.png
new file mode 100644
index 0000000..2449290
--- /dev/null
+++ b/firealarm_smokedetector/textures/firealarm_smokedetector_bottom_on.png
Binary files differ
diff --git a/firealarm_smokedetector/textures/firealarm_smokedetector_sides.png b/firealarm_smokedetector/textures/firealarm_smokedetector_sides.png
new file mode 100644
index 0000000..6873873
--- /dev/null
+++ b/firealarm_smokedetector/textures/firealarm_smokedetector_sides.png
Binary files differ