You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Player scripts invoked on startup (either because their running state is part of the save, or they are set as the startup script) can run before the game is fully initialized, and this can lead to an error if one of them triggers routing.
Normally, this error silently goes unnoticed (because the game's error handling isn't in place yet?), so the end-result is that the script that should have run on startup crashes and appears to have not run.
If the user script has any kind of error-handling though, they would catch an error like this:
Here's a sample script that can be used to reproduce the error fairly reliably just by running it, saving, then refreshing the game:
exportasyncfunctionmain(ns){try{ns.singularity.workForFaction("Tian Di Hui","hacking");while(true)awaitns.sleep(10000);}catch(err){ns.tprint("ERROR: An unexpected error occurred and now this script must terminate:\n"+(`${err.message}\n${err.stack}`??err))}}
You might have to update the faction to one you've joined.
As discussed, some possible solutions are:
Don't start any user scripts until after the game is done initializing (speed runners might be mad)
Just for the handful of singularity scripts which route, wrap the attempt to route in a try/catch. You can then either:
ignore the attempt to route and move on (might have weird side-effects e.g. relating to focus penalties)
Store the route destination in a variable, and once the UI is initialized, fulfill the route request ASAP. If multiple route-attempts occur, just save the most recent one? (I can only imagine this messing with scripts that try to interact with the UI, like auto-infiltration)
The text was updated successfully, but these errors were encountered:
Additional context: This same error is what causes several of our tests to be flaky. If the game takes long enough to load, it can crash with this error (even the production game, if it takes super long and hits the right weird circumstances - I saw it happen once).
We really ought to fix this at the source (somehow).
Just capturing what's been discussed in Discord.
Player scripts invoked on startup (either because their running state is part of the save, or they are set as the startup script) can run before the game is fully initialized, and this can lead to an error if one of them triggers routing.
Normally, this error silently goes unnoticed (because the game's error handling isn't in place yet?), so the end-result is that the script that should have run on startup crashes and appears to have not run.
If the user script has any kind of error-handling though, they would catch an error like this:
Here's a sample script that can be used to reproduce the error fairly reliably just by running it, saving, then refreshing the game:
You might have to update the faction to one you've joined.
As discussed, some possible solutions are:
The text was updated successfully, but these errors were encountered: