mirror of
https://github.com/minetest-mods/mesecons.git
synced 2025-06-28 13:56:02 +02:00
Fix #155 (option 2 used). Remove non-ActionQueue system. Enable overheat for more than 20 actions per second on lua- / microcontrollers and gates.
Fix a bug where a burnt luacontroller didn't have the correct pin-states as the burnt controller does not register any changes from outside.
This commit is contained in:
@ -19,12 +19,6 @@ function mesecon.queue:add_action(pos, func, params, time, overwritecheck, prior
|
||||
owcheck=(overwritecheck and mesecon:tablecopy(overwritecheck)) or nil,
|
||||
priority=priority}
|
||||
|
||||
-- if not using the queue, (MESECONS_GLOBALSTEP off), just execute the function an we're done
|
||||
if not MESECONS_GLOBALSTEP and action.time == 0 then
|
||||
mesecon.queue:execute(action)
|
||||
return
|
||||
end
|
||||
|
||||
local toremove = nil
|
||||
-- Otherwise, add the action to the queue
|
||||
if overwritecheck then -- check if old action has to be overwritten / removed:
|
||||
|
@ -79,14 +79,12 @@ mesecon.queue:add_function("receptor_on", function (pos, rules)
|
||||
rules = rules or mesecon.rules.default
|
||||
|
||||
-- if area (any of the rule targets) is not loaded, keep trying and call this again later
|
||||
if MESECONS_GLOBALSTEP then -- trying to enable resuming with globalstep disabled would cause an endless loop
|
||||
for _, rule in ipairs(mesecon:flattenrules(rules)) do
|
||||
local np = mesecon:addPosRule(pos, rule)
|
||||
-- if area is not loaded, keep trying
|
||||
if minetest.get_node_or_nil(np) == nil then
|
||||
mesecon.queue:add_action(pos, "receptor_on", {rules}, nil, rules)
|
||||
return
|
||||
end
|
||||
for _, rule in ipairs(mesecon:flattenrules(rules)) do
|
||||
local np = mesecon:addPosRule(pos, rule)
|
||||
-- if area is not loaded, keep trying
|
||||
if minetest.get_node_or_nil(np) == nil then
|
||||
mesecon.queue:add_action(pos, "receptor_on", {rules}, nil, rules)
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
@ -108,13 +106,11 @@ mesecon.queue:add_function("receptor_off", function (pos, rules)
|
||||
rules = rules or mesecon.rules.default
|
||||
|
||||
-- if area (any of the rule targets) is not loaded, keep trying and call this again later
|
||||
if MESECONS_GLOBALSTEP then
|
||||
for _, rule in ipairs(mesecon:flattenrules(rules)) do
|
||||
local np = mesecon:addPosRule(pos, rule)
|
||||
if minetest.get_node_or_nil(np) == nil then
|
||||
mesecon.queue:add_action(pos, "receptor_off", {rules}, nil, rules)
|
||||
return
|
||||
end
|
||||
for _, rule in ipairs(mesecon:flattenrules(rules)) do
|
||||
local np = mesecon:addPosRule(pos, rule)
|
||||
if minetest.get_node_or_nil(np) == nil then
|
||||
mesecon.queue:add_action(pos, "receptor_off", {rules}, nil, rules)
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -412,9 +412,7 @@ function mesecon:turnon(pos, rulename, recdepth)
|
||||
end
|
||||
|
||||
mesecon.queue:add_function("turnon", function (pos, rulename, recdepth)
|
||||
if (MESECONS_GLOBALSTEP) then -- do not resume if we don't use globalstep - that would cause an endless loop
|
||||
mesecon:turnon(pos, rulename, recdepth)
|
||||
end
|
||||
mesecon:turnon(pos, rulename, recdepth)
|
||||
end)
|
||||
|
||||
function mesecon:turnoff(pos, rulename, recdepth)
|
||||
@ -455,9 +453,7 @@ function mesecon:turnoff(pos, rulename, recdepth)
|
||||
end
|
||||
|
||||
mesecon.queue:add_function("turnoff", function (pos, rulename, recdepth)
|
||||
if (MESECONS_GLOBALSTEP) then -- do not resume if we don't use globalstep - that would cause an endless loop
|
||||
mesecon:turnoff(pos, rulename, recdepth)
|
||||
end
|
||||
mesecon:turnoff(pos, rulename, recdepth)
|
||||
end)
|
||||
|
||||
|
||||
|
@ -1,3 +1,5 @@
|
||||
-- Dig and place services
|
||||
|
||||
mesecon.on_placenode = function (pos, node)
|
||||
-- Receptors: Send on signal when active
|
||||
if mesecon:is_receptor_on(node.name) then
|
||||
@ -37,15 +39,38 @@ mesecon.on_dignode = function (pos, node)
|
||||
end
|
||||
end
|
||||
|
||||
minetest.register_abm({
|
||||
nodenames = {"group:overheat"},
|
||||
interval = 1.0,
|
||||
chance = 1,
|
||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_int("heat",0)
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_on_placenode(mesecon.on_placenode)
|
||||
minetest.register_on_dignode(mesecon.on_dignode)
|
||||
|
||||
-- Overheating service for fast circuits
|
||||
|
||||
-- returns true if heat is too high
|
||||
mesecon.do_overheat = function(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local heat = meta:get_int("heat") or 0
|
||||
|
||||
heat = heat + 1
|
||||
meta:set_int("heat", heat)
|
||||
|
||||
if heat < OVERHEAT_MAX then
|
||||
mesecon.queue:add_action(pos, "cooldown", {}, 1, nil, 0)
|
||||
else
|
||||
return true
|
||||
end
|
||||
|
||||
return false
|
||||
end
|
||||
|
||||
|
||||
mesecon.queue:add_function("cooldown", function (pos)
|
||||
if minetest.get_item_group(minetest.get_node(pos).name, "overheat") == 0 then
|
||||
return -- node has been moved, this one does not use overheating - ignore
|
||||
end
|
||||
|
||||
local meta = minetest.get_meta(pos)
|
||||
local heat = meta:get_int("heat")
|
||||
|
||||
if (heat > 0) then
|
||||
meta:set_int("heat", heat - 1)
|
||||
end
|
||||
end)
|
||||
|
@ -1,11 +1,12 @@
|
||||
-- SETTINGS
|
||||
BLINKY_PLANT_INTERVAL = 3
|
||||
NEW_STYLE_WIRES = true -- true = new nodebox wires, false = old raillike wires
|
||||
NEW_STYLE_WIRES = true -- true = new nodebox wires, false = old raillike wires
|
||||
PRESSURE_PLATE_INTERVAL = 0.1
|
||||
OBJECT_DETECTOR_RADIUS = 6
|
||||
PISTON_MAXIMUM_PUSH = 15
|
||||
MOVESTONE_MAXIMUM_PUSH = 100
|
||||
MESECONS_GLOBALSTEP = true -- true = receptors/effectors won't be updated
|
||||
-- until next globalstep, decreases server load
|
||||
MESECONS_RESUMETIME = 4 -- time to wait when starting the server before
|
||||
-- processing the ActionQueue, don't set this too low
|
||||
OVERHEAT_MAX = 20 -- maximum heat of any component that directly sends an output
|
||||
-- signal when the input changes (e.g. luacontroller, gates)
|
||||
-- Unit: actions per second, checks are every 1 second
|
||||
|
Reference in New Issue
Block a user