From df8ef255a3a66c676fc74197fb034e5033aed763 Mon Sep 17 00:00:00 2001 From: thetaepsilon-gamedev Date: Wed, 27 Sep 2017 17:25:16 +0100 Subject: flowing_logic.lua: add new spigot code + ABM registration --- flowing_logic.lua | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'flowing_logic.lua') diff --git a/flowing_logic.lua b/flowing_logic.lua index 62d75ab..50a4c99 100644 --- a/flowing_logic.lua +++ b/flowing_logic.lua @@ -234,3 +234,19 @@ pipeworks.run_pump_intake = function(pos, node) -- debuglog("oldpressure "..currentpressure.." intake_limit "..intake_limit.." actual_intake "..actual_intake.." newpressure "..newpressure) meta:set_float(label_pressure, newpressure) end + + + +pipeworks.run_spigot_output = function(pos, node) + -- try to output a water source node if there's enough pressure and space below. + local meta = minetest.get_meta(pos) + local currentpressure = meta:get_float(label_pressure) + if currentpressure > 1 then + local below = {x=pos.x, y=pos.y-1, z=pos.z} + local name = minetest.get_node(below).name + if (name == "air") or (name == "default:water_flowing") then + minetest.set_node(below, {name="default:water_source"}) + meta:set_float(label_pressure, currentpressure - 1) + end + end +end -- cgit v1.2.3