Skip to content

Commit

Permalink
fix: Fixed a crash when moving between surfaces in remote view with a…
Browse files Browse the repository at this point in the history
… spidertron remote held and that remote refrences now mined submarines.
  • Loading branch information
notnotmelon committed Dec 14, 2024
1 parent 7be5791 commit 996e32f
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions scripts/submarine.lua
Original file line number Diff line number Diff line change
Expand Up @@ -218,9 +218,18 @@ local function decend_or_ascend(submarine)
return true
end

local function clean_array_of_invalid_luaobjects(array)
local new_table = {}
for k, v in pairs(array) do
if v.valid then table.insert(new_table, v) end
end
return new_table
end

maraxsis.on_event(defines.events.on_player_changed_surface, function(event)
local spidertrons = storage.previous_spidertron_remote_selection[event.player_index]
if not spidertrons then return end
spidertrons = clean_array_of_invalid_luaobjects(spidertrons)
local player = game.get_player(event.player_index)
local cursor_stack = player.cursor_stack
if not cursor_stack or not cursor_stack.valid_for_read then return end
Expand Down

0 comments on commit 996e32f

Please sign in to comment.