summaryrefslogtreecommitdiff
path: root/devices.lua
diff options
context:
space:
mode:
Diffstat (limited to 'devices.lua')
-rw-r--r--devices.lua90
1 files changed, 78 insertions, 12 deletions
diff --git a/devices.lua b/devices.lua
index 3b7fc78..5203bf3 100644
--- a/devices.lua
+++ b/devices.lua
@@ -1,3 +1,4 @@
+local new_flow_logic_register = pipeworks.flowables.register
-- rotation handlers
@@ -129,7 +130,8 @@ for s in ipairs(states) do
dgroups = {snappy=3, pipe=1, not_in_creative_inventory=1}
end
- minetest.register_node("pipeworks:pump_"..states[s], {
+ local pumpname = "pipeworks:pump_"..states[s]
+ minetest.register_node(pumpname, {
description = "Pump/Intake Module",
drawtype = "mesh",
mesh = "pipeworks_pump.obj",
@@ -162,8 +164,15 @@ for s in ipairs(states) do
-- FIXME - does this preserve metadata? need to look at this
on_rotate = screwdriver.rotate_simple
})
-
- minetest.register_node("pipeworks:valve_"..states[s].."_empty", {
+ -- FIXME: currently a simple flow device, but needs directionality checking
+ new_flow_logic_register.simple(pumpname)
+ local pump_drive = 4
+ if states[s] ~= "off" then
+ new_flow_logic_register.intake_simple(pumpname, pump_drive)
+ end
+
+ local nodename_valve_empty = "pipeworks:valve_"..states[s].."_empty"
+ minetest.register_node(nodename_valve_empty, {
description = "Valve",
drawtype = "mesh",
mesh = "pipeworks_valve_"..states[s]..".obj",
@@ -201,9 +210,16 @@ for s in ipairs(states) do
end,
on_rotate = pipeworks.fix_after_rotation
})
+ -- only register flow logic for the "on" ABM.
+ -- this means that the off state automatically blocks flow by not participating in the balancing operation.
+ if states[s] ~= "off" then
+ -- FIXME: this still a simple device, directionality not honoured
+ new_flow_logic_register.simple(nodename_valve_empty)
+ end
end
-minetest.register_node("pipeworks:valve_on_loaded", {
+local nodename_valve_loaded = "pipeworks:valve_on_loaded"
+minetest.register_node(nodename_valve_loaded, {
description = "Valve",
drawtype = "mesh",
mesh = "pipeworks_valve_on.obj",
@@ -241,9 +257,16 @@ minetest.register_node("pipeworks:valve_on_loaded", {
end,
on_rotate = pipeworks.fix_after_rotation
})
+-- register this the same as the on-but-empty variant, so existing nodes of this type work also.
+-- note that as new_flow_logic code does not distinguish empty/full in node states,
+-- right-clicking a "loaded" valve (becoming an off valve) then turning it on again will yield a on-but-empty valve,
+-- but the flow logic will still function.
+-- thus under new_flow_logic this serves as a kind of migration.
+new_flow_logic_register.simple(nodename_valve_loaded)
-- grating
+-- FIXME: should this do anything useful in the new flow logic?
minetest.register_node("pipeworks:grating", {
description = "Decorative grating",
tiles = {
@@ -276,7 +299,8 @@ minetest.register_node("pipeworks:grating", {
-- outlet spigot
-minetest.register_node("pipeworks:spigot", {
+local nodename_spigot_empty = "pipeworks:spigot"
+minetest.register_node(nodename_spigot_empty, {
description = "Spigot outlet",
drawtype = "mesh",
mesh = "pipeworks_spigot.obj",
@@ -306,7 +330,8 @@ minetest.register_node("pipeworks:spigot", {
on_rotate = pipeworks.fix_after_rotation
})
-minetest.register_node("pipeworks:spigot_pouring", {
+local nodename_spigot_loaded = "pipeworks:spigot_pouring"
+minetest.register_node(nodename_spigot_loaded, {
description = "Spigot outlet",
drawtype = "mesh",
mesh = "pipeworks_spigot_pouring.obj",
@@ -348,6 +373,17 @@ minetest.register_node("pipeworks:spigot_pouring", {
drop = "pipeworks:spigot",
on_rotate = pipeworks.fix_after_rotation
})
+-- new flow logic does not currently distinguish between these two visual states.
+-- register both so existing flowing spigots continue to work (even if the visual doesn't match the spigot's behaviour).
+new_flow_logic_register.simple(nodename_spigot_empty)
+new_flow_logic_register.simple(nodename_spigot_loaded)
+local spigot_upper = 1.0
+local spigot_lower = 1.0
+local spigot_neighbours={{x=0, y=-1, z=0}}
+new_flow_logic_register.output_simple(nodename_spigot_empty, spigot_upper, spigot_lower, spigot_neighbours)
+new_flow_logic_register.output_simple(nodename_spigot_loaded, spigot_upper, spigot_lower, spigot_neighbours)
+
+
-- sealed pipe entry/exit (horizontal pipe passing through a metal
-- wall, for use in places where walls should look like they're airtight)
@@ -360,7 +396,8 @@ local panel_cbox = {
}
}
-minetest.register_node("pipeworks:entry_panel_empty", {
+local nodename_panel_empty = "pipeworks:entry_panel_empty"
+minetest.register_node(nodename_panel_empty, {
description = "Airtight Pipe entry/exit",
drawtype = "mesh",
mesh = "pipeworks_entry_panel.obj",
@@ -379,7 +416,8 @@ minetest.register_node("pipeworks:entry_panel_empty", {
on_rotate = pipeworks.fix_after_rotation
})
-minetest.register_node("pipeworks:entry_panel_loaded", {
+local nodename_panel_loaded = "pipeworks:entry_panel_loaded"
+minetest.register_node(nodename_panel_loaded, {
description = "Airtight Pipe entry/exit",
drawtype = "mesh",
mesh = "pipeworks_entry_panel.obj",
@@ -398,8 +436,15 @@ minetest.register_node("pipeworks:entry_panel_loaded", {
drop = "pipeworks:entry_panel_empty",
on_rotate = pipeworks.fix_after_rotation
})
+-- FIXME requires-directionality
+-- TODO: AFAIK the two panels have no visual difference, so are redundant under new flow logic - alias?
+new_flow_logic_register.simple(nodename_panel_empty)
+new_flow_logic_register.simple(nodename_panel_loaded)
+
-minetest.register_node("pipeworks:flow_sensor_empty", {
+
+local nodename_sensor_empty = "pipeworks:flow_sensor_empty"
+minetest.register_node(nodename_sensor_empty, {
description = "Flow Sensor",
drawtype = "mesh",
mesh = "pipeworks_flow_sensor.obj",
@@ -437,7 +482,8 @@ minetest.register_node("pipeworks:flow_sensor_empty", {
on_rotate = pipeworks.fix_after_rotation
})
-minetest.register_node("pipeworks:flow_sensor_loaded", {
+local nodename_sensor_loaded = "pipeworks:flow_sensor_loaded"
+minetest.register_node(nodename_sensor_loaded, {
description = "Flow sensor (on)",
drawtype = "mesh",
mesh = "pipeworks_flow_sensor.obj",
@@ -475,9 +521,18 @@ minetest.register_node("pipeworks:flow_sensor_loaded", {
mesecons = pipereceptor_on,
on_rotate = pipeworks.fix_after_rotation
})
+-- FIXME requires-directionality
+new_flow_logic_register.simple(nodename_sensor_empty)
+new_flow_logic_register.simple(nodename_sensor_loaded)
+-- activate flow sensor at roughly half the pressure pumps drive pipes
+local sensor_pressure_set = { { nodename_sensor_empty, 0.0 }, { nodename_sensor_loaded, 1.0 } }
+new_flow_logic_register.transition_simple_set(sensor_pressure_set, { mesecons=pipeworks.mesecons_rules })
+
+
-- tanks
+-- TODO flow-logic-stub: these don't currently do anything under the new flow logic.
for fill = 0, 10 do
local filldesc="empty"
local sgroups = {snappy=3, pipe=1, tankfill=fill+1}
@@ -548,7 +603,8 @@ end
-- fountainhead
-minetest.register_node("pipeworks:fountainhead", {
+local nodename_fountain_empty = "pipeworks:fountainhead"
+minetest.register_node(nodename_fountain_empty, {
description = "Fountainhead",
drawtype = "mesh",
mesh = "pipeworks_fountainhead.obj",
@@ -581,7 +637,8 @@ minetest.register_node("pipeworks:fountainhead", {
on_rotate = false
})
-minetest.register_node("pipeworks:fountainhead_pouring", {
+local nodename_fountain_loaded = "pipeworks:fountainhead_pouring"
+minetest.register_node(nodename_fountain_loaded, {
description = "Fountainhead",
drawtype = "mesh",
mesh = "pipeworks_fountainhead.obj",
@@ -615,6 +672,15 @@ minetest.register_node("pipeworks:fountainhead_pouring", {
drop = "pipeworks:fountainhead",
on_rotate = false
})
+new_flow_logic_register.simple(nodename_fountain_empty)
+new_flow_logic_register.simple(nodename_fountain_loaded)
+local fountain_upper = 1.0
+local fountain_lower = 1.0
+local fountain_neighbours={{x=0, y=1, z=0}}
+new_flow_logic_register.output_simple(nodename_fountain_empty, fountain_upper, fountain_lower, fountain_neighbours)
+new_flow_logic_register.output_simple(nodename_fountain_loaded, fountain_upper, fountain_lower, fountain_neighbours)
+
+
minetest.register_alias("pipeworks:valve_off_loaded", "pipeworks:valve_off_empty")
minetest.register_alias("pipeworks:entry_panel", "pipeworks:entry_panel_empty")