RELEASE 2.0.0 - Initial compatibility with Factorio 2.0
authorSomeone <someone@somenet.org>
Tue, 22 Oct 2024 10:42:51 +0000 (12:42 +0200)
committerSomeone <someone@somenet.org>
Tue, 22 Oct 2024 10:42:51 +0000 (12:42 +0200)
changelog.txt
control.lua
data-final-fixes.lua
info.json
settings.lua

index 6606a68020e5eb5f7fa1dde6054ea883fdb9c296..83f1c2b1bf2c2284c277ba618002eba33e234908 100644 (file)
@@ -1,3 +1,10 @@
+---------------------------------------------------------------------------------------------------
+Version: 2.0.0
+Date: 2024-10-21
+
+  Changed:
+    - Initial compatibility with Factorio 2.0
+
 ---------------------------------------------------------------------------------------------------
 Version: 1.1.4
 Date: 2024-01-06
index 5758fbb2cdda53953e0e99e8661898947db06449..e34ea1c55a7a8ec732ee6efede4d9cfdba800704 100644 (file)
@@ -1,15 +1,13 @@
-function getConfig(force, config_changed)
-    if not global.auto_research_config then
-        global.auto_research_config = {}
+local auto_research_config = {}
 
-        -- Disable Research Queue popup
-        if remote.interfaces.RQ and remote.interfaces.RQ["popup"] then
-            remote.call("RQ", "popup", false)
-        end
+function getConfig(force, config_changed)
+    -- Disable Research Queue popup
+    if remote.interfaces.RQ and remote.interfaces.RQ["popup"] then
+        remote.call("RQ", "popup", false)
     end
 
-    if not global.auto_research_config[force.name] then
-        global.auto_research_config[force.name] = {
+    if not auto_research_config[force.name] then
+        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)
         }
@@ -27,27 +25,27 @@ function getConfig(force, config_changed)
     end
 
     -- set research strategy
-    global.auto_research_config[force.name].research_strategy = global.auto_research_config[force.name].research_strategy or "balanced"
+    auto_research_config[force.name].research_strategy = auto_research_config[force.name].research_strategy or "balanced"
 
-    if config_changed or not global.auto_research_config[force.name].allowed_ingredients or not global.auto_research_config[force.name].infinite_research then
+    if config_changed or not auto_research_config[force.name].allowed_ingredients or not auto_research_config[force.name].infinite_research then
         -- remember any old ingredients
         local old_ingredients = {}
