mirror of
https://github.com/mt-mods/pipeworks.git
synced 2024-12-29 17:17:29 +01:00
flowing_logic.lua: add start of new pump handler code
This commit is contained in:
parent
6a0fe9f3c0
commit
c5e5aa069f
@ -135,6 +135,14 @@ end
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
-- global values and thresholds for water behaviour
|
||||||
|
-- TODO: add some way of setting this per-world
|
||||||
|
local thresholds = {}
|
||||||
|
-- limit on pump pressure - will not absorb more than can be taken
|
||||||
|
thresholds.pump_pressure = 2
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
-- borrowed from above: might be useable to replace the above coords tables
|
-- borrowed from above: might be useable to replace the above coords tables
|
||||||
local make_coords_offsets = function(pos, include_base)
|
local make_coords_offsets = function(pos, include_base)
|
||||||
local coords = {
|
local coords = {
|
||||||
@ -155,6 +163,7 @@ end
|
|||||||
-- accepts a limit parameter to only delete water blocks that the receptacle can accept,
|
-- accepts a limit parameter to only delete water blocks that the receptacle can accept,
|
||||||
-- and returns it so that the receptacle can update it's pressure values.
|
-- and returns it so that the receptacle can update it's pressure values.
|
||||||
-- this should ensure that water blocks aren't vanished from existance.
|
-- this should ensure that water blocks aren't vanished from existance.
|
||||||
|
-- will take care of zero or negative-valued limits.
|
||||||
pipeworks.check_for_liquids_v2 = function(pos, limit)
|
pipeworks.check_for_liquids_v2 = function(pos, limit)
|
||||||
if not limit then
|
if not limit then
|
||||||
limit = 6
|
limit = 6
|
||||||
@ -207,3 +216,14 @@ pipeworks.balance_pressure = function(pos, node)
|
|||||||
targetmeta:set_float(label_pressure, average)
|
targetmeta:set_float(label_pressure, average)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
pipeworks.run_pump_intake = function(pos, node)
|
||||||
|
-- try to absorb nearby water nodes, but only up to limit.
|
||||||
|
-- NB: check_for_liquids_v2 handles zero or negative from the following subtraction
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
local currentpressure = meta:get_float(label_pressure)
|
||||||
|
local intake_limit = thresholds.pump_pressure - currentpressure
|
||||||
|
local actual_intake = pipeworks.check_for_liquids_v2(pos, limit)
|
||||||
|
local newpressure = actual_intake + currentpressure
|
||||||
|
meta:set_float(label_pressure, newpressure)
|
||||||
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user