Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

analyze_server.js uses depreciated command getServerRam() #10

Open
FrozenExecute opened this issue Feb 25, 2023 · 1 comment
Open

analyze_server.js uses depreciated command getServerRam() #10

FrozenExecute opened this issue Feb 25, 2023 · 1 comment

Comments

@FrozenExecute
Copy link

Needs to be replaced with getServerMaxRam and getServerUsedRam

@Forelius
Copy link

I use this.

export async function main(ns) {
    const args = ns.flags([["help", false]]);
    const server = ns.args[0];
    if (args.help || !server) {
        ns.tprint("This script does a more detailed analysis of a server.");
        ns.tprint(`Usage: run ${ns.getScriptName()} SERVER`);
        ns.tprint("Example:");
        ns.tprint(`> run ${ns.getScriptName()} n00dles`);
        return;
    }
    const maxram = ns.getServerMaxRam(server);
    const usedram = ns.getServerUsedRam(server);
    const money = ns.getServerMoneyAvailable(server);
    const maxMoney = ns.getServerMaxMoney(server);
    const minSec = ns.getServerMinSecurityLevel(server);
    const sec = ns.getServerSecurityLevel(server);
    ns.tprint(`

${server}:
    RAM        : ${usedram} / ${maxram} (${maxram / usedram * 100}%)
    $          : ${ns.nFormat(money, "$0.000a")} / ${ns.nFormat(maxMoney, "$0.000a")} (${(money / maxMoney * 100).toFixed(2)}%)
    security   : ${minSec.toFixed(2)} / ${sec.toFixed(2)}
    growth     : ${ns.getServerGrowth(server)}
    hack time  : ${ns.tFormat(ns.getHackTime(server))}
    grow time  : ${ns.tFormat(ns.getGrowTime(server))}
    weaken time: ${ns.tFormat(ns.getWeakenTime(server))}
    grow x2    : ${(ns.growthAnalyze(server, 2)).toFixed(2)} threads
    grow x3    : ${(ns.growthAnalyze(server, 3)).toFixed(2)} threads
    grow x4    : ${(ns.growthAnalyze(server, 4)).toFixed(2)} threads
    hack 10%   : ${(.10 / ns.hackAnalyze(server)).toFixed(2)} threads
    hack 25%   : ${(.25 / ns.hackAnalyze(server)).toFixed(2)} threads
    hack 50%   : ${(.50 / ns.hackAnalyze(server)).toFixed(2)} threads
    hackChance : ${(ns.hackAnalyzeChance(server) * 100).toFixed(2)}%
`);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants