Bitburner

Bitburner

Zobrazit statistiky:
Questions about active scripts
I don't have much experience with JavaScript, just Python and C# so I don't know how they behave in comparison with other programming languages so I have two questions pertaining to this game:

1) If I have a for loop or a while loop executing in an active script, when that loop ends and there are no other executable statements following, will the active script end or will it restart from the first statement as before?

2) Do active Javascripts restart when I save and close the game?

Thanks.
Původně napsal Ragnaman:
when game is not running, scripts do not run, the game approximates gain of exp/money by observing exp/gain while the game runs.

Things like hacknet, faction rep gain, and approx money from hack() you will get while game is not running. But some complex automation shenanigans like starting and restarting scripts will simply not run.

So its good to let your scripts run for a while so you get some approx money/second values going and do faction work, and save, before shutting game down for the night.
< >
Zobrazeno 12 z 2 komentářů
Tento příspěvek byl autorem tématu označen jako nejlepší.
when game is not running, scripts do not run, the game approximates gain of exp/money by observing exp/gain while the game runs.

Things like hacknet, faction rep gain, and approx money from hack() you will get while game is not running. But some complex automation shenanigans like starting and restarting scripts will simply not run.

So its good to let your scripts run for a while so you get some approx money/second values going and do faction work, and save, before shutting game down for the night.
Naposledy upravil Ragnaman; 3. dub. 2024 v 6.08
As for (1)

usually people have a while true loop, you can exit such a loop with ns.exit()
of course not all scripts need such, but for example i have a setup.js script that runs on home permanently with a while(true) loop that checks various values of ns.getPlayer() periodically and kills/starts other scripts with ns.killall() and ns.exec().

such a script would do nothing while game is not running.

while(true) { *your code* await ns.asleep(1000) //sleep in milliseconds just for safety :p }
Naposledy upravil Ragnaman; 3. dub. 2024 v 6.09
< >
Zobrazeno 12 z 2 komentářů
Na stránku: 1530 50