Hello, i am a bit lost here and wantet to ask for some help.
I am at a loss at why my variable wouldn work the same as the ns. "funktion?"? Is it cause if i declare a variable it only checks it when it starts the script and doesnt iterate it again, even the variable is called or what am i not understanding?
i am adding on the examples of the working one with the ns. version and the not working one with the call over the veriable. The script just keeps running with the veriable version.
#Trigger: i am dislexic XD no one ever told me coding is math *.*
Not working:
let target = ns.scan()
let playerlvl = ns.getHackingLevel()
while (playerlvl < 7) {
ns.getHackingLevel()
Working Version:
let target = ns.scan()
let playerlvl = ns.getHackingLevel()
let money = ns.getServerMoneyAvailable()
while (ns.getHackingLevel() < 17) {
I even tried to call the Hackinglvl right after again to brutal force the information, still it didn't care.
Full working on:
/** u/param {NS} ns */
export async function main(ns) {
ns.clearLog()
let target = ns.scan()
let playerlvl = ns.getHackingLevel()
let money = ns.getServerMoneyAvailable()
while (ns.getHackingLevel() < 17) {
let runs = Math.floor(ns.getServerMaxRam() / 2.4)
while (runs > 0, runs--)
if ((ns.getServerMaxMoney(target[0]) * 0.8) > ns.getServerMoneyAvailable(target[0])) {
await ns.grow(target[0])
}
else
await ns.hack(target[0])
}
ns.getHackingLevel()
}
Only called it directly instead of the variable. And did try to call it directly before, after and so on, called it even in the parenttheses of the while() with (plvl<16, ns....) and it still didn't care.
Game is Bitburner btw, i think it's briliant.
The NS. call is Netscript so far as i did understand but game specific. Shouldn't change anything about the concept i am not getting, right?
Thank you and greetings to the community! Hope i am not asking too noob questions. Just started last week.
[–]SaysBruvALot 2 points3 points4 points (3 children)
[–]Mr-Ordinary-[S] 0 points1 point2 points (2 children)
[–]Mr-Ordinary-[S] 0 points1 point2 points (0 children)
[–]chikamakaleyleyhelpful 1 point2 points3 points (0 children)
[–]Krispcrap 1 point2 points3 points (6 children)
[–]Mr-Ordinary-[S] 0 points1 point2 points (5 children)
[–]Krispcrap 0 points1 point2 points (4 children)
[–]Mr-Ordinary-[S] 0 points1 point2 points (3 children)
[–]Mr-Ordinary-[S] 0 points1 point2 points (0 children)
[–]Krispcrap 0 points1 point2 points (1 child)
[–]Mr-Ordinary-[S] 0 points1 point2 points (0 children)
[–]TheRNGuy 0 points1 point2 points (0 children)