Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /** @param {NS} ns */
- export async function main(ns) {
- const args = ns.flags([["help", false]]);
- let mem = args._[0];
- if (!mem || args.help) {
- ns.tprint("This script get the cost of a server at the specified RAM.");
- ns.tprint(`Usage: run ${ns.getScriptName()} MEMSIZE`);
- ns.tprint("Example:");
- ns.tprint(`> run ${ns.getScriptName()} 32`);
- return;
- }
- if (!ns.args[0]) {
- let str = "";
- let x = 1;
- while (x <= ns.getPurchasedServerMaxRam()) {
- str += x + ", ";
- x = x * 2;
- }
- ns.tprint("Valid sizes are - " + str);
- } else {
- ns.tprint("Server Cost: ", ns.getPurchasedServerCost(ns.args[0]).toLocaleString("en-US"));
- }
- }
- export function autocomplete(data, args) {
- return ["1", "2", "4", "8", "16", "32", "64", "128", "256", "512",
- "1024", "2048", "4096", "8192", "16384", "32768", "65536", "131072", "262144", "524288", "1048576"];
- }
Advertisement
Add Comment
Please, Sign In to add comment