From 8030a462b399646c191242b4c0532a9bc30e2b8b Mon Sep 17 00:00:00 2001 From: Monica Moniot Date: Tue, 29 Nov 2022 20:40:07 -0500 Subject: [PATCH] added an update rate setting --- cybersyn/changelog.txt | 6 ++++++ cybersyn/info.json | 2 +- cybersyn/locale/en/base.cfg | 2 ++ cybersyn/scripts/central-planning.lua | 2 +- cybersyn/scripts/global.lua | 1 + cybersyn/scripts/main.lua | 2 ++ cybersyn/settings.lua | 9 +++++++++ 7 files changed, 22 insertions(+), 2 deletions(-) diff --git a/cybersyn/changelog.txt b/cybersyn/changelog.txt index 1d658e0..fb4d224 100644 --- a/cybersyn/changelog.txt +++ b/cybersyn/changelog.txt @@ -65,3 +65,9 @@ Date: 2022-11-29 Features: - Minor bugfix - Added placeholder sprites +--------------------------------------------------------------------------------------------------- +Version: 1.0.2 +Date: 2022-11-29 + Features: + - Added mod description + - Added update rate setting diff --git a/cybersyn/info.json b/cybersyn/info.json index b999582..68dce6c 100644 --- a/cybersyn/info.json +++ b/cybersyn/info.json @@ -1,6 +1,6 @@ { "name": "cybersyn", - "version": "1.0.0", + "version": "1.0.1", "title": "Project Cybersyn", "author": "Mami", "factorio_version": "1.1", diff --git a/cybersyn/locale/en/base.cfg b/cybersyn/locale/en/base.cfg index 1cb6d87..2023752 100644 --- a/cybersyn/locale/en/base.cfg +++ b/cybersyn/locale/en/base.cfg @@ -1,5 +1,6 @@ [mod-setting-name] cybersyn-ticks-per-second=Central planning updates per second +cybersyn-update-rate=Central planning update rate cybersyn-wait-time=Required inactivity duration (sec) cybersyn-request-threshold=Default requester threshold cybersyn-network-flag=Default network mask @@ -8,6 +9,7 @@ cybersyn-stuck-train-time=Stuck train timeout (sec) [mod-setting-description] cybersyn-ticks-per-second=How many times per second the central planner should update the state of the network and schedule deliveries. Only one deliveries can be made per update. This value will be rounded up to a divisor of 60. +cybersyn-update-rate=How many stations per tick can be polled at once. Larger number allow the central planner to keep more up to date on the current state of the network, but at the cost of performance. cybersyn-wait-time=How many seconds the duration of a train's inactivity order will be set to. Trains will be forced to wait in the station or depot until this amount of time has passed without the train receiving any kind of interaction. Non-zero values prevent inserters from getting stuck and prevent trains from leaving depots without refueling. Decimal values are allowed, they will be rounded up to a multiple of 1/60 (0.01667). cybersyn-request-threshold=The default request threshold when a request threshold signal is not given to a station. When a station receives a negative item signal that surpasses its request threshold, so long as any station exists with a positive signal greater than the request threshold, a delivery of that item will be scheduled between the two stations. cybersyn-network-flag=The default set of sub-networks a station will service when no network signal is given to a station. This integer is interpretted bit-wise to give 32 possible sub-networks to choose from. diff --git a/cybersyn/scripts/central-planning.lua b/cybersyn/scripts/central-planning.lua index 9f915ee..a8332cd 100644 --- a/cybersyn/scripts/central-planning.lua +++ b/cybersyn/scripts/central-planning.lua @@ -500,7 +500,7 @@ function tick(map_data, mod_settings) end if map_data.tick_state == STATE_POLL_STATIONS then - for i = 1, 2 do + for i = 1, mod_settings.update_rate do if tick_poll_station(map_data, mod_settings) then break end end elseif map_data.tick_state == STATE_DISPATCH then diff --git a/cybersyn/scripts/global.lua b/cybersyn/scripts/global.lua index d7fb57a..ecef4bc 100644 --- a/cybersyn/scripts/global.lua +++ b/cybersyn/scripts/global.lua @@ -77,6 +77,7 @@ ---@class CybersynModSettings ---@field public tps int +---@field public update_rate int ---@field public r_threshold int ---@field public network_flag int ---@field public warmup_time int diff --git a/cybersyn/scripts/main.lua b/cybersyn/scripts/main.lua index 24907d7..f0885b1 100644 --- a/cybersyn/scripts/main.lua +++ b/cybersyn/scripts/main.lua @@ -837,6 +837,7 @@ end local function on_settings_changed(event) mod_settings.tps = settings.global["cybersyn-ticks-per-second"].value --[[@as int]] + mod_settings.update_rate = settings.global["cybersyn-update-rate"].value --[[@as int]] mod_settings.r_threshold = settings.global["cybersyn-request-threshold"].value--[[@as int]] mod_settings.network_flag = settings.global["cybersyn-network-flag"].value--[[@as int]] mod_settings.warmup_time = settings.global["cybersyn-warmup-time"].value--[[@as int]] @@ -868,6 +869,7 @@ local filter_broken = { } local function main() mod_settings.tps = settings.global["cybersyn-ticks-per-second"].value --[[@as int]] + mod_settings.update_rate = settings.global["cybersyn-update-rate"].value --[[@as int]] mod_settings.r_threshold = settings.global["cybersyn-request-threshold"].value--[[@as int]] mod_settings.network_flag = settings.global["cybersyn-network-flag"].value--[[@as int]] mod_settings.warmup_time = settings.global["cybersyn-warmup-time"].value--[[@as int]] diff --git a/cybersyn/settings.lua b/cybersyn/settings.lua index 60bbaa6..59f113e 100644 --- a/cybersyn/settings.lua +++ b/cybersyn/settings.lua @@ -9,6 +9,15 @@ data:extend({ minimum_value = 1, maximum_value = 60, }, + { + type = "int-setting", + name = "cybersyn-update-rate", + order = "ab", + setting_type = "runtime-global", + default_value = 2, + minimum_value = 1, + maximum_value = 2147483647, + }, --{ -- type = "int-setting", -- name = "cybersyn-wait-time",