Skip to content

Commit

Permalink
Merge branch 'combat_and_loaders' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
jodokus31 authored May 30, 2023
2 parents 2abfacc + 80d9298 commit d725ff4
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 5 deletions.
7 changes: 7 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
20 changes: 16 additions & 4 deletions control.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -325,21 +327,24 @@ 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,
force = entity.force,
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

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion info.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "autobuild",
"version": "0.5.5",
"version": "0.5.6",
"factorio_version": "1.1",
"title": "Autobuild",
"author": "Therax",
Expand Down
5 changes: 5 additions & 0 deletions locale/de/autobuild.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.


2 changes: 2 additions & 0 deletions locale/en/autobuild.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
9 changes: 9 additions & 0 deletions settings.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit d725ff4

Please sign in to comment.