summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--autoplace.lua22
-rw-r--r--crafts.lua8
-rw-r--r--devices.lua267
-rw-r--r--flowing_logic.lua42
-rw-r--r--optdepends.txt2
5 files changed, 314 insertions, 27 deletions
diff --git a/autoplace.lua b/autoplace.lua
index dbcc423..ddfdb76 100644
--- a/autoplace.lua
+++ b/autoplace.lua
@@ -143,6 +143,28 @@ function pipes_scansurroundings(pos)
pzp=1
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...
if (string.find(nxm.name, "pipeworks:spigot") ~= nil)
diff --git a/crafts.lua b/crafts.lua
index 700543b..25c57b6 100644
--- a/crafts.lua
+++ b/crafts.lua
@@ -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
@@ -164,7 +171,6 @@ if minetest.get_modpath("homedecor") == nil then
end
-
-- 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.
diff --git a/devices.lua b/devices.lua
index 4c8072c..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 },
@@ -109,7 +127,15 @@ for s in ipairs(states) do
after_dig_node = function(pos)
pipe_scanforobjects(pos)
end,
- drop = "pipeworks:pump_off"
+ drop = "pipeworks:pump_off",
+ mesecons = {effector = {
+ action_on = function (pos, node)
+ minetest.env:add_node(pos,{name="pipeworks:pump_on", param2 = node.param2})
+ end,
+ action_off = function (pos, node)
+ minetest.env:add_node(pos,{name="pipeworks:pump_off", param2 = node.param2})
+ end
+ }}
})
local valveboxes = {}
@@ -124,7 +150,7 @@ for s in ipairs(states) do
local tilex = "pipeworks_valvebody_ends.png"
local tilez = "pipeworks_valvebody_sides.png"
- minetest.register_node("pipeworks:valve_"..states[s], {
+ minetest.register_node("pipeworks:valve_"..states[s].."_empty", {
description = "Valve",
drawtype = "nodebox",
tiles = {
@@ -161,9 +187,70 @@ for s in ipairs(states) do
end,
drop = "pipeworks:valve_off",
pipelike=1,
+ mesecons = {effector = {
+ action_on = function (pos, node)
+ minetest.env:add_node(pos,{name="pipeworks:valve_on_empty", param2 = node.param2})
+ end,
+ action_off = function (pos, node)
+ minetest.env:add_node(pos,{name="pipeworks:valve_off_empty", param2 = node.param2})
+ end
+ }}
})
end
+local valveboxes = {}
+pipe_addbox(valveboxes, pipe_leftstub)
+pipe_addbox(valveboxes, pipe_valvebody)
+pipe_addbox(valveboxes, pipe_rightstub)
+pipe_addbox(valveboxes, pipe_valvehandle_on)
+
+minetest.register_node("pipeworks:valve_on_loaded", {
+ description = "Valve",
+ drawtype = "nodebox",
+ tiles = {
+ "pipeworks_valvebody_top_on.png",
+ "pipeworks_valvebody_bottom.png",
+ "pipeworks_valvebody_ends.png",
+ "pipeworks_valvebody_ends.png",
+ "pipeworks_valvebody_sides.png",
+ "pipeworks_valvebody_sides.png",
+ },
+ paramtype = "light",
+ paramtype2 = "facedir",
+ selection_box = {
+ type = "fixed",
+ fixed = { -8/16, -4/16, -5/16, 8/16, 5/16, 5/16 }
+ },
+ node_box = {
+ type = "fixed",
+ fixed = valveboxes
+ },
+ groups = {snappy=3, pipe=1, not_in_creative_inventory=1},
+ sounds = default.node_sound_wood_defaults(),
+ walkable = true,
+ pipelike = 1,
+ on_construct = function(pos)
+ local meta = minetest.env:get_meta(pos)
+ meta:set_int("pipelike",1)
+ end,
+ after_place_node = function(pos)
+ pipe_scanforobjects(pos)
+ end,
+ after_dig_node = function(pos)
+ pipe_scanforobjects(pos)
+ end,
+ drop = "pipeworks:valve_off_empty",
+ pipelike=1,
+ mesecons = {effector = {
+ action_on = function (pos, node)
+ minetest.env:add_node(pos,{name="pipeworks:valve_on_empty", param2 = node.param2})
+ end,
+ action_off = function (pos, node)
+ minetest.env:add_node(pos,{name="pipeworks:valve_off_empty", param2 = node.param2})
+ end
+ }}
+})
+
-- grating
minetest.register_node("pipeworks:grating", {
@@ -256,7 +343,7 @@ minetest.register_node("pipeworks:spigot_pouring", {
},
paramtype = "light",
paramtype2 = "facedir",
- groups = {snappy=3, pipe=1},
+ groups = {snappy=3, pipe=1, not_in_creative_inventory=1},
sounds = default.node_sound_wood_defaults(),
walkable = true,
pipelike=1,
@@ -281,16 +368,15 @@ minetest.register_node("pipeworks:spigot_pouring", {
drop = "pipeworks:spigot",
})
-
--- sealed pipe entry/exit (decorative horizontal pipe passing through a metal
+-- sealed pipe entry/exit (horizontal pipe passing through a metal
-- wall, for use in places where walls should look like they're airtight)
- local airtightboxes = {}
- pipe_addbox(airtightboxes, pipe_frontstub)
- pipe_addbox(airtightboxes, pipe_backstub)
- pipe_addbox(airtightboxes, entry_panel)
+local airtightboxes = {}
+pipe_addbox(airtightboxes, pipe_frontstub)
+pipe_addbox(airtightboxes, pipe_backstub)
+pipe_addbox(airtightboxes, entry_panel)
-minetest.register_node("pipeworks:entry_panel", {
+minetest.register_node("pipeworks:entry_panel_empty", {
description = "Airtight Pipe entry/exit",
drawtype = "nodebox",
tiles = {
@@ -321,6 +407,146 @@ minetest.register_node("pipeworks:entry_panel", {
type = "fixed",
fixed = airtightboxes,
},
+ selection_box = {
+ type = "fixed",
+ fixed = {
+ { -2/16, -2/16, -8/16, 2/16, 2/16, 8/16 },
+ { -8/16, -8/16, -1/16, 8/16, 8/16, 1/16 }
+ }
+ }
+})
+
+minetest.register_node("pipeworks:entry_panel_loaded", {
+ description = "Airtight Pipe entry/exit",
+ drawtype = "nodebox",
+ tiles = {
+ "pipeworks_plain.png",
+ "pipeworks_plain.png",
+ "pipeworks_plain.png",
+ "pipeworks_plain.png",
+ "pipeworks_pipe_end_empty.png",
+ "pipeworks_pipe_end_empty.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)
+ end,
+ node_box = {
+ type = "fixed",
+ fixed = airtightboxes,
+ },
+ selection_box = {
+ type = "fixed",
+ fixed = {
+ { -2/16, -2/16, -8/16, 2/16, 2/16, 8/16 },
+ { -8/16, -8/16, -1/16, 8/16, 8/16, 1/16 }
+ }
+ },
+ 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
@@ -401,18 +627,27 @@ end
-- various actions
minetest.register_on_punchnode(function (pos, node)
- if node.name=="pipeworks:valve_on" then
+ if node.name=="pipeworks:valve_on_empty" then
+ fdir = minetest.env:get_node(pos).param2
+ minetest.env:add_node(pos, { name = "pipeworks:valve_off_empty", param2 = fdir })
+ local meta = minetest.env:get_meta(pos)
+ meta:set_int("pipelike",0)
+ end
+end)
+
+minetest.register_on_punchnode(function (pos, node)
+ if node.name=="pipeworks:valve_on_loaded" then
fdir = minetest.env:get_node(pos).param2
- minetest.env:add_node(pos, { name = "pipeworks:valve_off", param2 = fdir })
+ minetest.env:add_node(pos, { name = "pipeworks:valve_off_empty", param2 = fdir })
local meta = minetest.env:get_meta(pos)
meta:set_int("pipelike",0)
end
end)
minetest.register_on_punchnode(function (pos, node)
- if node.name=="pipeworks:valve_off" then
+ if node.name=="pipeworks:valve_off_empty" then
fdir = minetest.env:get_node(pos).param2
- minetest.env:add_node(pos, { name = "pipeworks:valve_on", param2 = fdir })
+ minetest.env:add_node(pos, { name = "pipeworks:valve_on_empty", param2 = fdir })
local meta = minetest.env:get_meta(pos)
meta:set_int("pipelike",1)
end
@@ -444,6 +679,10 @@ minetest.register_alias("pipeworks:valve_off_x", "pipeworks:valve_off")
minetest.register_alias("pipeworks:valve_off_z", "pipeworks:valve_off")
minetest.register_alias("pipeworks:valve_on_x", "pipeworks:valve_on")
minetest.register_alias("pipeworks:valve_on_z", "pipeworks:valve_on")
+minetest.register_alias("pipeworks:valve_off", "pipeworks:valve_off_empty")
+minetest.register_alias("pipeworks:valve_on", "pipeworks:valve_on_empty")
+minetest.register_alias("pipeworks:valve_off_loaded", "pipeworks:valve_off_empty")
+minetest.register_alias("pipeworks:entry_panel", "pipeworks:entry_panel_empty")
minetest.register_alias("pipeworks:storage_tank_0_x", "pipeworks:storage_tank_0")
minetest.register_alias("pipeworks:storage_tank_0_z", "pipeworks:storage_tank_0")
minetest.register_alias("pipeworks:storage_tank_1_x", "pipeworks:storage_tank_1")
diff --git a/flowing_logic.lua b/flowing_logic.lua
index e943488..a375aeb 100644
--- a/flowing_logic.lua
+++ b/flowing_logic.lua
@@ -14,7 +14,10 @@ local check4liquids = function(pos)
{x=pos.x,y=pos.y,z=pos.z+1}, }
for i =1,6 do
local name = minetest.env:get_node(coords[i]).name
- if string.find(name,'water') then return true end
+ if string.find(name,'water') then
+ minetest.env:remove_node(coords[i])
+ return true
+ end
end
return false
end
@@ -44,13 +47,14 @@ local check4inflows = function(pos,node)
end
if newnode then
dbg(newnode..' to replace '..node.name)
- minetest.env:add_node(pos,{name=newnode})
+ minetest.env:add_node(pos,{name=newnode, param2 = node.param2})
minetest.env:get_meta(pos):set_string('source',minetest.pos_to_string(source))
end
end
local checksources = function(pos,node)
local sourcepos = minetest.string_to_pos(minetest.env:get_meta(pos):get_string('source'))
+ if not sourcepos then return end
local source = minetest.env:get_node(sourcepos).name
local newnode = false
if not ((source == 'pipeworks:pump_on' and check4liquids(sourcepos)) or string.find(source,'_loaded') or source == 'ignore' ) then
@@ -59,7 +63,7 @@ local checksources = function(pos,node)
if newnode then dbg(newnode..' to replace '..node.name) end
if newnode then
- minetest.env:add_node(pos,{name=newnode})
+ minetest.env:add_node(pos,{name=newnode, param2 = node.param2})
minetest.env:get_meta(pos):set_string('source','')
end
end
@@ -67,7 +71,8 @@ end
local update_outlet = function(pos)
local top = minetest.env:get_node({x=pos.x,y=pos.y+1,z=pos.z}).name
if string.find(top,'_loaded') then
- if minetest.env:get_node({x=pos.x,y=pos.y-1,z=pos.z}).name == 'air' then
+ local name = minetest.env:get_node({x=pos.x,y=pos.y-1,z=pos.z}).name
+ if name == 'air' or name == "default:water_source" or name == "default:water_flowing" then
minetest.env:add_node({x=pos.x,y=pos.y-1,z=pos.z},{name='default:water_source'})
end
elseif minetest.env:get_node({x=pos.x,y=pos.y-1,z=pos.z}).name == 'default:water_source' then
@@ -81,19 +86,32 @@ local spigot_check = function(pos,node)
dbg(fdir..' checking '..minetest.pos_to_string(check[fdir+1])..' for spigot at '..minetest.pos_to_string(pos))
local top = minetest.env:get_node(check[fdir+1]).name
dbg('found '..top)
- if string.find(top,'_loaded') then
- minetest.env:add_node({x=pos.x,y=pos.y,z=pos.z},{name='pipeworks:spigot_pouring', param2 = fdir})
- if minetest.env:get_node({x=pos.x,y=pos.y-1,z=pos.z}).name == 'air' then
- minetest.env:add_node({x=pos.x,y=pos.y-1,z=pos.z},{name='default:water_source'})
- end
+ local name = minetest.env:get_node({x=pos.x,y=pos.y-1,z=pos.z}).name
+ if string.find(top,'_loaded') and (name == 'air' or name == "default:water_source" or name == "default:water_flowing") then
+ minetest.env:add_node({x=pos.x,y=pos.y-1,z=pos.z},{name='default:water_source'})
+ minetest.env:add_node(pos,{name='pipeworks:spigot_pouring', param2 = fdir})
else
- minetest.env:add_node({x=pos.x,y=pos.y,z=pos.z},{name='pipeworks:spigot', param2 = fdir})
- if minetest.env:get_node({x=pos.x,y=pos.y-1,z=pos.z}).name == 'default:water_source' then
- minetest.env:remove_node({x=pos.x,y=pos.y-1,z=pos.z})
+ if minetest.env:get_node(pos).name == 'pipeworks:spigot_pouring' then
+ minetest.env:add_node({x=pos.x,y=pos.y,z=pos.z},{name='pipeworks:spigot', param2 = fdir})
+ if name == 'air' or name == "default:water_source" or name == "default:water_flowing" then
+ minetest.env:remove_node({x=pos.x,y=pos.y-1,z=pos.z})
+ end
end
end
end
+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_on_loaded")
+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_off_empty")
+table.insert(pipes_full_nodenames,"pipeworks:valve_on_loaded")
+table.insert(pipes_full_nodenames,"pipeworks:entry_panel_loaded")
+table.insert(pipes_full_nodenames,"pipeworks:flow_sensor_loaded")
+
minetest.register_abm({
nodenames = pipes_empty_nodenames,
interval = 1,
diff --git a/optdepends.txt b/optdepends.txt
new file mode 100644
index 0000000..d92a438
--- /dev/null
+++ b/optdepends.txt
@@ -0,0 +1,2 @@
+mesecons
+