From 869c82fb25ce9885b61e2128846902a932982b92 Mon Sep 17 00:00:00 2001 From: cheapie Date: Sun, 26 Aug 2018 14:31:22 -0500 Subject: Add more devices Mesecons I/O modules and smoke detectors --- firealarm_meseconsio/depends.txt | 2 + firealarm_meseconsio/init.lua | 175 +++++++++++++++++++++ .../textures/firealarm_meseconsio_input_off.png | Bin 0 -> 232 bytes .../textures/firealarm_meseconsio_input_on.png | Bin 0 -> 231 bytes .../textures/firealarm_meseconsio_output_off.png | Bin 0 -> 232 bytes .../textures/firealarm_meseconsio_output_on.png | Bin 0 -> 232 bytes .../textures/firealarm_meseconsio_sides.png | Bin 0 -> 146 bytes 7 files changed, 177 insertions(+) create mode 100644 firealarm_meseconsio/depends.txt create mode 100644 firealarm_meseconsio/init.lua create mode 100644 firealarm_meseconsio/textures/firealarm_meseconsio_input_off.png create mode 100644 firealarm_meseconsio/textures/firealarm_meseconsio_input_on.png create mode 100644 firealarm_meseconsio/textures/firealarm_meseconsio_output_off.png create mode 100644 firealarm_meseconsio/textures/firealarm_meseconsio_output_on.png create mode 100644 firealarm_meseconsio/textures/firealarm_meseconsio_sides.png (limited to 'firealarm_meseconsio') 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 Binary files /dev/null and b/firealarm_meseconsio/textures/firealarm_meseconsio_input_off.png 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 Binary files /dev/null and b/firealarm_meseconsio/textures/firealarm_meseconsio_input_on.png 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 Binary files /dev/null and b/firealarm_meseconsio/textures/firealarm_meseconsio_output_off.png 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 Binary files /dev/null and b/firealarm_meseconsio/textures/firealarm_meseconsio_output_on.png 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 Binary files /dev/null and b/firealarm_meseconsio/textures/firealarm_meseconsio_sides.png differ -- cgit v1.2.3