diff --git a/changelog.txt b/changelog.txt index 6184ba4..f6251c8 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,4 +1,11 @@ --------------------------------------------------------------------------------------------------- +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 Changes: diff --git a/control.lua b/control.lua index df307a0..3453c90 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 @@ -325,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, @@ -333,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 @@ -615,7 +620,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 +682,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 52a07dd..ebcafce 100644 --- a/locale/de/autobuild.cfg +++ b/locale/de/autobuild.cfg @@ -13,14 +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=Andere Roboter ignorieren und alles bauen +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 @@ -30,5 +33,7 @@ autobuild-actions-per-cycle=Wie viele Bauvorgänge werden in einem Zyklus durchg 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=Visuellen Baubereich aktivieren. Deaktivieren um den visuellen Baubereich zu verbergen 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",