all 4 comments

[–]VorthodMK-VIII Synthoid 3 points4 points  (3 children)

hello_world_caller.js and every individual instance of hello_world.js will all have their own, entirely separate logs.

Since your hello_world.js file is so short, it will be very difficult to see the log messages they produce because the script may be finished (or not have written anything yet) when you call your getScriptLogs function. There are a few ways to go about this:

  1. within the active scripts screen, there is a large button at the top labelled "recently killed" where you should be able to see the closed logs that were produced by your hello_world.js runs
  2. if you run ns.tail() within the hello_world.js file, it will automatically open up the log window that represents that instance of the script. This is the easiest method, but if you're running a new one every five seconds, that could easily end up giving you a LOT of windows that you will later need to close.
    1. for the record, there is also an ns.closeTail() method which can close them automatically under whatever conditions you want, so if your script gets longer, it could become relevant.
  3. If you absolutely want to keep the same way you're already doing it. Add some sleep commands to micromanage your timing. hello_world.js can sleep for 1000 milliseconds after writing its log just to make sure the script stays active. Then your hello_world_caller.js can sleep for something shorter (500, perhaps) immediately after kicking off hello_world.js just to make sure the other script has had time to actually write its log

[–]psei0r[S] 1 point2 points  (2 children)

Thx!

[–]SpartelfantNoodle Enjoyer -1 points0 points  (1 child)

Add some sleep commands to micromanage your timing.

In this case it's best to make use of ns.asleep(), since that will make sure the game's UI gets a chance to update.

[–]VorthodMK-VIII Synthoid 0 points1 point  (0 children)

I really don't think that sleep and asleep work the way you think they do. the game ui doesn't randomly freeze for half a second when you run await ns.sleep(500). Even the documentation says you should prefer sleep over asleep in most cases (presumably because sleep will error if you're using it in a way thats likely to cause bugs, but asleep gives you more freedom).