1
0
mirror of https://github.com/mt-mods/pipeworks.git synced 2024-12-28 03:40:25 +01:00

new flow logic: algorithmic and value tuning for non-finite mode

This commit is contained in:
thetaepsilon-gamedev 2017-10-08 11:32:08 +01:00
parent f94c93bb59
commit 6a25e56336
2 changed files with 8 additions and 5 deletions

View File

@ -377,7 +377,7 @@ 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_upper = 1.5 local spigot_upper = 1.0
local spigot_lower = 1.0 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_upper, spigot_lower, spigot_neighbours) new_flow_logic_register.output_simple(nodename_spigot_empty, spigot_upper, spigot_lower, spigot_neighbours)
@ -671,7 +671,7 @@ 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_upper = 1.5 local fountain_upper = 1.0
local fountain_lower = 1.0 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_upper, fountain_lower, fountain_neighbours) new_flow_logic_register.output_simple(nodename_fountain_empty, fountain_upper, fountain_lower, fountain_neighbours)

View File

@ -202,12 +202,13 @@ end
-- removes water sources from neighbor positions when the output is "off" due to lack of pressure. -- removes water sources from neighbor positions when the output is "off" due to lack of pressure.
flowlogic.helpers.make_neighbour_cleanup_fixed = function(neighbours) flowlogic.helpers.make_neighbour_cleanup_fixed = function(neighbours)
return function(pos, node, currentpressure) return function(pos, node, currentpressure)
-- FIXME - this would indiscriminately take blocks while under-pressure, not just one time? --pipeworks.logger("neighbour_cleanup_fixed@"..formatvec(pos))
for _, offset in pairs(neighbours) do for _, offset in pairs(neighbours) do
local npos = vector.add(pos, offset) local npos = vector.add(pos, offset)
local name = minetest.get_node(npos).name local name = minetest.get_node(npos).name
if (name == "default:water_source") then if (name == "default:water_source") then
minetest.remove_node(pos) --pipeworks.logger("neighbour_cleanup_fixed removing "..formatvec(npos))
minetest.remove_node(npos)
end end
end end
end end
@ -221,6 +222,7 @@ flowlogic.run_output = function(pos, node, currentpressure, oldpressure, outputd
-- the outputfn is provided the current pressure and returns the pressure "taken". -- the outputfn is provided the current pressure and returns the pressure "taken".
-- as an example, using this with the above spigot function, -- as an example, using this with the above spigot function,
-- the spigot function tries to output a water source if it will fit in the world. -- the spigot function tries to output a water source if it will fit in the world.
--pipeworks.logger("flowlogic.run_output() pos "..formatvec(pos).." old -> currentpressure "..tostring(oldpressure).." "..tostring(currentpressure).." finitemode "..tostring(finitemode))
local upper = outputdef.upper local upper = outputdef.upper
local lower = outputdef.lower local lower = outputdef.lower
local result = currentpressure local result = currentpressure
@ -232,7 +234,8 @@ flowlogic.run_output = function(pos, node, currentpressure, oldpressure, outputd
if newpressure < 0 then newpressure = 0 end if newpressure < 0 then newpressure = 0 end
result = newpressure result = newpressure
end end
if (not finitemode) and (currentpressure < lower) and (oldpressure > lower) then if (not finitemode) and (currentpressure < lower) and (oldpressure < lower) then
--pipeworks.logger("flowlogic.run_output() invoking cleanup currentpressure="..tostring(currentpressure))
outputdef.cleanupfn(pos, node, currentpressure) outputdef.cleanupfn(pos, node, currentpressure)
end end
return result return result