From 6a0fe9f3c0797fb18f3613b35251536f84424d01 Mon Sep 17 00:00:00 2001 From: thetaepsilon-gamedev Date: Wed, 27 Sep 2017 15:49:03 +0100 Subject: [PATCH] flowing_logic.lua: add new version of check_for_liquids() --- flowing_logic.lua | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/flowing_logic.lua b/flowing_logic.lua index ee34ed0..1c02d36 100644 --- a/flowing_logic.lua +++ b/flowing_logic.lua @@ -149,6 +149,31 @@ local make_coords_offsets = function(pos, include_base) return coords end + + +-- new version of liquid check +-- 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. +pipeworks.check_for_liquids_v2 = function(pos, limit) + if not limit then + limit = 6 + end + local coords = make_coords_offsets(pos, false) + local total = 0 + for index, tpos in ipairs(coords) do + if total >= limit then break end + local name = minetest.get_node(tpos).name + if name == "default:water_source" then + minetest.remove_node(tpos) + total = total + 1 + end + end + return total +end + + + local label_pressure = "pipeworks.water_pressure" local label_haspressure = "pipeworks.is_pressure_node" pipeworks.balance_pressure = function(pos, node)