Error while running event PersonalTransformer2::on_player_changed_surface (ID 54)
LuaEntity API call when LuaEntity was invalid.
stack traceback:
[C]: in function 'index'
__PersonalTransformer2/control.lua:637: in function 'remove_entity'
PersonalTransformer2/control.lua:827: in function 'equipmentRemoved'
PersonalTransformer2/control.lua:873: in function 'playerOrArmorChanged'
PersonalTransformer2/control.lua:287: in function <PersonalTransformer2/control.lua:283>
Problem is caused by Compact Circuits deleting the surface upon leaving, thereby destroying all entities.
Can be fixed by adding this to both for loops in remove_entity:
if (not entity.valid) then
table.remove(storage.transformer_data[grid_id].grid_transformer_entities, index)
elseif (entity.name == entity_input_name) then