2017-10-01 01:24:45 +02:00
|
|
|
-- registration of pipework's own pipes.
|
2017-09-30 21:16:00 +02:00
|
|
|
-- 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
|
2017-10-01 14:00:41 +02:00
|
|
|
-- activation threshold for spigot
|
|
|
|
-- should not be below 1, as spigot helper code indiscriminately places a water source node if run.
|
|
|
|
thresholds.spigot_min = 1
|
2017-09-30 21:16:00 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
local pipes_full_nodenames = pipeworks.pipes_full_nodenames
|
|
|
|
local pipes_empty_nodenames = pipeworks.pipes_empty_nodenames
|
|
|
|
|
|
|
|
local register = pipeworks.flowables.register
|
2017-10-01 14:00:41 +02:00
|
|
|
local flowlogic = pipeworks.flowlogic
|
2017-09-30 21:16:00 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- 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
|
2017-10-01 17:54:24 +02:00
|
|
|
--[[
|
2017-09-30 21:16:00 +02:00
|
|
|
for _, pipe in ipairs(pipes_full_nodenames) do
|
|
|
|
register.simple(pipe)
|
|
|
|
end
|
|
|
|
for _, pipe in ipairs(pipes_empty_nodenames) do
|
|
|
|
register.simple(pipe)
|
|
|
|
end
|
2017-10-01 17:54:24 +02:00
|
|
|
]]
|
2017-09-30 21:16:00 +02:00
|
|
|
|
|
|
|
if pipeworks.enable_pipe_devices then
|
|
|
|
register.simple(pump_off)
|
|
|
|
register.simple(pump_on)
|
|
|
|
register.simple(spigot_on)
|
|
|
|
register.simple(spigot_off)
|
|
|
|
|
|
|
|
register.intake_simple(pump_on, thresholds.pump_pressure)
|
2017-10-01 14:00:41 +02:00
|
|
|
-- TODO: the code doesn't currently care if the spigot is the visually flowing node or not.
|
|
|
|
-- So some mechanism to register on/off states would be nice
|
|
|
|
register.output(spigot_off, thresholds.spigot_min, flowlogic.helpers.output_spigot)
|
|
|
|
register.output(spigot_on, thresholds.spigot_min, flowlogic.helpers.output_spigot)
|
2017-09-30 21:16:00 +02:00
|
|
|
end
|
|
|
|
end
|