DOCUMENTATION: Update tutorial script for buying cloud servers (#2653)

This commit is contained in:
catloversg
2026-04-13 07:05:56 +07:00
committed by GitHub
parent cc9144c01b
commit 9ab3e0bcb4
2 changed files with 10 additions and 11 deletions
@@ -33,12 +33,12 @@ Adding a sleep like in the first example, or changing the code so that the `awai
Common infinite loop when translating the server purchasing script in starting guide to scripts is to have a while loop, where the condition's change is conditional:
var ram = 8;
var i = 0;
const ram = 8;
let i = ns.cloud.getServerNames().length;
while (i < ns.cloud.getServerLimit()) {
if (ns.getServerMoneyAvailable("home") > ns.cloud.getRamLimit(ram)) {
var hostname = ns.cloud.purchaseServer("cloud-server-" + i, ram);
const hostname = ns.cloud.purchaseServer("cloud-server-" + i, ram);
ns.scp("early-hack-template.js", hostname);
ns.exec("early-hack-template.js", hostname, 3);
++i;