-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathreset.js
More file actions
40 lines (35 loc) · 981 Bytes
/
reset.js
File metadata and controls
40 lines (35 loc) · 981 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/** @param {NS} ns **/
export async function main(ns) {
ns.tprint('Starting reset')
ns.scriptKill('master.js', 'home')
if (ns.scriptRunning('w.js', 'home')) {
ns.tprint('Waiting all w.js exit')
}
while (ns.scriptRunning('w.js', 'home')) {
await ns.asleep(1000)
}
ns.tprint('Getting servers')
ns.run('worm.js')
await ns.sleep(1000)
ns.tprint('Calc servers performance')
var servers = ns.read('rooted.txt').split(',')
for (const server of servers) {
ns.run('getMax.js', 1, server, 'reset')
await ns.scp('h.js', 'home', server)
await ns.scp('g.js', 'home', server)
await ns.scp('w.js', 'home', server)
}
await ns.asleep(1000)
ns.tprint('Ranking servers')
ns.run('best.js', 1, 'reset')
await ns.asleep(1000)
ns.tprint('Init servers')
ns.run('init.js', 1, 'best', 'reset')
while (ns.scriptRunning('init.js', 'home')) {
await ns.asleep(1000)
}
ns.tprint('Start master.js to farm')
ns.run('master.js')
await ns.asleep(10000)
ns.run('best.js')
}