Merge pull request #2703 from lethern/patch-1

purchaseServer error message fix + small docs change
This commit is contained in:
hydroflame 2022-01-26 00:50:42 -05:00 committed by GitHub
commit 1a34d5e363
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 11 deletions

@ -2050,7 +2050,7 @@ function initAugmentations(): void {
info: info:
"A brain implant carefully assembled around the synapses, which " + "A brain implant carefully assembled around the synapses, which " +
"micromanages the activity and levels of various neuroreceptor " + "micromanages the activity and levels of various neuroreceptor " +
"chemicals and modulates electrical acvitiy to optimize concentration, " + "chemicals and modulates electrical activity to optimize concentration, " +
"allowing the user to multitask much more effectively.", "allowing the user to multitask much more effectively.",
stats: ( stats: (
<> <>

@ -524,7 +524,7 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
if (isNaN(hackAmount)) { if (isNaN(hackAmount)) {
throw makeRuntimeErrorMsg( throw makeRuntimeErrorMsg(
"hackAnalyzeThreads", "hackAnalyzeThreads",
`Invalid growth argument passed into hackAnalyzeThreads: ${hackAmount}. Must be numeric.`, `Invalid hackAmount argument passed into hackAnalyzeThreads: ${hackAmount}. Must be numeric.`,
); );
} }
@ -1649,7 +1649,12 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
const cost = getPurchaseServerCost(ram); const cost = getPurchaseServerCost(ram);
if (cost === Infinity) { if (cost === Infinity) {
workerScript.log("purchaseServer", () => `Invalid argument: ram='${ram}' must be a positive power of 2`); if(ram > getPurchaseServerMaxRam()){
workerScript.log("purchaseServer", () => `Invalid argument: ram='${ram}' must not be greater than getPurchaseServerMaxRam`);
}else{
workerScript.log("purchaseServer", () => `Invalid argument: ram='${ram}' must be a positive power of 2`);
}
return ""; return "";
} }

@ -4200,13 +4200,11 @@ export interface NS extends Singularity {
* ```ts * ```ts
* // NS1: * // NS1:
* var earnedMoney = hack("foodnstuff"); * var earnedMoney = hack("foodnstuff");
* earnedMoney = earnedMoney + hack("foodnstuff", { threads: 5 }); // Only use 5 threads to hack
* ``` * ```
* @example * @example
* ```ts * ```ts
* // NS2: * // NS2:
* let earnedMoney = await ns.hack("foodnstuff"); * let earnedMoney = await ns.hack("foodnstuff");
* earnedMoney += await ns.hack("foodnstuff", { threads: 5 }); // Only use 5 threads to hack
* ``` * ```
* @param host - Hostname of the target server to hack. * @param host - Hostname of the target server to hack.
* @param opts - Optional parameters for configuring function behavior. * @param opts - Optional parameters for configuring function behavior.
@ -4234,16 +4232,14 @@ export interface NS extends Singularity {
* @example * @example
* ```ts * ```ts
* // NS1: * // NS1:
* var availableMoney = getServerMoneyAvailable("foodnstuff"); * var currentMoney = getServerMoneyAvailable("foodnstuff");
* currentMoney = currentMoney * (1 + grow("foodnstuff")); * currentMoney = currentMoney * (1 + grow("foodnstuff"));
* currentMoney = currentMoney * (1 + grow("foodnstuff", { threads: 5 })); // Only use 5 threads to grow
* ``` * ```
* @example * @example
* ```ts * ```ts
* // NS2: * // NS2:
* let availableMoney = ns.getServerMoneyAvailable("foodnstuff"); * let currentMoney = ns.getServerMoneyAvailable("foodnstuff");
* currentMoney *= (1 + await ns.grow("foodnstuff")); * currentMoney *= (1 + await ns.grow("foodnstuff"));
* currentMoney *= (1 + await ns.grow("foodnstuff", { threads: 5 })); // Only use 5 threads to grow
* ``` * ```
* @param host - Hostname of the target server to grow. * @param host - Hostname of the target server to grow.
* @param opts - Optional parameters for configuring function behavior. * @param opts - Optional parameters for configuring function behavior.
@ -4269,14 +4265,12 @@ export interface NS extends Singularity {
* // NS1: * // NS1:
* var currentSecurity = getServerSecurityLevel("foodnstuff"); * var currentSecurity = getServerSecurityLevel("foodnstuff");
* currentSecurity = currentSecurity - weaken("foodnstuff"); * currentSecurity = currentSecurity - weaken("foodnstuff");
* currentSecurity = currentSecurity - weaken("foodnstuff", { threads: 5 }); // Only use 5 threads to weaken
* ``` * ```
* @example * @example
* ```ts * ```ts
* // NS2: * // NS2:
* let currentSecurity = ns.getServerSecurityLevel("foodnstuff"); * let currentSecurity = ns.getServerSecurityLevel("foodnstuff");
* currentSecurity -= await ns.weaken("foodnstuff"); * currentSecurity -= await ns.weaken("foodnstuff");
* currentSecurity -= await ns.weaken("foodnstuff", { threads: 5 }); // Only use 5 threads to weaken
* ``` * ```
* @param host - Hostname of the target server to weaken. * @param host - Hostname of the target server to weaken.
* @param opts - Optional parameters for configuring function behavior. * @param opts - Optional parameters for configuring function behavior.