forked from mtcontrib/pipeworks
flowing_logic.lua: add new spigot code + ABM registration
This commit is contained in:
parent
69133818f7
commit
df8ef255a3
|
@ -234,3 +234,19 @@ pipeworks.run_pump_intake = function(pos, node)
|
||||||
-- debuglog("oldpressure "..currentpressure.." intake_limit "..intake_limit.." actual_intake "..actual_intake.." newpressure "..newpressure)
|
-- debuglog("oldpressure "..currentpressure.." intake_limit "..intake_limit.." actual_intake "..actual_intake.." newpressure "..newpressure)
|
||||||
meta:set_float(label_pressure, newpressure)
|
meta:set_float(label_pressure, newpressure)
|
||||||
end
|
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
|
||||||
|
|
|
@ -7,13 +7,20 @@ local pipes_empty_nodenames = pipeworks.pipes_empty_nodenames
|
||||||
-- FIXME: DRY principle, get this from elsewhere in the code
|
-- FIXME: DRY principle, get this from elsewhere in the code
|
||||||
local pump_on = "pipeworks:pump_on"
|
local pump_on = "pipeworks:pump_on"
|
||||||
local pump_off = "pipeworks:pump_off"
|
local pump_off = "pipeworks:pump_off"
|
||||||
|
local spigot_off = "pipeworks:spigot"
|
||||||
|
local spigot_on = "pipeworks:spigot_pouring"
|
||||||
|
|
||||||
local pipes_all_nodenames = pipes_full_nodenames
|
local pipes_all_nodenames = pipes_full_nodenames
|
||||||
for _, pipe in ipairs(pipes_empty_nodenames) do
|
for _, pipe in ipairs(pipes_empty_nodenames) do
|
||||||
table.insert(pipes_all_nodenames, pipe)
|
table.insert(pipes_all_nodenames, pipe)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if pipeworks.enable_pipe_devices then
|
||||||
table.insert(pipes_all_nodenames, pump_off)
|
table.insert(pipes_all_nodenames, pump_off)
|
||||||
table.insert(pipes_all_nodenames, pump_on)
|
table.insert(pipes_all_nodenames, pump_on)
|
||||||
|
table.insert(pipes_all_nodenames, spigot_on)
|
||||||
|
table.insert(pipes_all_nodenames, spigot_off)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
if pipeworks.enable_pipes then
|
if pipeworks.enable_pipes then
|
||||||
|
@ -37,4 +44,14 @@ if pipeworks.enable_pipe_devices then
|
||||||
pipeworks.run_pump_intake(pos, node)
|
pipeworks.run_pump_intake(pos, node)
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
-- output water from spigots
|
||||||
|
-- add both "on/off" spigots so one can be used to indicate a certain level of fluid.
|
||||||
|
minetest.register_abm({
|
||||||
|
nodenames = { spigot_on, spigot_off },
|
||||||
|
interval = 1,
|
||||||
|
chance = 1,
|
||||||
|
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||||
|
pipeworks.run_spigot_output(pos, node)
|
||||||
|
end
|
||||||
|
})
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue
Block a user