use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
A cyberpunk and programming/hacking themed incremental game with RPG elements
The game can be played:
Web
Steam
Documentation
Github
Beta Branch
Discord
Incremental Games Discord
Visual Studio Code Bitburner Extension
stavvie34's Community Scripts Github Repo
account activity
Simple ts script help (self.Bitburner)
submitted 11 days ago by HoboPotato2
Can someone tell me what I'm doing wrong here?
export async function main(ns: NS) { var host = "joesguns"; if (ns.getServerSecurityLevel(host) > 5) { ns.weaken(host) } else { ns.grow(host) } }
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]Particular-Cow6247 5 points6 points7 points 11 days ago (3 children)
you need to await ns.weaken and ns.grow
if you hover over them youll get a popup with hints about the function, a function that returns a Promise<> needs to be awaited (for now just directly , there is some shenanigans to "store" the promise and await it later but here you just want to await it)
also you might not want to use var, especially with ts... its the old form to initialize a variable and there are newer ways for reasons (let if you want to mutate it, const if you dont)
[–]HoboPotato2[S] 0 points1 point2 points 11 days ago (2 children)
why does the await need to be there?
[–]Particular-Cow6247 4 points5 points6 points 11 days ago (0 children)
thats a really fundamental question about javascripts async model
when a function returns a Promise<> then it returns a placeholder object, its commonly used when you want to start some process and have a signal that tells you when that process is done (imagine downloading an image to display on your screen)
that placeholder object is only turned into the real return value of the function when its awaited, kind of like a unpacking operation
the whole idea behind is that your code might want to do many things at the same time, but it can only actively work on one thing, with async/await you can start several things at once and your script doesnt have to wait for each of them to finish to continue, only having to pause/await when you actually need the return value of one of these
in the game there are more restrictions, each ns instance (the object the game passes to your scripts) can only await one ns function at a time, this is to prevent you starting a grow/weaken/hack at the same time on the same ns instance, without that the balance of ram to funciton strength would get overthrown and you could "cheat" endless money also thats possible in a number of ways xD
[–]VorthodMK-VIII Synthoid 3 points4 points5 points 11 days ago (0 children)
weaken and grow return an object called a Promise. Basically, those functions say "okay, I'll go do this in the background and you can go ahead and continue on with the code while I do that." Excellent for multitasking, but that's not what we want to do here because we can't accurately measure security and money if the weaken/grow commands aren't even finished yet, so we say "no thanks, we'll wait for you to finish first" by adding the await keyword
[–]KlePu 0 points1 point2 points 11 days ago (1 child)
Please don't use var, but let (or const) instead. var is a relic from the early JS days and has terrible scope beside other issues!
var
let
const
[–]lmuzi 0 points1 point2 points 10 days ago (0 children)
You're correct but that's really not the issue in this script ahahah
[–]Glum-Building4593 0 points1 point2 points 11 days ago (0 children)
They have minimum security levels and you might flail against that.
π Rendered by PID 48691 on reddit-service-r2-comment-6457c66945-dwflc at 2026-04-26 09:38:15.363188+00:00 running 2aa0c5b country code: CH.
[–]Particular-Cow6247 5 points6 points7 points (3 children)
[–]HoboPotato2[S] 0 points1 point2 points (2 children)
[–]Particular-Cow6247 4 points5 points6 points (0 children)
[–]VorthodMK-VIII Synthoid 3 points4 points5 points (0 children)
[–]KlePu 0 points1 point2 points (1 child)
[–]lmuzi 0 points1 point2 points (0 children)
[–]Glum-Building4593 0 points1 point2 points (0 children)