This commit is contained in:
DS 2024-03-16 09:02:10 -06:00 committed by GitHub
commit f88faed3d8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 42 additions and 7 deletions

View File

@ -77,9 +77,16 @@ minetest.register_on_placenode(mesecon.on_placenode)
minetest.register_on_dignode(mesecon.on_dignode)
-- Overheating service for fast circuits
local OVERHEAT_MAX = mesecon.setting("overheat_max", 20)
local COOLDOWN_TIME = mesecon.setting("cooldown_time", 2.0)
local COOLDOWN_STEP = mesecon.setting("cooldown_granularity", 0.5)
local OVERHEAT_MAX = math.max(1.0, mesecon.setting("overheat_max", 20.0))
local COOLDOWN_MODE = mesecon.setting("cooldown_mode", "steps")
local COOLDOWN_IN_STEPS = COOLDOWN_MODE == "steps"
-- default for steps assumes a dtime of 0.016 seconds
local COOLDOWN_TIME = math.max(0.0, COOLDOWN_IN_STEPS and
mesecon.setting("cooldown_time_steps", 125.0) or
mesecon.setting("cooldown_time", 2.0))
local COOLDOWN_STEP = math.max(0.0, COOLDOWN_IN_STEPS and
mesecon.setting("cooldown_granularity_steps", 20) or
mesecon.setting("cooldown_granularity", 0.5))
local COOLDOWN_MULTIPLIER = OVERHEAT_MAX / COOLDOWN_TIME
local cooldown_timer = 0.0
local object_heat = {}
@ -121,7 +128,7 @@ function mesecon.move_hot_nodes(moved_nodes)
end
local function global_cooldown(dtime)
cooldown_timer = cooldown_timer + dtime
cooldown_timer = cooldown_timer + (COOLDOWN_IN_STEPS and 1 or dtime)
if cooldown_timer < COOLDOWN_STEP then
return -- don't overload the CPU
end

View File

@ -1,9 +1,37 @@
[mesecons]
# Number of seconds to wait after server start before starting to execute actions
# from the actionqueue.
mesecon.resumetime (Startup delay) int 4 1 10
mesecon.overheat_max (Device heat limit) int 20 1 100
mesecon.cooldown_time (Device cooldown time) float 2.0 0.1 10.0
mesecon.cooldown_granularity (Cooldown step length) float 0.5 0.0 1.0
# Heat at which a device overheats.
# As a rule of thumb, a device gets 1 additional heat each time when it toggles.
mesecon.overheat_max (Device heat limit) float 20.0 1.0
# The method used to cooldown devices over time:
# - seconds: The cooldown will happen per seconds.
# Use mesecon.cooldown_time and mesecon.cooldown_granularity for further configuration.
# - steps: The cooldown will happen per server steps.
# Use mesecon.cooldown_time_steps and mesecon.cooldown_granularity_steps for further configuration.
mesecon.cooldown_mode (Device cooldown mode) enum steps seconds,steps
# The time in seconds it takes for a device to fully cool down from max heat.
# Only used if mesecon.cooldown_mode is seconds.
mesecon.cooldown_time (Device cooldown time in seconds) float 2.0 0.0
# Length in seconds of the interval in which devices are cooled down over time.
# This does not affect the cooldown speed.
# Only used if mesecon.cooldown_mode is seconds.
mesecon.cooldown_granularity (Cooldown step length in seconds) float 0.5 0.0
# The time in server steps it takes for a device to fully cool down from max heat.
# Only used if mesecon.cooldown_mode is steps.
mesecon.cooldown_time_steps (Device cooldown time in server steps) float 125.0 0.0
# Length in server steps of the interval in which devices are cooled down over time.
# This does not affect the cooldown speed.
# Only used if mesecon.cooldown_mode is steps.
mesecon.cooldown_granularity_steps (Cooldown step length in server steps) int 20 0
[mesecons_blinkyplant]