Skip to content

Instantly share code, notes, and snippets.

@JasonMadeSomething
Created February 27, 2022 22:06
Show Gist options
  • Save JasonMadeSomething/c4d4261a2338b5947840878f4995c535 to your computer and use it in GitHub Desktop.
Save JasonMadeSomething/c4d4261a2338b5947840878f4995c535 to your computer and use it in GitHub Desktop.
/** @param {NS} ns **/
export async function main(ns) {
const playerServers = ns.getPurchasedServers()
const ret = []
for (let i = 0; i < playerServers.length; i++) {
ret.push({
servername: playerServers[i],
ram: ns.getPurchasedServerMaxRam(playerServers[i]),
cost: ns.getPurchasedServerCost(ns.getPurchasedServerMaxRam(playerServers[i]))
})
}
for (let i = 0; i < ret.length; i++) {
const ram_output = ns.nFormat(ret[i].ram * 1000000, '0.00b')
const cost_output = ns.nFormat(ret[i].cost, '($ 0.00 a)')
const name_output = ret[i].servername
ns.tprint(`Server Name: ${name_output}, RAM: ${ram_output}, Cost: ${cost_output}\n`)
}
}
/** @param {NS} ns **/
export async function main(ns) {
const playerServers = ns.getPurchasedServers()
const ret = []
for (let i = 0; i < playerServers.length; i++) {
ret.push({
servername: playerServers[i],
ram: ns.getPurchasedServerMaxRam(playerServers[i]),
cost: ns.getPurchasedServerCost(ns.getPurchasedServerMaxRam(playerServers[i]))
})
}
for (let i = 0; i < ret.length; i++) {
const ram_output = ret[i].ram
const cost_output = ret[i].cost
const name_output = ret[i].servername
ns.tprint(`Server Name: ${name_output}, RAM: ${ram_output}, Cost: ${cost_output}\n`)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment