Skip to content

Commit

Permalink
Remove deprecated references to singularity functions not in the sing…
Browse files Browse the repository at this point in the history
…ularity namespace
  • Loading branch information
alainbryden committed Jul 23, 2022
1 parent 3efd2ca commit e9cceb5
Show file tree
Hide file tree
Showing 18 changed files with 75 additions and 75 deletions.
2 changes: 1 addition & 1 deletion Remote/manualhack-target.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export async function main(ns) {
if (sleepDuration > 0)
await ns.sleep(sleepDuration);
do {
if (!await ns.manualHack() && !disableToastWarnings)
if (!await ns.singularity.manualHack() && !disableToastWarnings)
ns.toast(`Warning, hack stole 0 money. Might be a misfire. ${JSON.stringify(ns.args)}`, 'warning');
if (loop) await ns.sleep(cycleTime - expectedDuration);
} while (loop);
Expand Down
6 changes: 3 additions & 3 deletions Tasks/backdoor-all-servers.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export let main = async ns => {
ns.print(`Hopping to ${server}`);
anyConnected = true;
for (let hop of routes[server])
ns.connect(hop);
ns.singularity.connect(hop);
if (server === "w0r1d_d43m0n") {
ns.alert("Ready to hack w0r1d_d43m0n!");
while (true) await ns.sleep(10000); // Sleep forever so the script isn't run multiple times to create multiple overlapping alerts
Expand All @@ -50,12 +50,12 @@ export let main = async ns => {
if (pid === 0)
return ns.print(`Couldn't initiate a new backdoor of "${server}"" (insufficient RAM?). Will try again later.`);
await ns.sleep(spawnDelay); // Wait some time for the external backdoor script to initiate its backdoor of the current connected server
ns.connect("home");
ns.singularity.connect("home");
}
} catch (err) {
ns.tprint(String(err));
} finally {
if (anyConnected)
ns.connect("home");
ns.singularity.connect("home");
}
};
2 changes: 1 addition & 1 deletion Tasks/backdoor-all-servers.js.backdoor-one.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
export async function main(ns) {
let target = ns.args.length > 0 ? ns.args[0] : '(unspecified server)';
try {
await ns.installBackdoor();
await ns.singularity.installBackdoor();
ns.toast(`Backdoored ${target}`, 'success');
}
catch (err) {
Expand Down
2 changes: 1 addition & 1 deletion Tasks/program-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export async function main(ns) {
do {
let foundMissingProgram = false;
for (const prog of programNames) {
if (!ns.fileExists(prog, "home") && ns.purchaseProgram(prog))
if (!ns.fileExists(prog, "home") && ns.singularity.purchaseProgram(prog))
ns.toast(`Purchased ${prog}`, 'success');
else if (keepRunning)
foundMissingProgram = true;
Expand Down
6 changes: 3 additions & 3 deletions Tasks/ram-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ export async function main(ns) {
return log(ns, `ERROR: One of the arguments could not be parsed as a number: ${JSON.stringify(options)}`, true, 'error');
// Quickly buy as many upgrades as we can within the budget
do {
let cost = await getNsDataThroughFile(ns, `ns.getUpgradeHomeRamCost()`, `/Temp/getUpgradeHomeRamCost.txt`);
let currentRam = await getNsDataThroughFile(ns, `ns.getServerMaxRam(ns.args[0])`, `/Temp/getServerMaxRam.txt`, ["home"]);
let cost = await getNsDataThroughFile(ns, `ns.singularity.getUpgradeHomeRamCost()`, `/Temp/getUpgradeHomeRamCost.txt`);
let currentRam = await getNsDataThroughFile(ns, `ns.singularity.getServerMaxRam(ns.args[0])`, `/Temp/getServerMaxRam.txt`, ["home"]);
if (cost >= Number.MAX_VALUE || currentRam == max_ram)
return log(ns, `INFO: We're at max home RAM (${formatRam(currentRam)})`);
const nextRam = currentRam * 2;
const upgradeDesc = `home RAM from ${formatRam(currentRam)} to ${formatRam(nextRam)}`;
if (spendable < cost)
return log(ns, `Money we're allowed to spend (${formatMoney(spendable)}) is less than the cost (${formatMoney(cost)}) to upgrade ${upgradeDesc}`);
if (!(await getNsDataThroughFile(ns, `ns.upgradeHomeRam()`, `/Temp/upgradeHomeRam.txt`)))
if (!(await getNsDataThroughFile(ns, `ns.singularity.upgradeHomeRam()`, `/Temp/upgradeHomeRam.txt`)))
return log(ns, `ERROR: Failed to upgrade ${upgradeDesc} thinking we could afford it ` +
`(cost: ${formatMoney(cost)} cash: ${formatMoney(money)} budget: ${formatMoney(spendable)})`, true, 'error');
// Otherwise, we've successfully upgraded home ram.
Expand Down
2 changes: 1 addition & 1 deletion Tasks/tor-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export async function main(ns) {
ns.toast(`Purchased the Tor router!`, 'success');
break;
}
ns.purchaseTor();
ns.singularity.purchaseTor();
if (keepRunning)
await ns.sleep(interval);
}
Expand Down
16 changes: 8 additions & 8 deletions ascend.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export async function main(ns) {
await waitForProcessToComplete(ns, pid, true); // Wait for the script to shut down, indicating it has shut down other scripts

// Stop the current action so that we're no longer spending money (if training) and can collect rep earned (if working)
await getNsDataThroughFile(ns, 'ns.stopAction()', '/Temp/stop-player-action.txt');
await getNsDataThroughFile(ns, 'ns.singularity.stopAction()', '/Temp/stop-player-action.txt');

// Clear any global reserve so that all money can be spent
await ns.write(getFilePath('reserve.txt'), '0', "w");
Expand Down Expand Up @@ -84,8 +84,8 @@ export async function main(ns) {

// Sanity check, if we are not slated to install any augmentations, ABORT
// Get owned + purchased augmentations, then installed augmentations. Ensure there's a difference
let purchasedAugmentations = await getNsDataThroughFile(ns, 'ns.getOwnedAugmentations(true)', '/Temp/player-augs-purchased.txt');
let installedAugmentations = await getNsDataThroughFile(ns, 'ns.getOwnedAugmentations()', '/Temp/player-augs-installed.txt');
let purchasedAugmentations = await getNsDataThroughFile(ns, 'ns.singularity.getOwnedAugmentations(true)', '/Temp/player-augs-purchased.txt');
let installedAugmentations = await getNsDataThroughFile(ns, 'ns.singularity.getOwnedAugmentations()', '/Temp/player-augs-installed.txt');
let noAugsToInstall = purchasedAugmentations.length == installedAugmentations.length;
if (noAugsToInstall && !options['allow-soft-reset'])
return log(ns, `ERROR: See above faction-manager.js logs - there are no new purchased augs. ` +
Expand Down Expand Up @@ -117,13 +117,13 @@ export async function main(ns) {

// STEP 7: Buy whatever home CPU upgrades we can afford
log(ns, 'Try Upgrade Home Cores...', true, 'info');
pid = await runCommand(ns, `while(ns.upgradeHomeCores()); { await ns.sleep(10); }`, '/Temp/upgrade-home-ram.js');
pid = await runCommand(ns, `while(ns.singularity.upgradeHomeCores()); { await ns.sleep(10); }`, '/Temp/upgrade-home-ram.js');
await waitForProcessToComplete(ns, pid, true); // Wait for the script to shut down, indicating it has bought all it can.

// STEP 8: Join every faction we've been invited to (gives a little INT XP)
let invites = await getNsDataThroughFile(ns, 'ns.checkFactionInvitations()', '/Temp/faction-invitations.txt');
let invites = await getNsDataThroughFile(ns, 'ns.singularity.checkFactionInvitations()', '/Temp/faction-invitations.txt');
if (invites.length > 0) {
pid = await runCommand(ns, 'ns.args.forEach(f => ns.joinFaction(f))', '/Temp/join-factions.js', invites);
pid = await runCommand(ns, 'ns.args.forEach(f => ns.singularity.joinFaction(f))', '/Temp/join-factions.js', invites);
await waitForProcessToComplete(ns, pid, true);
}

Expand Down Expand Up @@ -160,9 +160,9 @@ export async function main(ns) {
// Default script (if none is specified) is stanek.js if we have it (which in turn will spawn daemon.js when done)
(purchasedAugmentations.includes(`Stanek's Gift - Genesis`) ? getFilePath('stanek.js') : getFilePath('daemon.js'));
if (noAugsToInstall)
await runCommand(ns, `ns.softReset(ns.args[0])`, '/Temp/soft-reset.js', [resetScript]);
await runCommand(ns, `ns.singularity.softReset(ns.args[0])`, '/Temp/soft-reset.js', [resetScript]);
else
await runCommand(ns, `ns.installAugmentations(ns.args[0])`, '/Temp/install-augmentations.js', [resetScript]);
await runCommand(ns, `ns.singularity.installAugmentations(ns.args[0])`, '/Temp/install-augmentations.js', [resetScript]);
} else
log(ns, `SUCCESS: Ready to ascend. In the future, you can run with --reset (or --install-augmentations) ` +
`to actually perform the reset automatically.`, true, 'success');
Expand Down
8 changes: 4 additions & 4 deletions autopilot.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ async function startUp(ns) {
unlockedSFs = await getActiveSourceFiles(ns, true);
try {
installedAugmentations = !(4 in unlockedSFs) ? [] :
await getNsDataThroughFile(ns, 'ns.getOwnedAugmentations()', '/Temp/player-augs-installed.txt');
await getNsDataThroughFile(ns, 'ns.singularity.getOwnedAugmentations()', '/Temp/player-augs-installed.txt');
if (!(4 in unlockedSFs))
log(ns, `WARNING: This script requires SF4 (singularity) functions to assess purchasable augmentations ascend automatically. ` +
`Some functionality will be diabled and you'll have to manage working for factions, purchasing, and installing augmentations yourself.`, true);
Expand Down Expand Up @@ -176,7 +176,7 @@ async function checkOnDaedalusStatus(ns, player, stocksValue) {
return reserveForDaedalus = false;
}
if (reserveForDaedalus) { // Already waiting for a Daedalus invite, try joining them
return (4 in unlockedSFs) ? await getNsDataThroughFile(ns, 'ns.joinFaction(ns.args[0])', '/Temp/joinFaction.txt', ["Daedalus"]) :
return (4 in unlockedSFs) ? await getNsDataThroughFile(ns, 'ns.singularity.joinFaction(ns.args[0])', '/Temp/joinFaction.txt', ["Daedalus"]) :
log(ns, "INFO: Please manually join the faction 'Daedalus' as soon as possible to proceed", false, 'info');
}
const bitNodeMults = await tryGetBitNodeMultipliers(ns, false) || { DaedalusAugsRequirement: 1 };
Expand Down Expand Up @@ -432,7 +432,7 @@ async function maybeDoCasino(ns, player) {
await killScript(ns, 'work-for-factions.js');
// Kill any action, in case we are studying or working out, as it might steal focus or funds before we can bet it at the casino.
if (4 in unlockedSFs) // No big deal if we can't, casino.js has logic to find the stop button and click it.
await getNsDataThroughFile(ns, `ns.stopAction()`, '/Temp/stop-action.txt');
await getNsDataThroughFile(ns, `ns.singularity.stopAction()`, '/Temp/stop-action.txt');

const pid = launchScriptHelper(ns, 'casino.js', ['--kill-all-scripts', true, '--on-completion-script', ns.getScriptName()]);
if (pid) {
Expand Down Expand Up @@ -567,7 +567,7 @@ async function shouldDelayInstall(ns, player, facmanOutput) {
// enough rep, or enough money to donate for rep to buy TRP (Reminder: donations always unlocked in BN8)
if (player.bitNodeN == 8 && player.factions.includes("Daedalus") && (wdHack || 0) == 0) {
// Sanity check, ensure the player hasn't manually purchased (but not yet installed) TRP
const ownedAugmentations = await getNsDataThroughFile(ns, `ns.getOwnedAugmentations(true)`, '/Temp/player-augs-purchased.txt');
const ownedAugmentations = await getNsDataThroughFile(ns, `ns.singularity.getOwnedAugmentations(true)`, '/Temp/player-augs-purchased.txt');
if (!facmanOutput.affordable_augs.includes("The Red Pill") && !ownedAugmentations.includes("The Red Pill")) {
setStatus(ns, `Not installing until we have enough Daedalus rep to install TRP on our next reset.`)
return true;
Expand Down
4 changes: 2 additions & 2 deletions bladeburner.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ async function gatherBladeburnerInfo(ns) {
maxRankNeeded = blackOpsRanks[remainingBlackOpsNames[remainingBlackOpsNames.length - 1]];
// Check if we have the aug that lets us do bladeburner while otherwise busy
haveSimulacrum = !(4 in ownedSourceFiles) ? true : // If player doesn't have SF4, we cannot check, so hope for the best.
await getNsDataThroughFile(ns, `ns.getOwnedAugmentations().includes("${simulacrumAugName}")`, '/Temp/bladeburner-hasSimulacrum.txt');
await getNsDataThroughFile(ns, `ns.singularity.getOwnedAugmentations().includes("${simulacrumAugName}")`, '/Temp/bladeburner-hasSimulacrum.txt');
// Initialize some flags that may change over time
lastAssignedTask = null;
lastBlackOpComplete = false; // Flag will track whether we've notified the user that the last black-op is ready
Expand Down Expand Up @@ -404,7 +404,7 @@ let lastCanWorkCheckIdle = true;
async function canDoBladeburnerWork(ns) {
if (options['ignore-busy-status'] || haveSimulacrum) return true;
// Check if the player is busy doing something else
const busy = await getNsDataThroughFile(ns, 'ns.isBusy()', '/Temp/isBusy.txt');
const busy = await getNsDataThroughFile(ns, 'ns.singularity.isBusy()', '/Temp/isBusy.txt');
if (!busy) return lastCanWorkCheckIdle = true;
if (lastCanWorkCheckIdle)
log(ns, `WARNING: Cannot perform Bladeburner actions because the player is busy ` +
Expand Down
4 changes: 2 additions & 2 deletions casino.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export async function main(ns) {
// Step 1: Go to Aevum if we aren't already there. (Must be done manually if you don't have SF4)
if (ns.getPlayer().city != "Aevum") {
try {
if (ns.getPlayer().money < 200000 || !(await getNsDataThroughFile(ns, 'ns.travelToCity(ns.args[0])', '/Temp/travelToCity.txt', ["Aevum"])))
if (ns.getPlayer().money < 200000 || !(await getNsDataThroughFile(ns, 'ns.singularity.travelToCity(ns.args[0])', '/Temp/travelToCity.txt', ["Aevum"])))
return tailAndLog(ns, "ERROR: Sorry, you need at least 200k to travel to the casino.");
} catch (err) {
return tailAndLog(ns, "ERROR: You must manually travel to to Aevum to use this script until you get SF4");
Expand Down Expand Up @@ -77,7 +77,7 @@ export async function main(ns) {
await click(await findRetry(ns, "//div[(@role = 'button') and (contains(., 'City'))]"));
await click(await findRetry(ns, "//span[@aria-label = 'Iker Molina Casino']"));
} catch { // Use SF4 as a fallback, it's more reliable.
try { await getNsDataThroughFile(ns, 'ns.goToLocation(ns.args[0])', '/Temp/goToLocation.txt', ["Iker Molina Casino"]); }
try { await getNsDataThroughFile(ns, 'ns.singularity.goToLocation(ns.args[0])', '/Temp/goToLocation.txt', ["Iker Molina Casino"]); }
catch { return tailAndLog(ns, "ERROR: Failed to travel to the casino both using UI navigation and using SF4 as a fall-back."); }
}
// Step 2.3: Try to start the blackjack game
Expand Down
4 changes: 2 additions & 2 deletions crime.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ async function legacyAutoCrime(ns, crime = "mug") {
let interval = 100;
while (true) {
let maxBusyLoops = 100;
while ((await getNsDataThroughFile(ns, `ns.isBusy()`, '/Temp/isBusy.txt')) && maxBusyLoops-- > 0) {
while ((await getNsDataThroughFile(ns, `ns.singularity.isBusy()`, '/Temp/isBusy.txt')) && maxBusyLoops-- > 0) {
await ns.sleep(interval);
ns.print("Waiting to no longer be busy...");
}
Expand All @@ -31,7 +31,7 @@ async function legacyAutoCrime(ns, crime = "mug") {
return;
}
ns.tail(); // Force a tail window open when auto-criming, or else it's very difficult to stop if it was accidentally closed.
let wait = 10 + (await getNsDataThroughFile(ns, 'ns.commitCrime(ns.args[0])', '/Temp/commitCrime.txt', [crime]));
let wait = 10 + (await getNsDataThroughFile(ns, 'ns.singularity.commitCrime(ns.args[0])', '/Temp/commitCrime.txt', [crime]));
ns.print(`Karma: ${formatNumberShort(ns.heart.break())} Committing crime \"${crime}\" and sleeping for ${formatDuration(wait)}...`);
await ns.sleep(wait);
}
Expand Down
8 changes: 4 additions & 4 deletions daemon.js
Original file line number Diff line number Diff line change
Expand Up @@ -350,14 +350,14 @@ async function kickstartHackXp(ns) {
log(ns, `INFO: Studying for ${studyTime} seconds to kickstart hack XP and speed up initial cycle times. (set --initial-study-time 0 to disable this step.)`);
const money = ns.getServerMoneyAvailable("home")
if (money >= 200000) // If we can afford to travel, we're probably far enough along that it's worthwhile going to Volhaven where ZB university is.
await getNsDataThroughFile(ns, `ns.travelToCity("Volhaven")`, '/Temp/travel-to-city.txt');
await getNsDataThroughFile(ns, `ns.singularity.travelToCity("Volhaven")`, '/Temp/travel-to-city.txt');
const playerInfo = await getPlayerInfo(); // Update player stats to be certain of our new location.
const university = playerInfo.city == "Sector-12" ? "Rothman University" : playerInfo.city == "Aevum" ? "Summit University" : playerInfo.city == "Volhaven" ? "ZB Institute of Technology" : null;
if (!university)
log(ns, `INFO: Cannot study, because you are in city ${playerInfo.city} which has no known university, and you cannot afford to travel to another city.`);
else {
const course = playerInfo.city == "Sector-12" ? "Study Computer Science" : "Algorithms"; // Assume if we are still in Sector-12 we are poor and should only take the free course
await getNsDataThroughFile(ns, `ns.universityCourse(ns.args[0], ns.args[1], ns.args[2])`, '/Temp/study.txt', [university, course, false]);
await getNsDataThroughFile(ns, `ns.singularity.universityCourse(ns.args[0], ns.args[1], ns.args[2])`, '/Temp/study.txt', [university, course, false]);
startedStudying = true;
await ns.sleep(studyTime * 1000); // Wait for studies to affect Hack XP. This will often greatly reduce time-to-hack/grow/weaken, and avoid a slow first cycle
}
Expand Down Expand Up @@ -388,7 +388,7 @@ async function kickstartHackXp(ns) {
log(ns, 'WARNING: Encountered an error while trying to kickstart hack XP (low RAM issues perhaps?)', false, 'warning');
} finally {
// Ensure we stop studying (in case no other running scripts end up stealing focus, so we don't keep studying forever)
if (startedStudying) await getNsDataThroughFile(ns, `ns.stopAction()`, '/Temp/stop-action.txt');
if (startedStudying) await getNsDataThroughFile(ns, `ns.singularity.stopAction()`, '/Temp/stop-action.txt');
studying = false; // This will allow work-for-faction to launch
}
}
Expand Down Expand Up @@ -797,7 +797,7 @@ async function refreshDynamicServerData(ns, serverNames) {
dictServerProfitInfo = Object.fromEntries(JSON.parse(dictServerProfitInfo).map(s => [s.hostname, s]));
//ns.print(dictServerProfitInfo);
if (options.i)
currentTerminalServer = getServerByName(await getNsDataThroughFile(ns, 'ns.getCurrentServer()', '/Temp/terminal-server.txt'));
currentTerminalServer = getServerByName(await getNsDataThroughFile(ns, 'ns.singularity.getCurrentServer()', '/Temp/terminal-server.txt'));
}

class Server {
Expand Down
Loading

0 comments on commit e9cceb5

Please sign in to comment.