-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathimport.js
57 lines (53 loc) · 1.46 KB
/
import.js
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
let config = {
folder: 'scripts',
rootUrl: 'https://raw.githubusercontent.com/ChaelCodes/bitburner-scripts/main/',
serverPrefix: 'ChaelPwns',
};
/*
* This will import all files listed in importFiles.
*/
export async function main(ns) {
let filesImported = await importFiles(ns);
ns.tprint('='.repeat(20));
if (filesImported) {
ns.tprint('Hey! Thank you for downloading the BitBurner Scripts.');
ns.tprint(`You've installed these in the ${config.folder} directory.`);
ns.tprint(
`A good place to start is running \`run /${config.folder}/hax.js\``
);
} else {
ns.tprint(
'You had some issues downloading files, please reach out to the repo maintainer or check your config.'
);
}
}
async function importFiles(ns) {
let files = [
'autoHack.js',
'autoRemoteHack.js',
'buyHacknet.js',
'dashboard.js',
'hack.js',
'hax.js',
'purchaseServers.js',
'remoteHack.js',
'serverStatus.js',
];
let filesImported = true;
for (let file of files) {
let remoteFileName = `${config.rootUrl}scripts/${file}`;
let result = await ns.wget(remoteFileName, `/${getFolder()}/${file}`);
filesImported = filesImported && result;
ns.tprint(`File: ${file}: ${result ? '✔️' : '❌'}`);
}
return filesImported;
}
export function getFolder() {
return config.folder;
}
export function getServerPrefix() {
return config.serverPrefix;
}
export function getHackScript() {
return `/${getFolder()}/hack.js`;
}