summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorthetaepsilon-gamedev <thetaepsilon-gamedev@noreply.users.github.com>2017-09-27 16:02:30 +0100
committerthetaepsilon-gamedev <thetaepsilon-gamedev@noreply.users.github.com>2017-09-27 16:02:30 +0100
commitc5e5aa069fd45ba8d617bf4192f59699ddcdb186 (patch)
tree3e98d8ec2993e7f2010637f3f29152e2228c566a
parent6a0fe9f3c0797fb18f3613b35251536f84424d01 (diff)
downloadpipeworks-c5e5aa069fd45ba8d617bf4192f59699ddcdb186.tar
pipeworks-c5e5aa069fd45ba8d617bf4192f59699ddcdb186.tar.gz
pipeworks-c5e5aa069fd45ba8d617bf4192f59699ddcdb186.tar.bz2
pipeworks-c5e5aa069fd45ba8d617bf4192f59699ddcdb186.tar.xz
pipeworks-c5e5aa069fd45ba8d617bf4192f59699ddcdb186.zip
flowing_logic.lua: add start of new pump handler code
-rw-r--r--flowing_logic.lua20
1 files changed, 20 insertions, 0 deletions
diff --git a/flowing_logic.lua b/flowing_logic.lua
index 1c02d36..0147283 100644
--- a/flowing_logic.lua
+++ b/flowing_logic.lua
@@ -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
local make_coords_offsets = function(pos, include_base)
local coords = {
@@ -155,6 +163,7 @@ end
-- 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.
-- 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)
if not limit then
limit = 6
@@ -207,3 +216,14 @@ pipeworks.balance_pressure = function(pos, node)
targetmeta:set_float(label_pressure, average)
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