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] 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