forked from mtcontrib/pipeworks
add flow sensor. Sends mesecons signal when water is flowing through it.
This commit is contained in:
parent
509fac3845
commit
d4dddc41ec
@ -143,6 +143,28 @@ function pipes_scansurroundings(pos)
|
|||||||
pzp=1
|
pzp=1
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- ...flow sensors...
|
||||||
|
|
||||||
|
if (string.find(nxm.name, "pipeworks:flow_sensor") ~= nil)
|
||||||
|
and (nxm.param2 == 0 or nxm.param2 == 2) then
|
||||||
|
pxm=1
|
||||||
|
end
|
||||||
|
|
||||||
|
if (string.find(nxp.name, "pipeworks:flow_sensor") ~= nil)
|
||||||
|
and (nxp.param2 == 0 or nxp.param2 == 2) then
|
||||||
|
pxp=1
|
||||||
|
end
|
||||||
|
|
||||||
|
if (string.find(nzm.name, "pipeworks:flow_sensor") ~= nil)
|
||||||
|
and (nzm.param2 == 1 or nzm.param2 == 3) then
|
||||||
|
pzm=1
|
||||||
|
end
|
||||||
|
|
||||||
|
if (string.find(nzp.name, "pipeworks:flow_sensor") ~= nil)
|
||||||
|
and (nzp.param2 == 1 or nzp.param2 == 3) then
|
||||||
|
pzp=1
|
||||||
|
end
|
||||||
|
|
||||||
-- ...spigots...
|
-- ...spigots...
|
||||||
|
|
||||||
if (string.find(nxm.name, "pipeworks:spigot") ~= nil)
|
if (string.find(nxm.name, "pipeworks:spigot") ~= nil)
|
||||||
|
@ -64,6 +64,13 @@ minetest.register_craft( {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
minetest.register_craft( {
|
||||||
|
output = "pipeworks:flow_sensor_empty 2",
|
||||||
|
recipe = {
|
||||||
|
{ "pipeworks:pipe_110000_empty", "mesecons:mesecon", "pipeworks:pipe_110000_empty" },
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
-- Various ancillary tube devices
|
-- Various ancillary tube devices
|
||||||
|
|
||||||
@ -164,7 +171,6 @@ if minetest.get_modpath("homedecor") == nil then
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
-- If the technic mod is present, then don't bother registering the recipes
|
-- If the technic mod is present, then don't bother registering the recipes
|
||||||
-- for the various tubes, as technic has its own recipes for those.
|
-- for the various tubes, as technic has its own recipes for those.
|
||||||
|
|
||||||
|
110
devices.lua
110
devices.lua
@ -1,5 +1,19 @@
|
|||||||
-- List of devices that should participate in the autoplace algorithm
|
-- 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 = {
|
pipes_devicelist = {
|
||||||
"pump",
|
"pump",
|
||||||
"valve",
|
"valve",
|
||||||
@ -35,6 +49,10 @@ pipe_valvehandle_off = {
|
|||||||
{ -1/16, 4/16, -5/16, 1/16, 5/16, 0 }
|
{ -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 = {
|
spigot_bottomstub = {
|
||||||
{ -2/64, -16/64, -6/64, 2/64, 1/64, 6/64 }, -- pipe segment against -Y face
|
{ -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 },
|
{ -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"
|
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
|
-- tanks
|
||||||
|
|
||||||
for fill = 0, 10 do
|
for fill = 0, 10 do
|
||||||
|
@ -104,11 +104,13 @@ table.insert(pipes_empty_nodenames,"pipeworks:valve_on_empty")
|
|||||||
table.insert(pipes_empty_nodenames,"pipeworks:valve_off_empty")
|
table.insert(pipes_empty_nodenames,"pipeworks:valve_off_empty")
|
||||||
table.insert(pipes_empty_nodenames,"pipeworks:valve_on_loaded")
|
table.insert(pipes_empty_nodenames,"pipeworks:valve_on_loaded")
|
||||||
table.insert(pipes_empty_nodenames,"pipeworks:entry_panel_empty")
|
table.insert(pipes_empty_nodenames,"pipeworks:entry_panel_empty")
|
||||||
|
table.insert(pipes_empty_nodenames,"pipeworks:flow_sensor_empty")
|
||||||
|
|
||||||
table.insert(pipes_full_nodenames,"pipeworks:valve_on_empty")
|
table.insert(pipes_full_nodenames,"pipeworks:valve_on_empty")
|
||||||
table.insert(pipes_full_nodenames,"pipeworks:valve_off_empty")
|
table.insert(pipes_full_nodenames,"pipeworks:valve_off_empty")
|
||||||
table.insert(pipes_full_nodenames,"pipeworks:valve_on_loaded")
|
table.insert(pipes_full_nodenames,"pipeworks:valve_on_loaded")
|
||||||
table.insert(pipes_full_nodenames,"pipeworks:entry_panel_loaded")
|
table.insert(pipes_full_nodenames,"pipeworks:entry_panel_loaded")
|
||||||
|
table.insert(pipes_full_nodenames,"pipeworks:flow_sensor_loaded")
|
||||||
|
|
||||||
minetest.register_abm({
|
minetest.register_abm({
|
||||||
nodenames = pipes_empty_nodenames,
|
nodenames = pipes_empty_nodenames,
|
||||||
|
2
optdepends.txt
Normal file
2
optdepends.txt
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
mesecons
|
||||||
|
|
Loading…
Reference in New Issue
Block a user