restartScenario
Definition
-- @/lua/ge/extensions/scenario/scenarios.lua:1082
-- restarts the currently loaded scenario from the very start, unloading everything and loading everything again
-- important that this stays a reload and does not become an onload, since otherwise the reloading auto start bug happens again
local function restartScenario()
guihooks.trigger('ScenarioNotRunning')
displayEndUITimer = 0
endUIDisplayed = false
if not scenario then return end
scenario.state = nil
scenario.result = nil
scenario.vehicleTrackingTable = nil
scenario.playerIsDamaged = nil
scenario.playerHasStopped = nil
scenario.displayEndUIRefs = 0
scenario.stats = nil
scenario.lapConfig = deepcopy(scenario.initialLapConfig)
-- TODO(AK): This is such a bad approach. If you add a temp field and forget to delete it like those above, it persists to next try
-- We should just have pre-saved version of the scenario data when it is first loaded (clean slate) and deepCopy that one instead
-- of tweaking a used one with all sorts of modified state.
local tmp = deepcopy(scenario)
stop()
scenario = tmp
scenario.restartStage = 0
changeState('restart')
end
Callers
@/lua/ge/extensions/tech/techCore.lua
if not block('restartScenario', request, request['restrict_actions']) then return false end
scenario_scenarios.restartScenario()
else
@/lua/ge/extensions/scenario/scenarios.lua
log('D', logTag, 'uiEventRetry Triggered')
restartScenario()
prepareStartUI()
if not scenario then return end
restartScenario()
end