summaryrefslogtreecommitdiff
path: root/new_flow_logic/abm_register.lua
blob: ac7b2e3f6646c5d55be41fefa3a1f783d15eaa40 (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
-- register new flow logic ABMs
-- written 2017 by thetaepsilon



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

local flowlogic = pipeworks.flowlogic

-- A possible DRY violation here...
-- DISCUSS: should it be possible later on to raise the the rate of ABMs, or lower the chance?
-- Currently all the intervals and chances are hardcoded below.



-- register node list for the main logic function.
-- see flowlogic.run() in abms.lua.

local register_flowlogic_abm = function(nodename)
	minetest.register_abm({
		nodenames = { nodename },
		interval = 1,
		chance = 1,
		action = function(pos, node, active_object_count, active_object_count_wider)
			flowlogic.run(pos, node)
		end
	})
end
register.flowlogic = register_flowlogic_abm