summaryrefslogtreecommitdiff
path: root/register_flow_logic.lua
blob: f82b8a96e2a36cef928ee14bcadf8b166a8d738f (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
50
51
52
53
54
55
56
57
58
59
-- register new flow logic ABMs
-- written 2017 by thetaepsilon



-- note that checking for feature toggles (because otherwise certain pipes aren't define)
-- is now done by flowable_nodes_add_pipes.lua
--[[
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
]]

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
for nodename, _ in pairs(pipeworks.flowables.list.simple) do
	register_abm_balance(nodename)
end

if pipeworks.enable_pipe_devices then
	-- absorb water into pumps if it'll fit
	minetest.register_abm({
		nodenames = pipeworks.flowables.inputs.nodenames,
		interval = 1,
		chance = 1,
		action = function(pos, node, active_object_count, active_object_count_wider)
			pipeworks.flowlogic.run_pump_intake(pos, node)
		end
	})

	-- output water from spigots
	-- add both "on/off" spigots so one can be used to indicate a certain level of fluid.
	-- temp. disabled as the node names were moved to flowable_node_add_pipes.lua
	--[[
	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
	})
	]]
end