2017-09-27 18:00:18 +02:00
|
|
|
-- register new flow logic ABMs
|
2017-09-27 18:54:03 +02:00
|
|
|
-- written 2017 by thetaepsilon
|
2017-09-27 18:00:18 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
2017-10-01 00:02:11 +02:00
|
|
|
local register = {}
|
|
|
|
pipeworks.flowlogic.abmregister = register
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-09-30 21:16:00 +02:00
|
|
|
-- note that checking for feature toggles (because otherwise certain pipes aren't define)
|
|
|
|
-- is now done by flowable_nodes_add_pipes.lua
|
|
|
|
--[[
|
2017-09-27 18:00:18 +02:00
|
|
|
if pipeworks.enable_pipes then
|
|
|
|
minetest.register_abm({
|
|
|
|
nodenames = pipes_all_nodenames,
|
|
|
|
interval = 1,
|
|
|
|
chance = 1,
|
|
|
|
action = function(pos, node, active_object_count, active_object_count_wider)
|
|
|
|
pipeworks.balance_pressure(pos, node)
|
|
|
|
end
|
|
|
|
})
|
|
|
|
end
|
2017-09-30 21:16:00 +02:00
|
|
|
]]
|
2017-09-30 23:41:38 +02:00
|
|
|
|
|
|
|
local register_abm_balance = function(nodename)
|
|
|
|
minetest.register_abm({
|
|
|
|
nodenames = { nodename },
|
|
|
|
interval = 1,
|
|
|
|
chance = 1,
|
|
|
|
action = function(pos, node, active_object_count, active_object_count_wider)
|
|
|
|
pipeworks.flowlogic.balance_pressure(pos, node)
|
|
|
|
end
|
|
|
|
})
|
|
|
|
end
|
2017-10-01 00:02:11 +02:00
|
|
|
register.balance = register_abm_balance
|
2017-09-30 23:41:38 +02:00
|
|
|
for nodename, _ in pairs(pipeworks.flowables.list.simple) do
|
|
|
|
register_abm_balance(nodename)
|
|
|
|
end
|
2017-09-27 18:00:18 +02:00
|
|
|
|
2017-09-30 23:56:12 +02:00
|
|
|
local register_abm_input = function(nodename, properties)
|
2017-09-27 18:00:18 +02:00
|
|
|
minetest.register_abm({
|
2017-09-30 23:56:12 +02:00
|
|
|
nodenames = { nodename },
|
2017-09-27 18:00:18 +02:00
|
|
|
interval = 1,
|
|
|
|
chance = 1,
|
|
|
|
action = function(pos, node, active_object_count, active_object_count_wider)
|
2017-09-30 21:47:00 +02:00
|
|
|
pipeworks.flowlogic.run_pump_intake(pos, node)
|
2017-09-27 18:00:18 +02:00
|
|
|
end
|
|
|
|
})
|
2017-09-30 23:56:12 +02:00
|
|
|
end
|
2017-10-01 00:02:11 +02:00
|
|
|
register.input = register_abm_input
|
2017-09-30 23:56:12 +02:00
|
|
|
|
|
|
|
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
|
2017-09-30 21:16:00 +02:00
|
|
|
|
2017-09-27 18:25:16 +02:00
|
|
|
-- output water from spigots
|
|
|
|
-- add both "on/off" spigots so one can be used to indicate a certain level of fluid.
|
2017-09-30 21:16:00 +02:00
|
|
|
-- temp. disabled as the node names were moved to flowable_node_add_pipes.lua
|
|
|
|
--[[
|
2017-09-27 18:25:16 +02:00
|
|
|
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
|
|
|
|
})
|
2017-09-30 21:16:00 +02:00
|
|
|
]]
|
2017-09-27 18:00:18 +02:00
|
|
|
end
|