register_flow_logic.lua: factor out per-node input ABM registration

This commit is contained in:
thetaepsilon-gamedev 2017-09-30 22:56:12 +01:00
parent 7498a32364
commit aaef5eb22b
1 changed files with 9 additions and 3 deletions

View File

@ -32,16 +32,22 @@ for nodename, _ in pairs(pipeworks.flowables.list.simple) do
register_abm_balance(nodename) register_abm_balance(nodename)
end end
if pipeworks.enable_pipe_devices then local register_abm_input = function(nodename, properties)
-- absorb water into pumps if it'll fit
minetest.register_abm({ minetest.register_abm({
nodenames = pipeworks.flowables.inputs.nodenames, nodenames = { nodename },
interval = 1, interval = 1,
chance = 1, chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider) action = function(pos, node, active_object_count, active_object_count_wider)
pipeworks.flowlogic.run_pump_intake(pos, node) pipeworks.flowlogic.run_pump_intake(pos, node)
end end
}) })
end
if pipeworks.enable_pipe_devices then
-- absorb water into pumps if it'll fit
for nodename, properties in pairs(pipeworks.flowables.inputs.list) do
register_abm_input(nodename, properties)
end
-- output water from spigots -- output water from spigots
-- add both "on/off" spigots so one can be used to indicate a certain level of fluid. -- add both "on/off" spigots so one can be used to indicate a certain level of fluid.