1
0
mirror of https://github.com/Refactorio/RedMew.git synced 2024-12-12 10:04:40 +02:00

Check that entities are valid

This commit is contained in:
Matthew Heguy 2019-01-14 17:25:14 -05:00
parent f062c53868
commit 229e3e7f25

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