summaryrefslogtreecommitdiff
path: root/new_flow_logic/register_local_pipes.lua
blob: 6fe8b7e29673ca36b769c9db78abbdba79ed4e49 (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
-- conditional registration of pipe nodes for the new pipe logic, depending on enable flags.
-- otherwise register_flow_logic.lua would be attempting to register ABMs for non-existant nodes.
-- written 2017 by thetaepsilon



-- global values and thresholds for water behaviour
-- TODO: add some way of setting this per-world
local thresholds = {}
-- limit on pump pressure - will not absorb more than can be taken
thresholds.pump_pressure = 2



local pipes_full_nodenames = pipeworks.pipes_full_nodenames
local pipes_empty_nodenames = pipeworks.pipes_empty_nodenames

local register = pipeworks.flowables.register
local abmregister = pipeworks.flowlogic.abmregister



-- FIXME: DRY principle for names, move this to devices.lua?
-- FIXME: all devices still considered simple
local pump_on = "pipeworks:pump_on"
local pump_off = "pipeworks:pump_off"
local spigot_off = "pipeworks:spigot"
local spigot_on = "pipeworks:spigot_pouring"

if pipeworks.enable_pipes then
	for _, pipe in ipairs(pipes_full_nodenames) do
		register.simple(pipe)
		abmregister.balance(pipe)
	end
	for _, pipe in ipairs(pipes_empty_nodenames) do
		register.simple(pipe)
		abmregister.balance(pipe)
	end

	if pipeworks.enable_pipe_devices then
		register.simple(pump_off)
		register.simple(pump_on)
		register.simple(spigot_on)
		register.simple(spigot_off)
		abmregister.balance(pump_off)
		abmregister.balance(pump_on)
		abmregister.balance(spigot_on)
		abmregister.balance(spigot_off)

		register.intake_simple(pump_on, thresholds.pump_pressure)
		abmregister.input(pump_on, thresholds.pump_pressure)
	end
end