hello, I am unfamiliar with factorio scripting, throwing the code into copilot resulted into the following (I am rephrasing)
the car1 tag search is a heavy process that is happening every tic, causing the performance issue
(in mission 1 before the start, if you type in the console something like:
c\ game.speed=8
you should be able to notice the slow down the moment the mission start
I replaces this from control.lua:
condition = function(event)
local cardead = game.surfaces[1].find_entities_filtered { name = "car", limit = 1 }[1]
if not cardead then game.set_game_state({ game_finished = true, player_won = false, can_continue = false }) end
return game.players[1].vehicle ~= nil and game.players[1].vehicle.energy == 0
end,
to this:
condition = function(event)
local car = storage.car1
if not (car and car.valid) then
game.set_game_state({ game_finished = true, player_won = false, can_continue = false })
end
local v = game.players[1].vehicle
return v ~= nil and v.energy == 0
end,
and it seems to fix it.
AI also suggested replacing it with a car die event instead but it's too confusing for me to understand right now.