-        if global.auto_research_config[force.name].allowed_ingredients then
-            for name, enabled in pairs(global.auto_research_config[force.name].allowed_ingredients) do
+        if auto_research_config[force.name].allowed_ingredients then
+            for name, enabled in pairs(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
-        global.auto_research_config[force.name].allowed_ingredients = {}
-        global.auto_research_config[force.name].infinite_research = {}
+        auto_research_config[force.name].allowed_ingredients = {}
+        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
-                global.auto_research_config[force.name].allowed_ingredients[ingredient.name] = (old_ingredients[ingredient.name] == nil or old_ingredients[ingredient.name])
+                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
-                global.auto_research_config[force.name].infinite_research[tech.name] = tech
+                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
@@ -56,11 +54,11 @@ function getConfig(force, config_changed)
             end
         end
         for techname, _ in pairs(finite_research) do
-            global.auto_research_config[force.name].infinite_research[techname] = nil
+            auto_research_config[force.name].infinite_research[techname] = nil
         end
     end
 
-    return global.auto_research_config[force.name]
+    return auto_research_config[force.name]
 end
 
 function setAutoResearch(force, enabled)
@@ -69,7 +67,6 @@ function setAutoResearch(force, enabled)
     end
     local config = getConfig(force)
     config.enabled = enabled
-    force.research_queue_enabled = not enabled
 
     if enabled then
         -- start new research
@@ -219,7 +216,15 @@ function startNextResearch(force, override_spam_detection)
     end
 
     if next_research then
-        force.add_research(next_research)
+        local rq = {}
+        table.insert(rq, next_research)
+
+        for i=1,6 do
+          if force.research_queue[i] == nil then break end
+          table.insert(rq, force.research_queue[i])
+        end
+
+        force.research_queue = rq
     end
 end
 
@@ -502,7 +507,7 @@ gui = {
                 }
             end
             local sprite = "auto_research_tool_" .. ingredientname
-            if not player.gui.is_valid_sprite_path(sprite) then
+            if not helpers.is_valid_sprite_path(sprite) then
                 sprite = "auto_research_unknown"
             end
             ingredientflow.add{type = "sprite-button", style = "auto_research_sprite_button_toggle" .. (allowed and "_pressed" or ""), name = "auto_research_allow_ingredient-" .. ingredientname, tooltip = {"item-name." .. ingredientname}, sprite = sprite}
@@ -533,7 +538,7 @@ gui = {
                     entryflow.add{type = "label", style = "auto_research_tech_label", caption = tech.localised_name}
                     for _, ingredient in pairs(tech.research_unit_ingredients) do
                         local sprite = "auto_research_tool_" .. ingredient.name
-                        if not player.gui.is_valid_sprite_path(sprite) then
+                        if not helpers.is_valid_sprite_path(sprite) then
                             sprite = "auto_research_unknown"
                         end
                         entryflow.add{type = "sprite", style = "auto_research_sprite", sprite = sprite}
@@ -659,7 +664,7 @@ gui = {
                     entryflow.add{type = "label", style = "auto_research_tech_label", name = name, caption = tech.localised_name}
                     for _, ingredient in pairs(tech.research_unit_ingredients) do
                         local sprite = "auto_research_tool_" .. ingredient.name
-                        if not player.gui.is_valid_sprite_path(sprite) then
+                        if not helpers.is_valid_sprite_path(sprite) then
                             sprite = "auto_research_unknown"
                         end
                         entryflow.add{type = "sprite", style = "auto_research_sprite", sprite = sprite}
index c565c7e72205a9111b9348de159dcc79988c9683..9993d3b0a553f476cec7226c8d94e3e00ed86ad3 100644 (file)
@@ -1,15 +1,15 @@
 -- dynamically add sprites for tools (to display research ingredients)
 for _, tool in pairs(data.raw.tool) do
-    if tool.icon or tool.icons then
+    if tool.icon then
         data:extend({
             {
                 type = "sprite",
                 name = "auto_research_tool_" .. tool.name,
-                filename = tool.icon or (tool.icons[1] and tool.icons[1].icon) or nil,
+                filename = tool.icon or nil,
                 priority = "extra-high-no-scale",
-                width = tool.icon_size or (tool.icons[1].icon_size) or 32,
-                height = tool.icon_size or (tool.icons[1].icon_size) or 32,
-                scale = 32/(tool.icon_size or (tool.icons[1].icon_size) or 32)
+                width = tool.icon_size or 64,
+                height = tool.icon_size or 64,
+                scale = 64/(tool.icon_size or 64)
             }
         })
     end
index e9d5b1c0fd3627292ebce6153cee3816a2df9bb4..1b0508fbc6f87aa8cb3afe172fe9a3fb14936619 100644 (file)
--- a/info.json
+++ b/info.json
@@ -1,13 +1,13 @@
 {
     "name": "some-autoresearch",
-    "version": "1.1.4",
+    "version": "2.0.0",
     "title": "Auto Research (fixed + re-published)",
     "author": "Someone (originally canidae)",
     "homepage": "https://git.somenet.org/factorio/some-autoresearch.git",
     "description": "Automates research. Toggle GUI with Shift+T (customizable).",
-    "factorio_version": "1.1",
+    "factorio_version": "2.0",
     "dependencies": [
-        "base>=1.1.0",
+        "base>=2.0.0",
 
       "! factorio-research-queue",
       "! sonaxaton-research-queue"
index b1c66cd8c8e662004c4bc15dffc598ea18284fed..20e2008e5e9b2fc985deacb05a78fd5e5d7446e4 100644 (file)
@@ -1,7 +1,7 @@
 data:extend({
     {
         type = "string-setting",
-        allow_blank = "true",
+        allow_blank = true,
         name = "queued-tech-setting",
         setting_type = "runtime-per-user",
         default_value = "",
@@ -9,7 +9,7 @@ data:extend({
     },
     {
         type = "string-setting",
-        allow_blank = "true",
+        allow_blank = true,
         name = "blacklisted-tech-setting",
         setting_type = "runtime-per-user",
         default_value = "",