summaryrefslogtreecommitdiff
path: root/register_flow_logic.lua
blob: e7bed6a13fedbcf859100d8d9821d1f2a1c152be (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
-- register new flow logic ABMs
-- written 2017 by thetaepsilon



local register = {}
pipeworks.flowlogic.abmregister = register



-- 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.
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
register.balance = register_abm_balance

-- register a node for the pump ABM.
-- maxpressure is the maximum pressure that this pump can drive.
local register_abm_input = function(nodename, maxpressure)
	minetest.register_abm({
		nodenames = { nodename },
		interval = 1,
		chance = 1,
		action = function(pos, node, active_object_count, active_object_count_wider)
			pipeworks.flowlogic.run_pump_intake(pos, node)
		end
	})
end
register.input = register_abm_input

-- old spigot ABM code, not yet migrated
--[[
	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
	})
]]