From fc1e727473983f783539ce8b69a541de23710ad1 Mon Sep 17 00:00:00 2001 From: Someone Date: Wed, 23 Oct 2024 16:03:36 +0200 Subject: [PATCH] RELEASE 2.0.4 - Global storage should work again. --- changelog.txt | 7 +++++++ control.lua | 29 ++++++++++++++++------------- info.json | 2 +- 3 files changed, 24 insertions(+), 14 deletions(-) diff --git a/changelog.txt b/changelog.txt index 15de050..c44ce5d 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,3 +1,10 @@ +--------------------------------------------------------------------------------------------------- +Version: 2.0.4 +Date: 2024-10-23 + + Changed: + - Global storage should work again. + --------------------------------------------------------------------------------------------------- Version: 2.0.3 Date: 2024-10-23 diff --git a/control.lua b/control.lua index 6a95aee..266a0a9 100644 --- a/control.lua +++ b/control.lua @@ -1,13 +1,16 @@ -local auto_research_config = {} function getConfig(force, config_changed) + if not storage.auto_research_config then + storage.auto_research_config = {} + end + -- Disable Research Queue popup if remote.interfaces.RQ and remote.interfaces.RQ["popup"] then remote.call("RQ", "popup", false) end - if not auto_research_config[force.name] then - auto_research_config[force.name] = { + if not storage.auto_research_config[force.name] then + storage.auto_research_config[force.name] = { prioritized_techs = {}, -- "prioritized" is "queued". kept for backwards compatability (because i'm lazy and don't want migration code) deprioritized_techs = {} -- "deprioritized" is "blacklisted". kept for backwards compatability (because i'm lazy and don't want migration code) } @@ -25,27 +28,27 @@ function getConfig(force, config_changed) end -- set research strategy - auto_research_config[force.name].research_strategy = auto_research_config[force.name].research_strategy or "balanced" + storage.auto_research_config[force.name].research_strategy = storage.auto_research_config[force.name].research_strategy or "balanced" - if config_changed or not auto_research_config[force.name].allowed_ingredients or not auto_research_config[force.name].infinite_research then + if config_changed or not storage.auto_research_config[force.name].allowed_ingredients or not storage.auto_research_config[force.name].infinite_research then -- remember any old ingredients local old_ingredients = {} - if auto_research_config[force.name].allowed_ingredients then - for name, enabled in pairs(auto_research_config[force.name].allowed_ingredients) do + if storage.auto_research_config[force.name].allowed_ingredients then + for name, enabled in pairs(storage.auto_research_config[force.name].allowed_ingredients) do old_ingredients[name] = enabled end end -- find all possible tech ingredients -- also scan for research that are infinite: techs that have no successor and tech.research_unit_count_formula is not nil - auto_research_config[force.name].allowed_ingredients = {} - auto_research_config[force.name].infinite_research = {} + storage.auto_research_config[force.name].allowed_ingredients = {} + storage.auto_research_config[force.name].infinite_research = {} local finite_research = {} for _, tech in pairs(force.technologies) do for _, ingredient in pairs(tech.research_unit_ingredients) do - auto_research_config[force.name].allowed_ingredients[ingredient.name] = (old_ingredients[ingredient.name] == nil or old_ingredients[ingredient.name]) + storage.auto_research_config[force.name].allowed_ingredients[ingredient.name] = (old_ingredients[ingredient.name] == nil or old_ingredients[ingredient.name]) end if tech.research_unit_count_formula then - auto_research_config[force.name].infinite_research[tech.name] = tech + storage.auto_research_config[force.name].infinite_research[tech.name] = tech end for _, pretech in pairs(tech.prerequisites) do if pretech.enabled and not pretech.researched then @@ -54,11 +57,11 @@ function getConfig(force, config_changed) end end for techname, _ in pairs(finite_research) do - auto_research_config[force.name].infinite_research[techname] = nil + storage.auto_research_config[force.name].infinite_research[techname] = nil end end - return auto_research_config[force.name] + return storage.auto_research_config[force.name] end function setAutoResearch(force, enabled) diff --git a/info.json b/info.json index 8a212e8..56f73bb 100644 --- a/info.json +++ b/info.json @@ -1,6 +1,6 @@ { "name": "some-autoresearch", - "version": "2.0.3", + "version": "2.0.4", "title": "Auto Research (fixed + re-published)", "author": "Someone (originally canidae)", "homepage": "https://git.somenet.org/factorio/some-autoresearch.git", -- 2.43.0