mirror of
https://github.com/mt-mods/pipeworks.git
synced 2024-12-27 19:30:26 +01:00
new flow logic: flowable_node_registry_install.lua: separate pressure threshold into upper and lower hysteresis values
This commit is contained in:
parent
465e28cbd3
commit
4f58a3039c
14
devices.lua
14
devices.lua
@ -376,10 +376,11 @@ minetest.register_node(nodename_spigot_loaded, {
|
|||||||
-- register both so existing flowing spigots continue to work (even if the visual doesn't match the spigot's behaviour).
|
-- 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_empty)
|
||||||
new_flow_logic_register.simple(nodename_spigot_loaded)
|
new_flow_logic_register.simple(nodename_spigot_loaded)
|
||||||
local spigot_min = 1
|
local spigot_upper = 1.5
|
||||||
|
local spigot_lower = 1.0
|
||||||
local spigot_neighbours={{x=0, y=-1, z=0}}
|
local spigot_neighbours={{x=0, y=-1, z=0}}
|
||||||
new_flow_logic_register.output_simple(nodename_spigot_empty, spigot_min, spigot_neighbours)
|
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_min, spigot_neighbours)
|
new_flow_logic_register.output_simple(nodename_spigot_loaded, spigot_upper, spigot_lower, spigot_neighbours)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -669,10 +670,11 @@ minetest.register_node(nodename_fountain_loaded, {
|
|||||||
})
|
})
|
||||||
new_flow_logic_register.simple(nodename_fountain_empty)
|
new_flow_logic_register.simple(nodename_fountain_empty)
|
||||||
new_flow_logic_register.simple(nodename_fountain_loaded)
|
new_flow_logic_register.simple(nodename_fountain_loaded)
|
||||||
local fountain_min = 1
|
local fountain_upper = 1.5
|
||||||
|
local fountain_lower = 1.0
|
||||||
local fountain_neighbours={{x=0, y=1, z=0}}
|
local fountain_neighbours={{x=0, y=1, z=0}}
|
||||||
new_flow_logic_register.output_simple(nodename_fountain_empty, fountain_min, fountain_neighbours)
|
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_min, fountain_neighbours)
|
new_flow_logic_register.output_simple(nodename_fountain_loaded, fountain_upper, fountain_lower, fountain_neighbours)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -62,12 +62,19 @@ end
|
|||||||
|
|
||||||
-- Register a node as an output.
|
-- Register a node as an output.
|
||||||
-- Expects node to already be a flowable.
|
-- Expects node to already be a flowable.
|
||||||
-- threshold and outputfn are currently as documented for register_abm_output() in abm_register.lua.
|
-- upper and lower thresholds have different meanings depending on whether finite liquid mode is in effect.
|
||||||
register.output = function(nodename, threshold, outputfn)
|
-- if not (the default unless auto-detected),
|
||||||
|
-- nodes above their upper threshold have their outputfn invoked (and pressure deducted),
|
||||||
|
-- nodes between upper and lower are left idle,
|
||||||
|
-- and nodes below lower have their cleanup fn invoked (to say remove water sources).
|
||||||
|
-- the upper and lower difference acts as a hysteresis to try and avoid "gaps" in the flow.
|
||||||
|
-- if finite mode is on, upper is ignored and lower is used to determine whether to run outputfn;
|
||||||
|
-- cleanupfn is ignored in this mode as finite mode assumes something causes water to move itself.
|
||||||
|
register.output = function(nodename, upper, lower, outputfn)
|
||||||
checkbase(nodename)
|
checkbase(nodename)
|
||||||
pipeworks.flowables.outputs.list[nodename] = { threshold=threshold, outputfn=outputfn }
|
pipeworks.flowables.outputs.list[nodename] = { threshold=threshold, outputfn=outputfn }
|
||||||
if pipeworks.toggles.pressure_logic then
|
if pipeworks.toggles.pressure_logic then
|
||||||
abmregister.output(nodename, threshold, outputfn)
|
abmregister.output(nodename, lower, outputfn)
|
||||||
end
|
end
|
||||||
regwarning("output node", nodename)
|
regwarning("output node", nodename)
|
||||||
end
|
end
|
||||||
@ -77,7 +84,8 @@ end
|
|||||||
-- which tries to place water nodes around it.
|
-- which tries to place water nodes around it.
|
||||||
-- possibly this could be given a helper function to determine which faces a node should try,
|
-- possibly this could be given a helper function to determine which faces a node should try,
|
||||||
-- to allow things like rotation or other param values determining "direction" to be respected.
|
-- to allow things like rotation or other param values determining "direction" to be respected.
|
||||||
register.output_simple = function(nodename, threshold, neighbours)
|
-- for meanings of upper and lower, see register.output() above.
|
||||||
|
register.output_simple = function(nodename, upper, lower, neighbours)
|
||||||
local outputfn = pipeworks.flowlogic.helpers.make_neighbour_output_fixed(neighbours)
|
local outputfn = pipeworks.flowlogic.helpers.make_neighbour_output_fixed(neighbours)
|
||||||
register.output(nodename, threshold, outputfn)
|
register.output(nodename, upper, lower, outputfn)
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user