From d981002050492e62628069732cb72522bb04a410 Mon Sep 17 00:00:00 2001 From: jodokus31 <33641866+jodokus31@users.noreply.github.com> Date: Tue, 30 May 2023 18:37:50 +0200 Subject: [PATCH 1/2] Add setting to allow to build while in combat --- changelog.txt | 5 +++++ control.lua | 11 ++++++++++- info.json | 2 +- locale/de/autobuild.cfg | 7 +++++++ locale/en/autobuild.cfg | 2 ++ settings.lua | 9 +++++++++ 6 files changed, 34 insertions(+), 2 deletions(-) diff --git a/changelog.txt b/changelog.txt index 6184ba4..714664f 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,4 +1,9 @@ --------------------------------------------------------------------------------------------------- +Version: 0.5.6 +Date: 2023-05-30 + Changes: + - Add setting to allow Autobuild to keep building, even when in combat +--------------------------------------------------------------------------------------------------- Version: 0.5.5 Date: 2023-04-21 Changes: diff --git a/control.lua b/control.lua index df307a0..e78141b 100644 --- a/control.lua +++ b/control.lua @@ -18,6 +18,8 @@ local function get_player_state(player_index) state.enable_visual_area = settings.get_player_settings(player_index)["autobuild-enable-visual-area"].value state.visual_area_opacity = settings.get_player_settings(player_index)["autobuild-visual-area-opacity"].value state.ignore_other_robots = settings.get_player_settings(player_index)["autobuild-ignore-other-robots"].value + state.build_while_in_combat = settings.get_player_settings(player_index)["autobuild-build-while-in-combat"].value + state.last_successful_build_tick = 0 player_state[player_index] = state @@ -615,7 +617,10 @@ local function handle_player_update(player) return end - if player.in_combat then return end + if not state.build_while_in_combat and player.in_combat then + -- don't build while in combat only when setting is enabled + return + end if needs_recheck(player, state) then -- player has moved @@ -674,6 +679,10 @@ script.on_event(defines.events.on_runtime_mod_setting_changed, function(event) elseif event.setting == "autobuild-ignore-other-robots" then local state = get_player_state(event.player_index) state.ignore_other_robots = settings.get_player_settings(event.player_index)[event.setting].value + + elseif event.setting == "autobuild-build-while-in-combat" then + local state = get_player_state(event.player_index) + state.build_while_in_combat = settings.get_player_settings(event.player_index)[event.setting].value end diff --git a/info.json b/info.json index 5bb2b19..6bae110 100644 --- a/info.json +++ b/info.json @@ -1,6 +1,6 @@ { "name": "autobuild", - "version": "0.5.5", + "version": "0.5.6", "factorio_version": "1.1", "title": "Autobuild", "author": "Therax", diff --git a/locale/de/autobuild.cfg b/locale/de/autobuild.cfg index 4d90183..2e6150f 100644 --- a/locale/de/autobuild.cfg +++ b/locale/de/autobuild.cfg @@ -13,13 +13,17 @@ deconstruction-disabled=Automatische Dekonstruktion deaktiviert. tiles-enabled=Automatisches Konstruieren von Kacheln aktiviert. tiles-disabled=Automatisches Konstruieren von Kacheln deaktiviert. + [mod-setting-name] autobuild-cycle-length-in-ticks=Bauzykluslänge in Ticks autobuild-log-level=Debug-Log-Level autobuild-actions-per-cycle=Bauvorgänge pro Zyklus autobuild-idle-cycles-before-recheck=Leerlauf-Überprüfungs Zyklen +autobuild-enable-visual-area=Aktiviere den visuellen Bereich autobuild-visual-area-opacity=Deckkraft des visuellen Bereiches +autobuild-ignore-other-robots=Ignoriere andere Bots und baue alles selbst +autobuild-build-while-in-combat=Baue weiter trotz Kampfhandlungen [mod-setting-description] autobuild-cycle-length-in-ticks=Wie viele Ticks sind ein Bauzyklus. Erhöht die Anzahl der Konstruktionsaktionen. Könnte die Performance verschlechtern, wenn zu niedrig @@ -27,6 +31,9 @@ autobuild-log-level=Debug Log Level (0 nichts, 5 alles, oder werte dazwischen) autobuild-actions-per-cycle=Wie viele Bauvorgänge werden in einem Zyklus durchgeführt. Erhöht die Anzahl der Gesamtbau-Aktionen. Kann Performance verschlechtern, wenn zu hoch autobuild-idle-cycles-before-recheck=Anzahl der Zyklen, bis die Baubewerber neu berechnet werden, z. B. nach einer Konstruktionspause (5 Sek. ohne Bau), benötigt es max. diese Anzahl an Zyklen, um die Konstruktion fortzusetzen. Könnte unproduktive Performance verschlechtern, wenn zu niedrig +autobuild-enable-visual-area=Aktiviere den visuellen Bereich. Enable Visual building area. Den Haken rausnehmen, um den visuellen Bereich zu verstecken. autobuild-visual-area-opacity=Deckkraft des visuellen Bereiches +autobuild-ignore-other-robots=Respektiert nicht, dass Tasks einem Bot aus dem Netzwerk zugewiesen sind und baue trotzdem. +autobuild-build-while-in-combat=Aktiviere, wenn während Kampfhandlungen weiter gebaut werden soll. Anscheinend ist man auch im Kampfmodus, wenn man die Grapping Gun von SE verwendet hat. diff --git a/locale/en/autobuild.cfg b/locale/en/autobuild.cfg index b2a796e..90cf270 100644 --- a/locale/en/autobuild.cfg +++ b/locale/en/autobuild.cfg @@ -22,6 +22,7 @@ autobuild-idle-cycles-before-recheck=Idle recheck cycles autobuild-enable-visual-area=Enable Visual building area autobuild-visual-area-opacity=Visual area opacity autobuild-ignore-other-robots=Ignore other robots and build everything +autobuild-build-while-in-combat=Keep building while in combat [mod-setting-description] autobuild-cycle-length-in-ticks=How many ticks is one building cycle. Increases amount of overall building actions. Might tank performance, if too low @@ -32,3 +33,4 @@ autobuild-idle-cycles-before-recheck=Amount of cycles until building candidates autobuild-enable-visual-area=Enable Visual building area. Uncheck to hide visual building area autobuild-visual-area-opacity=Visual area opacity autobuild-ignore-other-robots=Do not respect tasks already assigned to other robots and build/deconstruct/upgrade anyway. +autobuild-build-while-in-combat=Enable, when you want to keep building, while in combat. Obviously, using the grappling gun from SE also counts as being in combat diff --git a/settings.lua b/settings.lua index 6e45833..a8f8a7a 100644 --- a/settings.lua +++ b/settings.lua @@ -63,6 +63,15 @@ table.insert(settings, default_value = false, }) +table.insert(settings, + { + type = "bool-setting", + name = "autobuild-build-while-in-combat", + order = "eb", + setting_type = "runtime-per-user", + default_value = false, + }) + table.insert(settings, { type = "int-setting", From 80d929888e3918d5830730c977025ce65d75afa8 Mon Sep 17 00:00:00 2001 From: jodokus31 <33641866+jodokus31@users.noreply.github.com> Date: Tue, 30 May 2023 19:17:50 +0200 Subject: [PATCH 2/2] Fix single tile loaders upgrade with belts --- changelog.txt | 2 ++ control.lua | 9 ++++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/changelog.txt b/changelog.txt index 714664f..f6251c8 100644 --- a/changelog.txt +++ b/changelog.txt @@ -3,6 +3,8 @@ Version: 0.5.6 Date: 2023-05-30 Changes: - Add setting to allow Autobuild to keep building, even when in combat + Bugfixes: + - Fix that belts can be upgraded with a single tile loaders or vice versa --------------------------------------------------------------------------------------------------- Version: 0.5.5 Date: 2023-04-21 diff --git a/control.lua b/control.lua index e78141b..3453c90 100644 --- a/control.lua +++ b/control.lua @@ -327,7 +327,7 @@ local function try_upgrade_with_stack(entity, target_name, player, stack_to_plac return false end - local entity = entity.surface.create_entity{ + local new_entity = entity.surface.create_entity{ name = target_name, position = entity.position, direction = entity.direction, @@ -335,13 +335,16 @@ local function try_upgrade_with_stack(entity, target_name, player, stack_to_plac fast_replace = true, player = player, type = entity.type:find("loader") and entity.loader_type or - entity.type == "underground-belt" and entity.belt_to_ground_type, + entity.type == "underground-belt" and entity.belt_to_ground_type or + nil, raise_built = true, } - if entity then + + if new_entity then player.remove_item(stack_to_place) return true end + return false end