summaryrefslogtreecommitdiff
path: root/devices.lua
diff options
context:
space:
mode:
authorVanessa Ezekowitz <vanessaezekowitz@gmail.com>2013-05-10 18:28:57 -0400
committerVanessa Ezekowitz <vanessaezekowitz@gmail.com>2013-05-10 18:28:57 -0400
commitd4dddc41ec199ffc73f1ad10f900b42c3164a46f (patch)
treee2d61bc3a91a9042499279ed09179c3f1cd2f67c /devices.lua
parent509fac3845cc06b5b1673d9516fd998265058298 (diff)
downloadpipeworks-d4dddc41ec199ffc73f1ad10f900b42c3164a46f.tar
pipeworks-d4dddc41ec199ffc73f1ad10f900b42c3164a46f.tar.gz
pipeworks-d4dddc41ec199ffc73f1ad10f900b42c3164a46f.tar.bz2
pipeworks-d4dddc41ec199ffc73f1ad10f900b42c3164a46f.tar.xz
pipeworks-d4dddc41ec199ffc73f1ad10f900b42c3164a46f.zip
add flow sensor. Sends mesecons signal when water is flowing through it.
Diffstat (limited to 'devices.lua')
-rw-r--r--devices.lua110
1 files changed, 110 insertions, 0 deletions
diff --git a/devices.lua b/devices.lua
index dcd5967..3cbf71a 100644
--- a/devices.lua
+++ b/devices.lua
@@ -1,5 +1,19 @@
-- List of devices that should participate in the autoplace algorithm
+if mesecon then
+ pipereceptor_on = {
+ receptor = {
+ state = mesecon.state.on
+ }
+ }
+
+ pipereceptor_off = {
+ receptor = {
+ state = mesecon.state.off
+ }
+ }
+end
+
pipes_devicelist = {
"pump",
"valve",
@@ -35,6 +49,10 @@ pipe_valvehandle_off = {
{ -1/16, 4/16, -5/16, 1/16, 5/16, 0 }
}
+pipe_sensorbody = {
+ { -3/16, -2/16, -2/16, 3/16, 2/16, 2/16 }
+}
+
spigot_bottomstub = {
{ -2/64, -16/64, -6/64, 2/64, 1/64, 6/64 }, -- pipe segment against -Y face
{ -4/64, -16/64, -5/64, 4/64, 1/64, 5/64 },
@@ -439,6 +457,98 @@ minetest.register_node("pipeworks:entry_panel_loaded", {
drop = "pipeworks:entry_panel_empty"
})
+local sensorboxes = {}
+pipe_addbox(sensorboxes, pipe_leftstub)
+pipe_addbox(sensorboxes, pipe_sensorbody)
+pipe_addbox(sensorboxes, pipe_rightstub)
+
+minetest.register_node("pipeworks:flow_sensor_empty", {
+ description = "Flow Sensor",
+ drawtype = "nodebox",
+ tiles = {
+ "pipeworks_plain.png",
+ "pipeworks_plain.png",
+ "pipeworks_plain.png",
+ "pipeworks_plain.png",
+ "pipeworks_windowed_empty.png",
+ "pipeworks_windowed_empty.png"
+ },
+ paramtype = "light",
+ paramtype2 = "facedir",
+ groups = {snappy=3, pipe=1},
+ sounds = default.node_sound_wood_defaults(),
+ walkable = true,
+ after_place_node = function(pos)
+ pipe_scanforobjects(pos)
+ end,
+ after_dig_node = function(pos)
+ pipe_scanforobjects(pos)
+ end,
+ pipelike=1,
+ on_construct = function(pos)
+ local meta = minetest.env:get_meta(pos)
+ meta:set_int("pipelike",1)
+ if mesecon then
+ mesecon:receptor_off(pos, rules)
+ end
+ end,
+ node_box = {
+ type = "fixed",
+ fixed = sensorboxes,
+ },
+ selection_box = {
+ type = "fixed",
+ fixed = {
+ { -8/16, -2/16, -2/16, 8/16, 2/16, 2/16 },
+ }
+ },
+ mesecons = pipereceptor_off
+})
+
+minetest.register_node("pipeworks:flow_sensor_loaded", {
+ description = "Flow sensor (on)",
+ drawtype = "nodebox",
+ tiles = {
+ "pipeworks_plain.png",
+ "pipeworks_plain.png",
+ "pipeworks_plain.png",
+ "pipeworks_plain.png",
+ pipeworks_liquid_texture.."^pipeworks_windowed_loaded.png",
+ pipeworks_liquid_texture.."^pipeworks_windowed_loaded.png"
+ },
+ paramtype = "light",
+ paramtype2 = "facedir",
+ groups = {snappy=3, pipe=1, not_in_creative_inventory=1},
+ sounds = default.node_sound_wood_defaults(),
+ walkable = true,
+ after_place_node = function(pos)
+ pipe_scanforobjects(pos)
+ end,
+ after_dig_node = function(pos)
+ pipe_scanforobjects(pos)
+ end,
+ pipelike=1,
+ on_construct = function(pos)
+ local meta = minetest.env:get_meta(pos)
+ meta:set_int("pipelike",1)
+ if mesecon then
+ mesecon:receptor_on(pos, rules)
+ end
+ end,
+ node_box = {
+ type = "fixed",
+ fixed = sensorboxes,
+ },
+ selection_box = {
+ type = "fixed",
+ fixed = {
+ { -8/16, -2/16, -2/16, 8/16, 2/16, 2/16 },
+ }
+ },
+ drop = "pipeworks:flow_sensor_empty",
+ mesecons = pipereceptor_on
+})
+
-- tanks
for fill = 0, 10 do