forked from mtcontrib/pipeworks
new flow logic: abm_register.lua: add extra safeguarding for conditional activation of new flow logic
This commit is contained in:
parent
084174123d
commit
72f793e2b3
@ -1,30 +1,26 @@
|
|||||||
-- register new flow logic ABMs
|
-- register new flow logic ABMs
|
||||||
-- written 2017 by thetaepsilon
|
-- written 2017 by thetaepsilon
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
local register = {}
|
local register = {}
|
||||||
pipeworks.flowlogic.abmregister = register
|
pipeworks.flowlogic.abmregister = register
|
||||||
|
|
||||||
local flowlogic = pipeworks.flowlogic
|
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.
|
-- register node list for the main logic function.
|
||||||
-- see flowlogic.run() in abms.lua.
|
-- see flowlogic.run() in abms.lua.
|
||||||
|
|
||||||
local register_flowlogic_abm = function(nodename)
|
local register_flowlogic_abm = function(nodename)
|
||||||
minetest.register_abm({
|
if pipeworks.toggles.pressure_logic then
|
||||||
nodenames = { nodename },
|
minetest.register_abm({
|
||||||
interval = 1,
|
nodenames = { nodename },
|
||||||
chance = 1,
|
interval = 1,
|
||||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
chance = 1,
|
||||||
flowlogic.run(pos, node)
|
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||||
end
|
flowlogic.run(pos, node)
|
||||||
})
|
end
|
||||||
|
})
|
||||||
|
else
|
||||||
|
minetest.log("warning", "pipeworks pressure_logic not enabled but register.flowlogic() requested")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
register.flowlogic = register_flowlogic_abm
|
register.flowlogic = register_flowlogic_abm
|
||||||
|
Loading…
Reference in New Issue
Block a user