File tree Expand file tree Collapse file tree 2 files changed +12
-5
lines changed Expand file tree Collapse file tree 2 files changed +12
-5
lines changed Original file line number Diff line number Diff line change @@ -35,9 +35,11 @@ local origin = {0, 0}
3535-- issues because of the change to the behavior of entity prototype flags concerning automated interaction.
3636-- TODO: Open a new bug report for these issues once explored a bit more.
3737local limbo = setmetatable ({}, {
38- --- @param surface LuaSurface
38+ --- @param surface_index uint
3939 --- @return LuaEntity ?
40- __index = function (self , surface )
40+ __index = function (self , surface_index )
41+ local surface = game .surfaces [surface_index ]
42+ if not surface then return nil end
4143 local entity = surface .find_entity (" inventory-selector-limbo" , origin )
4244 if not entity then
4345 -- Any and all flags that can be set to make this entity as invisible and uninteractable as possible
@@ -56,10 +58,9 @@ local limbo = setmetatable({}, {
5658 entity .active = false
5759 end
5860 -- Cache the reference for future lookups
59- self [surface ] = entity
61+ self [surface_index ] = entity
6062 return entity
6163 end ,
62- __mode = " k" ,
6364})
6465
6566return limbo
Original file line number Diff line number Diff line change @@ -265,7 +265,7 @@ function selector:update_proxy_inventory()
265265
266266 :: limbo::
267267 -- The target wasn't valid for some reason, so just prepare a limbo container
268- target = limbo [proxy .surface ]
268+ target = limbo [proxy .surface_index ]
269269 index = inventory .get_inventory_info (target , " main" ) or defines .inventory .chest -- 1
270270
271271 :: assign::
@@ -826,6 +826,12 @@ local library = {
826826 on_load = register_tick_handlers ,
827827 --- @type table<defines.events , function>
828828 events = {
829+ [defines .events .on_surface_cleared ] = function (event )
830+ limbo [event .surface_index ] = nil
831+ end ,
832+ [defines .events .on_surface_deleted ] = function (event )
833+ limbo [event .surface_index ] = nil
834+ end ,
829835 [defines .events .on_object_destroyed ] = on_object_destroyed ,
830836 [defines .events .on_player_rotated_entity ] = on_entity_modified ,
831837 [defines .events .on_player_flipped_entity ] = on_entity_modified ,
You can’t perform that action at this time.
0 commit comments