mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-19 07:48:37 +02:00
EDITOR: Improved infinite loop checking (#1276)
This commit is contained in:
@@ -62,6 +62,21 @@ For example, if a script run with 1 thread is able to hack \$10,000, then runnin
|
||||
|
||||
When "multithreading" a script, the total [RAM](ram.md) cost can be calculated by simply multiplying the [RAM](ram.md) cost of a single instance of your script by the number of threads you will use. [See [`ns.getScriptRam()`](https://github.com/bitburner-official/bitburner-src/blob/bec737a25307be29c7efef147fc31effca65eedc/markdown/bitburner.ns.getscriptram.md) or the `mem` terminal command detailed below]
|
||||
|
||||
## Never-ending scripts
|
||||
|
||||
Sometimes it might be necessary for a script to never end and keep doing a particular task.
|
||||
In that case you would want to write your script in a never-ending loop, like `while (true)`.
|
||||
|
||||
However, if you are not careful, this can crash your game.
|
||||
If the code inside the loop doesn't `await` for some time, it will never give other scripts and the game itself time to process.
|
||||
|
||||
<br />
|
||||
|
||||
To help you find this potential bug, any `while (true)` loop without any `await` statement inside it will be marked.
|
||||
A red decoration will appear on the left side of the script editor, telling you about the issue.
|
||||
|
||||
If you are really sure that this is not an oversight, you can suppress the warning using the comment `// @ignore-infinite` directly above the loop.
|
||||
|
||||
## Working with Scripts in Terminal
|
||||
|
||||
Here are some [terminal](terminal.md) commands you will find useful when working with scripts:
|
||||
|
||||
Reference in New Issue
Block a user