diff --git a/features/redmew_qol.lua b/features/redmew_qol.lua index b6d6475c..77f29a60 100644 --- a/features/redmew_qol.lua +++ b/features/redmew_qol.lua @@ -37,7 +37,7 @@ local random_train_color = Token.register( function(event) local entity = event.created_entity - if entity and entity.name == 'locomotive' then + if entity and entity.valid and entity.name == 'locomotive' then entity.color = Utils.random_RGB() end end @@ -56,7 +56,7 @@ local restrict_chest = Token.register( function(event) local entity = event.created_entity - if entity and (entity.name == 'logistic-chest-passive-provider' or entity.type == 'container') then + if entity and entity.valid and (entity.name == 'logistic-chest-passive-provider' or entity.type == 'container') then local chest_inventory = entity.get_inventory(defines.inventory.chest) if #chest_inventory + 1 == chest_inventory.getbar() then chest_inventory.setbar(2) @@ -93,7 +93,7 @@ local change_backer_name = Token.register( function(event) local entity = event.created_entity - if entity and entity.backer_name then + if entity and entity.valid and entity.backer_name then entity.backer_name = pick_name() or entity.backer_name end end