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-10-01 00:22:04 +02:00
|
|
|
-- register a node name for the pressure balancing ABM.
|
|
|
|
-- currently this only exists as a per-node function to allow nodes to be registered outside pipeworks.
|
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-27 18:00:18 +02:00
|
|
|
|
2017-10-01 13:28:22 +02:00
|
|
|
-- register a node for the input ABM.
|
|
|
|
-- intakefn is run on the node to determine how much water can be taken (and update it's environment accordingly).
|
|
|
|
-- maxpressure is the maximum pressure that this input can drive, beyond which pressure will not be raised.
|
2017-10-01 01:44:14 +02:00
|
|
|
local register_abm_input = function(nodename, maxpressure, intakefn)
|
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-10-01 01:44:14 +02:00
|
|
|
pipeworks.flowlogic.run_input(pos, node, maxpressure, intakefn)
|
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
|
|
|
|
2017-10-01 00:22:04 +02:00
|
|
|
-- old spigot ABM code, not yet migrated
|
|
|
|
--[[
|
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-10-01 00:22:04 +02:00
|
|
|
]]
|