1
0
mirror of https://github.com/Refactorio/RedMew.git synced 2025-01-18 03:21:47 +02:00

Merge pull request #653 from plague006/fix/qol

Check that entities are valid in redmew_qol
This commit is contained in:
Matthew 2019-01-15 09:52:13 -05:00 committed by GitHub
commit 934adaa9f6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

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