forked from mtcontrib/pipeworks
new_flow_logic.lua: move logic functions inside pipeworks.flowlogic sub-table
This commit is contained in:
parent
40eeaac2ec
commit
0251baf692
|
@ -3,6 +3,11 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
local flowlogic = {}
|
||||||
|
pipeworks.flowlogic = flowlogic
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
-- borrowed from above: might be useable to replace the above coords tables
|
-- borrowed from above: might be useable to replace the above coords tables
|
||||||
local make_coords_offsets = function(pos, include_base)
|
local make_coords_offsets = function(pos, include_base)
|
||||||
local coords = {
|
local coords = {
|
||||||
|
@ -28,7 +33,7 @@ end
|
||||||
-- and returns it so that the receptacle can update it's pressure values.
|
-- and returns it so that the receptacle can update it's pressure values.
|
||||||
-- this should ensure that water blocks aren't vanished from existance.
|
-- this should ensure that water blocks aren't vanished from existance.
|
||||||
-- will take care of zero or negative-valued limits.
|
-- will take care of zero or negative-valued limits.
|
||||||
pipeworks.check_for_liquids_v2 = function(pos, limit)
|
flowlogic.check_for_liquids_v2 = function(pos, limit)
|
||||||
if not limit then
|
if not limit then
|
||||||
limit = 6
|
limit = 6
|
||||||
end
|
end
|
||||||
|
@ -50,7 +55,7 @@ end
|
||||||
|
|
||||||
local label_pressure = "pipeworks.water_pressure"
|
local label_pressure = "pipeworks.water_pressure"
|
||||||
local label_haspressure = "pipeworks.is_pressure_node"
|
local label_haspressure = "pipeworks.is_pressure_node"
|
||||||
pipeworks.balance_pressure = function(pos, node)
|
flowlogic.balance_pressure = function(pos, node)
|
||||||
-- debuglog("balance_pressure() "..node.name.." at "..pos.x.." "..pos.y.." "..pos.z)
|
-- debuglog("balance_pressure() "..node.name.." at "..pos.x.." "..pos.y.." "..pos.z)
|
||||||
-- check the pressure of all nearby nodes, and average it out.
|
-- check the pressure of all nearby nodes, and average it out.
|
||||||
-- for the moment, only balance neighbour nodes if it already has a pressure value.
|
-- for the moment, only balance neighbour nodes if it already has a pressure value.
|
||||||
|
@ -84,7 +89,7 @@ end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
pipeworks.run_pump_intake = function(pos, node)
|
flowlogic.run_pump_intake = function(pos, node)
|
||||||
-- try to absorb nearby water nodes, but only up to limit.
|
-- try to absorb nearby water nodes, but only up to limit.
|
||||||
-- NB: check_for_liquids_v2 handles zero or negative from the following subtraction
|
-- NB: check_for_liquids_v2 handles zero or negative from the following subtraction
|
||||||
|
|
||||||
|
@ -103,7 +108,7 @@ end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
pipeworks.run_spigot_output = function(pos, node)
|
flowlogic.run_spigot_output = function(pos, node)
|
||||||
-- try to output a water source node if there's enough pressure and space below.
|
-- try to output a water source node if there's enough pressure and space below.
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
local currentpressure = meta:get_float(label_pressure)
|
local currentpressure = meta:get_float(label_pressure)
|
||||||
|
|
|
@ -23,7 +23,7 @@ minetest.register_abm({
|
||||||
interval = 1,
|
interval = 1,
|
||||||
chance = 1,
|
chance = 1,
|
||||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||||
pipeworks.balance_pressure(pos, node)
|
pipeworks.flowlogic.balance_pressure(pos, node)
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ if pipeworks.enable_pipe_devices then
|
||||||
interval = 1,
|
interval = 1,
|
||||||
chance = 1,
|
chance = 1,
|
||||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||||
pipeworks.run_pump_intake(pos, node)
|
pipeworks.flowlogic.run_pump_intake(pos, node)
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user