mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-30 03:23:48 +01:00
Merge pull request #2118 from Icehawk78/feat/add-ns2-examples-docs
Add ns2 examples to the netscript docs
This commit is contained in:
commit
fba2265cce
485
src/ScriptEditor/NetscriptDefinitions.d.ts
vendored
485
src/ScriptEditor/NetscriptDefinitions.d.ts
vendored
@ -952,7 +952,13 @@ export interface TIX {
|
|||||||
*
|
*
|
||||||
* @example
|
* @example
|
||||||
* ```ts
|
* ```ts
|
||||||
* getPrice("FISG");
|
* // NS1
|
||||||
|
* stock.getPrice("FISG");
|
||||||
|
* ```
|
||||||
|
* @example
|
||||||
|
* ```ts
|
||||||
|
* // NS2
|
||||||
|
* ns.stock.getPrice("FISG");
|
||||||
* ```
|
* ```
|
||||||
* @param sym - Stock symbol.
|
* @param sym - Stock symbol.
|
||||||
* @returns The price of a stock.
|
* @returns The price of a stock.
|
||||||
@ -995,11 +1001,17 @@ export interface TIX {
|
|||||||
*
|
*
|
||||||
* @example
|
* @example
|
||||||
* ```ts
|
* ```ts
|
||||||
* pos = getPosition("ECP");
|
* // NS1
|
||||||
* shares = pos[0];
|
* var pos = stock.getPosition("ECP");
|
||||||
* avgPx = pos[1];
|
* var shares = pos[0];
|
||||||
* sharesShort = pos[2];
|
* var avgPx = pos[1];
|
||||||
* avgPxShort = pos[3];
|
* var sharesShort = pos[2];
|
||||||
|
* var avgPxShort = pos[3];
|
||||||
|
* ```
|
||||||
|
* @example
|
||||||
|
* ```ts
|
||||||
|
* // NS2
|
||||||
|
* const [shares, avgPx, sharesShort, avgPxShort] = ns.stock.getPosition("ECP");
|
||||||
* ```
|
* ```
|
||||||
* @param sym - Stock symbol.
|
* @param sym - Stock symbol.
|
||||||
* @returns Array of four elements that represents the player’s position in a stock.
|
* @returns Array of four elements that represents the player’s position in a stock.
|
||||||
@ -1369,8 +1381,14 @@ export interface Singularity {
|
|||||||
*
|
*
|
||||||
* @example
|
* @example
|
||||||
* ```ts
|
* ```ts
|
||||||
|
* // NS1
|
||||||
* purchaseProgram("brutessh.exe");
|
* purchaseProgram("brutessh.exe");
|
||||||
* ```
|
* ```
|
||||||
|
* @example
|
||||||
|
* ```ts
|
||||||
|
* // NS2
|
||||||
|
* ns.purchaseProgram("brutessh.exe");
|
||||||
|
* ```
|
||||||
* @param programName - Name of program to purchase.
|
* @param programName - Name of program to purchase.
|
||||||
* @returns True if the specified program is purchased, and false otherwise.
|
* @returns True if the specified program is purchased, and false otherwise.
|
||||||
*/
|
*/
|
||||||
@ -1485,6 +1503,7 @@ export interface Singularity {
|
|||||||
*
|
*
|
||||||
* @example
|
* @example
|
||||||
* ```ts
|
* ```ts
|
||||||
|
* // NS1:
|
||||||
* //If you only want to work until you get 100,000 company reputation. One small hack to get around this is to continuously restart the action to receive your earnings:
|
* //If you only want to work until you get 100,000 company reputation. One small hack to get around this is to continuously restart the action to receive your earnings:
|
||||||
* while (getCompanyRep(COMPANY HERE) < VALUE) {
|
* while (getCompanyRep(COMPANY HERE) < VALUE) {
|
||||||
* workForCompany();
|
* workForCompany();
|
||||||
@ -1492,6 +1511,16 @@ export interface Singularity {
|
|||||||
* }
|
* }
|
||||||
* //This way, your company reputation will be updated every minute.
|
* //This way, your company reputation will be updated every minute.
|
||||||
* ```
|
* ```
|
||||||
|
* @example
|
||||||
|
* ```ts
|
||||||
|
* // NS2:
|
||||||
|
* //If you only want to work until you get 100,000 company reputation. One small hack to get around this is to continuously restart the action to receive your earnings:
|
||||||
|
* while (ns.getCompanyRep(COMPANY HERE) < VALUE) {
|
||||||
|
* ns.workForCompany();
|
||||||
|
* await ns.sleep(60000);
|
||||||
|
* }
|
||||||
|
* //This way, your company reputation will be updated every minute.
|
||||||
|
* ```
|
||||||
* @param companyName - Name of company to work for. Must be an exact match. Optional. If not specified, this argument defaults to the last job that you worked
|
* @param companyName - Name of company to work for. Must be an exact match. Optional. If not specified, this argument defaults to the last job that you worked
|
||||||
* @param focus - Acquire player focus on this work operation. Optional. Defaults to true.
|
* @param focus - Acquire player focus on this work operation. Optional. Defaults to true.
|
||||||
* @returns True if the player starts working, and false otherwise.
|
* @returns True if the player starts working, and false otherwise.
|
||||||
@ -1604,6 +1633,7 @@ export interface Singularity {
|
|||||||
*
|
*
|
||||||
* @example
|
* @example
|
||||||
* ```ts
|
* ```ts
|
||||||
|
* // NS1:
|
||||||
* //If you only want to work until you get 100,000 faction reputation. One small hack to get around this is to continuously restart the action to receive your earnings:
|
* //If you only want to work until you get 100,000 faction reputation. One small hack to get around this is to continuously restart the action to receive your earnings:
|
||||||
* while (getFactionRep(FACTION NAME) < VALUE) {
|
* while (getFactionRep(FACTION NAME) < VALUE) {
|
||||||
* workForFaction(FACNAME, WORKTYPE);
|
* workForFaction(FACNAME, WORKTYPE);
|
||||||
@ -1611,6 +1641,16 @@ export interface Singularity {
|
|||||||
* }
|
* }
|
||||||
* //This way, your faction reputation will be updated every minute.
|
* //This way, your faction reputation will be updated every minute.
|
||||||
* ```
|
* ```
|
||||||
|
* @example
|
||||||
|
* ```ts
|
||||||
|
* // NS2:
|
||||||
|
* //If you only want to work until you get 100,000 faction reputation. One small hack to get around this is to continuously restart the action to receive your earnings:
|
||||||
|
* while (ns.getFactionRep(FACTION NAME) < VALUE) {
|
||||||
|
* ns.workForFaction(FACNAME, WORKTYPE);
|
||||||
|
* await ns.sleep(60000);
|
||||||
|
* }
|
||||||
|
* //This way, your faction reputation will be updated every minute.
|
||||||
|
* ```
|
||||||
* @param faction - Name of faction to work for.
|
* @param faction - Name of faction to work for.
|
||||||
* @param workType - Type of work to perform for the faction.
|
* @param workType - Type of work to perform for the faction.
|
||||||
* @param focus - Acquire player focus on this work operation. Optional. Defaults to true.
|
* @param focus - Acquire player focus on this work operation. Optional. Defaults to true.
|
||||||
@ -1700,8 +1740,14 @@ export interface Singularity {
|
|||||||
*
|
*
|
||||||
* @example
|
* @example
|
||||||
* ```ts
|
* ```ts
|
||||||
|
* // NS1:
|
||||||
* createProgram(“relaysmtp.exe”);
|
* createProgram(“relaysmtp.exe”);
|
||||||
* ```
|
* ```
|
||||||
|
* @example
|
||||||
|
* ```ts
|
||||||
|
* // NS2:
|
||||||
|
* ns.createProgram(“relaysmtp.exe”);
|
||||||
|
* ```
|
||||||
* @param program - Name of program to create.
|
* @param program - Name of program to create.
|
||||||
* @returns True if you successfully start working on the specified program, and false otherwise.
|
* @returns True if you successfully start working on the specified program, and false otherwise.
|
||||||
*/
|
*/
|
||||||
@ -2259,11 +2305,20 @@ export interface Hacknet {
|
|||||||
*
|
*
|
||||||
* @example
|
* @example
|
||||||
* ```ts
|
* ```ts
|
||||||
|
* // NS1:
|
||||||
* var upgradeName = "Sell for Corporation Funds";
|
* var upgradeName = "Sell for Corporation Funds";
|
||||||
* if (hacknet.numHashes() > hacknet.hashCost(upgradeName)) {
|
* if (hacknet.numHashes() > hacknet.hashCost(upgradeName)) {
|
||||||
* hacknet.spendHashes(upgName);
|
* hacknet.spendHashes(upgName);
|
||||||
* }
|
* }
|
||||||
* ```
|
* ```
|
||||||
|
* @example
|
||||||
|
* ```ts
|
||||||
|
* // NS2:
|
||||||
|
* const upgradeName = "Sell for Corporation Funds";
|
||||||
|
* if (ns.hacknet.numHashes() > ns.hacknet.hashCost(upgradeName)) {
|
||||||
|
* ns.hacknet.spendHashes(upgName);
|
||||||
|
* }
|
||||||
|
* ```
|
||||||
* @param upgName - Name of the upgrade of Hacknet Node.
|
* @param upgName - Name of the upgrade of Hacknet Node.
|
||||||
* @returns Number of hashes required for the specified upgrade.
|
* @returns Number of hashes required for the specified upgrade.
|
||||||
*/
|
*/
|
||||||
@ -2285,9 +2340,16 @@ export interface Hacknet {
|
|||||||
*
|
*
|
||||||
* @example
|
* @example
|
||||||
* ```ts
|
* ```ts
|
||||||
|
* // NS1:
|
||||||
* hacknet.spendHashes("Sell for Corporation Funds");
|
* hacknet.spendHashes("Sell for Corporation Funds");
|
||||||
* hacknet.spendHashes("Increase Maximum Money", "foodnstuff");
|
* hacknet.spendHashes("Increase Maximum Money", "foodnstuff");
|
||||||
* ```
|
* ```
|
||||||
|
* @example
|
||||||
|
* ```ts
|
||||||
|
* NS2:
|
||||||
|
* ns.hacknet.spendHashes("Sell for Corporation Funds");
|
||||||
|
* ns.hacknet.spendHashes("Increase Maximum Money", "foodnstuff");
|
||||||
|
* ```
|
||||||
* @param upgName - Name of the upgrade of Hacknet Node.
|
* @param upgName - Name of the upgrade of Hacknet Node.
|
||||||
* @param upgTarget - Object to which upgrade applies. Required for certain upgrades.
|
* @param upgTarget - Object to which upgrade applies. Required for certain upgrades.
|
||||||
* @returns True if the upgrade is successfully purchased, and false otherwise..
|
* @returns True if the upgrade is successfully purchased, and false otherwise..
|
||||||
@ -2304,7 +2366,13 @@ export interface Hacknet {
|
|||||||
* Returns the list of all available hash upgrades that can be used in the spendHashes function.
|
* Returns the list of all available hash upgrades that can be used in the spendHashes function.
|
||||||
* @example
|
* @example
|
||||||
* ```ts
|
* ```ts
|
||||||
* const upgrades = hacknet.getHashUpgrades(); // ["Sell for Money","Sell for Corporation Funds",...]
|
* // NS1:
|
||||||
|
* var upgrades = hacknet.getHashUpgrades(); // ["Sell for Money","Sell for Corporation Funds",...]
|
||||||
|
* ```
|
||||||
|
* @example
|
||||||
|
* ```ts
|
||||||
|
* // NS2:
|
||||||
|
* const upgrades = ns.hacknet.getHashUpgrades(); // ["Sell for Money","Sell for Corporation Funds",...]
|
||||||
* ```
|
* ```
|
||||||
* @returns An array containing the available upgrades
|
* @returns An array containing the available upgrades
|
||||||
*/
|
*/
|
||||||
@ -2756,11 +2824,20 @@ export interface Bladeburner {
|
|||||||
* * [Current stamina, Max stamina]
|
* * [Current stamina, Max stamina]
|
||||||
* @example
|
* @example
|
||||||
* ```ts
|
* ```ts
|
||||||
|
* // NS1:
|
||||||
* function getStaminaPercentage() {
|
* function getStaminaPercentage() {
|
||||||
* let res = bladeburner.getStamina();
|
* var res = bladeburner.getStamina();
|
||||||
* return res[0] / res[1];
|
* return res[0] / res[1];
|
||||||
* }
|
* }
|
||||||
* ```
|
* ```
|
||||||
|
* @example
|
||||||
|
* ```ts
|
||||||
|
* // NS2:
|
||||||
|
* function getStaminaPercentage() {
|
||||||
|
* const [current, max] = ns.bladeburner.getStamina();
|
||||||
|
* return current / max;
|
||||||
|
* }
|
||||||
|
* ```
|
||||||
* @returns Array containing current stamina and max stamina.
|
* @returns Array containing current stamina and max stamina.
|
||||||
*/
|
*/
|
||||||
getStamina(): [number, number];
|
getStamina(): [number, number];
|
||||||
@ -3878,8 +3955,15 @@ export interface NS extends Singularity {
|
|||||||
*
|
*
|
||||||
* @example
|
* @example
|
||||||
* ```ts
|
* ```ts
|
||||||
* hack("foodnstuff");
|
* // NS1:
|
||||||
* hack("foodnstuff", { threads: 5 }); // Only use 5 threads to hack
|
* var earnedMoney = hack("foodnstuff");
|
||||||
|
* earnedMoney = earnedMoney + hack("foodnstuff", { threads: 5 }); // Only use 5 threads to hack
|
||||||
|
* ```
|
||||||
|
* @example
|
||||||
|
* ```ts
|
||||||
|
* // NS2:
|
||||||
|
* 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.
|
||||||
@ -3906,8 +3990,17 @@ export interface NS extends Singularity {
|
|||||||
*
|
*
|
||||||
* @example
|
* @example
|
||||||
* ```ts
|
* ```ts
|
||||||
* grow("foodnstuff");
|
* // NS1:
|
||||||
* grow("foodnstuff", { threads: 5 }); // Only use 5 threads to grow
|
* var availableMoney = getServerMoneyAvailable("foodnstuff");
|
||||||
|
* currentMoney = currentMoney * (1 + grow("foodnstuff"));
|
||||||
|
* currentMoney = currentMoney * (1 + grow("foodnstuff", { threads: 5 })); // Only use 5 threads to grow
|
||||||
|
* ```
|
||||||
|
* @example
|
||||||
|
* ```ts
|
||||||
|
* // NS2:
|
||||||
|
* let availableMoney = ns.getServerMoneyAvailable("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.
|
||||||
@ -3930,8 +4023,17 @@ export interface NS extends Singularity {
|
|||||||
*
|
*
|
||||||
* @example
|
* @example
|
||||||
* ```ts
|
* ```ts
|
||||||
* weaken("foodnstuff");
|
* // NS1:
|
||||||
* weaken("foodnstuff", { threads: 5 }); // Only use 5 threads to weaken
|
* var currentSecurity = getServerSecurityLevel("foodnstuff");
|
||||||
|
* currentSecurity = currentSecurity - weaken("foodnstuff");
|
||||||
|
* currentSecurity = currentSecurity - weaken("foodnstuff", { threads: 5 }); // Only use 5 threads to weaken
|
||||||
|
* ```
|
||||||
|
* @example
|
||||||
|
* ```ts
|
||||||
|
* // NS2:
|
||||||
|
* let currentSecurity = ns.getServerSecurityLevel("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.
|
||||||
@ -3988,8 +4090,16 @@ export interface NS extends Singularity {
|
|||||||
*
|
*
|
||||||
* @example
|
* @example
|
||||||
* ```ts
|
* ```ts
|
||||||
|
* // NS1:
|
||||||
* //For example, assume the following returns 0.01:
|
* //For example, assume the following returns 0.01:
|
||||||
* hackAnalyze("foodnstuff");
|
* var hackAmount = hackAnalyze("foodnstuff");
|
||||||
|
* //This means that if hack the foodnstuff server, then you will steal 1% of its total money. If you hack using N threads, then you will steal N*0.01 times its total money.
|
||||||
|
* ```
|
||||||
|
* @example
|
||||||
|
* ```ts
|
||||||
|
* // NS2:
|
||||||
|
* //For example, assume the following returns 0.01:
|
||||||
|
* const hackAmount = ns.hackAnalyze("foodnstuff");
|
||||||
* //This means that if hack the foodnstuff server, then you will steal 1% of its total money. If you hack using N threads, then you will steal N*0.01 times its total money.
|
* //This means that if hack the foodnstuff server, then you will steal 1% of its total money. If you hack using N threads, then you will steal N*0.01 times its total money.
|
||||||
* ```
|
* ```
|
||||||
* @param host - Hostname of the target server.
|
* @param host - Hostname of the target server.
|
||||||
@ -4036,8 +4146,16 @@ export interface NS extends Singularity {
|
|||||||
*
|
*
|
||||||
* @example
|
* @example
|
||||||
* ```ts
|
* ```ts
|
||||||
|
* // NS1:
|
||||||
* //For example, if you want to determine how many grow calls you need to double the amount of money on foodnstuff, you would use:
|
* //For example, if you want to determine how many grow calls you need to double the amount of money on foodnstuff, you would use:
|
||||||
* growthAnalyze("foodnstuff", 2);
|
* var growTimes = growthAnalyze("foodnstuff", 2);
|
||||||
|
* //If this returns 100, then this means you need to call grow 100 times in order to double the money (or once with 100 threads).
|
||||||
|
* ```
|
||||||
|
* @example
|
||||||
|
* ```ts
|
||||||
|
* // NS2:
|
||||||
|
* //For example, if you want to determine how many grow calls you need to double the amount of money on foodnstuff, you would use:
|
||||||
|
* const growTimes = ns.growthAnalyze("foodnstuff", 2);
|
||||||
* //If this returns 100, then this means you need to call grow 100 times in order to double the money (or once with 100 threads).
|
* //If this returns 100, then this means you need to call grow 100 times in order to double the money (or once with 100 threads).
|
||||||
* ```
|
* ```
|
||||||
* @param host - Hostname of the target server.
|
* @param host - Hostname of the target server.
|
||||||
@ -4064,6 +4182,24 @@ export interface NS extends Singularity {
|
|||||||
* RAM cost: 0 GB
|
* RAM cost: 0 GB
|
||||||
*
|
*
|
||||||
* @param millis - Number of milliseconds to sleep.
|
* @param millis - Number of milliseconds to sleep.
|
||||||
|
* @example
|
||||||
|
* ```ts
|
||||||
|
* // NS1:
|
||||||
|
* // This will count from 1 to 10 in your terminal, with one number every 5 seconds
|
||||||
|
* for (var i=0; i<10; i++) {
|
||||||
|
* tprint(i + 1);
|
||||||
|
* sleep(5000);
|
||||||
|
* }
|
||||||
|
* ```
|
||||||
|
* @example
|
||||||
|
* ```ts
|
||||||
|
* // NS2:
|
||||||
|
* // This will count from 1 to 10 in your terminal, with one number every 5 seconds
|
||||||
|
* for (var i=0; i<10; i++) {
|
||||||
|
* ns.tprint(i + 1);
|
||||||
|
* await ns.sleep(5000);
|
||||||
|
* }
|
||||||
|
* ```
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
sleep(millis: number): Promise<void>;
|
sleep(millis: number): Promise<void>;
|
||||||
@ -4165,18 +4301,27 @@ export interface NS extends Singularity {
|
|||||||
*
|
*
|
||||||
* @example
|
* @example
|
||||||
* ```ts
|
* ```ts
|
||||||
|
* // NS1:
|
||||||
* //Get logs from foo.script on the current server that was run with no args
|
* //Get logs from foo.script on the current server that was run with no args
|
||||||
* getScriptLogs("foo.script");
|
* getScriptLogs("foo.script");
|
||||||
* ```
|
*
|
||||||
* @example
|
|
||||||
* ```ts
|
|
||||||
* //Open logs from foo.script on the foodnstuff server that was run with no args
|
* //Open logs from foo.script on the foodnstuff server that was run with no args
|
||||||
* getScriptLogs("foo.script", "foodnstuff");
|
* getScriptLogs("foo.script", "foodnstuff");
|
||||||
|
*
|
||||||
|
* //Open logs from foo.script on the foodnstuff server that was run with the arguments [1, "test"]
|
||||||
|
* getScriptLogs("foo.script", "foodnstuff", 1, "test");
|
||||||
* ```
|
* ```
|
||||||
* @example
|
* @example
|
||||||
* ```ts
|
* ```ts
|
||||||
|
* // NS2:
|
||||||
|
* //Get logs from foo.script on the current server that was run with no args
|
||||||
|
* ns.getScriptLogs("foo.script");
|
||||||
|
*
|
||||||
|
* //Open logs from foo.script on the foodnstuff server that was run with no args
|
||||||
|
* ns.getScriptLogs("foo.script", "foodnstuff");
|
||||||
|
*
|
||||||
* //Open logs from foo.script on the foodnstuff server that was run with the arguments [1, "test"]
|
* //Open logs from foo.script on the foodnstuff server that was run with the arguments [1, "test"]
|
||||||
* getScriptLogs("foo.script", "foodnstuff", 1, "test");
|
* ns.getScriptLogs("foo.script", "foodnstuff", 1, "test");
|
||||||
* ```
|
* ```
|
||||||
* @param fn - Optional. Filename of script to get logs from.
|
* @param fn - Optional. Filename of script to get logs from.
|
||||||
* @param host - Optional. Hostname of the server that the script is on.
|
* @param host - Optional. Hostname of the server that the script is on.
|
||||||
@ -4199,18 +4344,27 @@ export interface NS extends Singularity {
|
|||||||
*
|
*
|
||||||
* @example
|
* @example
|
||||||
* ```ts
|
* ```ts
|
||||||
|
* // NS1:
|
||||||
* //Open logs from foo.script on the current server that was run with no args
|
* //Open logs from foo.script on the current server that was run with no args
|
||||||
* tail("foo.script");
|
* tail("foo.script");
|
||||||
* ```
|
*
|
||||||
* @example
|
|
||||||
* ```ts
|
|
||||||
* //Get logs from foo.script on the foodnstuff server that was run with no args
|
* //Get logs from foo.script on the foodnstuff server that was run with no args
|
||||||
* tail("foo.script", "foodnstuff");
|
* tail("foo.script", "foodnstuff");
|
||||||
|
*
|
||||||
|
* //Get logs from foo.script on the foodnstuff server that was run with the arguments [1, "test"]
|
||||||
|
* tail("foo.script", "foodnstuff", 1, "test");
|
||||||
* ```
|
* ```
|
||||||
* @example
|
* @example
|
||||||
* ```ts
|
* ```ts
|
||||||
|
* // NS2:
|
||||||
|
* //Open logs from foo.script on the current server that was run with no args
|
||||||
|
* ns.tail("foo.script");
|
||||||
|
*
|
||||||
|
* //Get logs from foo.script on the foodnstuff server that was run with no args
|
||||||
|
* ns.tail("foo.script", "foodnstuff");
|
||||||
|
*
|
||||||
* //Get logs from foo.script on the foodnstuff server that was run with the arguments [1, "test"]
|
* //Get logs from foo.script on the foodnstuff server that was run with the arguments [1, "test"]
|
||||||
* tail("foo.script", "foodnstuff", 1, "test");
|
* ns.tail("foo.script", "foodnstuff", 1, "test");
|
||||||
* ```
|
* ```
|
||||||
* @param fn - Optional. Filename of the script being tailed. If omitted, the current script is tailed.
|
* @param fn - Optional. Filename of the script being tailed. If omitted, the current script is tailed.
|
||||||
* @param host - Optional. Hostname of the script being tailed. Defaults to the server this script is running on. If args are specified, this is not optional.
|
* @param host - Optional. Hostname of the script being tailed. Defaults to the server this script is running on. If args are specified, this is not optional.
|
||||||
@ -4241,8 +4395,14 @@ export interface NS extends Singularity {
|
|||||||
*
|
*
|
||||||
* @example
|
* @example
|
||||||
* ```ts
|
* ```ts
|
||||||
|
* // NS1:
|
||||||
* nuke("foodnstuff");
|
* nuke("foodnstuff");
|
||||||
* ```
|
* ```
|
||||||
|
* @example
|
||||||
|
* ```ts
|
||||||
|
* // NS2:
|
||||||
|
* ns.nuke("foodnstuff");
|
||||||
|
* ```
|
||||||
* @param host - Hostname of the target server.
|
* @param host - Hostname of the target server.
|
||||||
*/
|
*/
|
||||||
nuke(host: string): void;
|
nuke(host: string): void;
|
||||||
@ -4256,8 +4416,14 @@ export interface NS extends Singularity {
|
|||||||
*
|
*
|
||||||
* @example
|
* @example
|
||||||
* ```ts
|
* ```ts
|
||||||
|
* // NS1:
|
||||||
* brutessh("foodnstuff");
|
* brutessh("foodnstuff");
|
||||||
* ```
|
* ```
|
||||||
|
* @example
|
||||||
|
* ```ts
|
||||||
|
* // NS2:
|
||||||
|
* ns.brutessh("foodnstuff");
|
||||||
|
* ```
|
||||||
* @param host - Hostname of the target server.
|
* @param host - Hostname of the target server.
|
||||||
*/
|
*/
|
||||||
brutessh(host: string): void;
|
brutessh(host: string): void;
|
||||||
@ -4271,8 +4437,14 @@ export interface NS extends Singularity {
|
|||||||
*
|
*
|
||||||
* @example
|
* @example
|
||||||
* ```ts
|
* ```ts
|
||||||
|
* // NS1:
|
||||||
* ftpcrack("foodnstuff");
|
* ftpcrack("foodnstuff");
|
||||||
* ```
|
* ```
|
||||||
|
* @example
|
||||||
|
* ```ts
|
||||||
|
* // NS2:
|
||||||
|
* ns.ftpcrack("foodnstuff");
|
||||||
|
* ```
|
||||||
* @param host - Hostname of the target server.
|
* @param host - Hostname of the target server.
|
||||||
*/
|
*/
|
||||||
ftpcrack(host: string): void;
|
ftpcrack(host: string): void;
|
||||||
@ -4286,8 +4458,14 @@ export interface NS extends Singularity {
|
|||||||
*
|
*
|
||||||
* @example
|
* @example
|
||||||
* ```ts
|
* ```ts
|
||||||
|
* // NS1:
|
||||||
* relaysmtp("foodnstuff");
|
* relaysmtp("foodnstuff");
|
||||||
* ```
|
* ```
|
||||||
|
* @example
|
||||||
|
* ```ts
|
||||||
|
* // NS2:
|
||||||
|
* ns.relaysmtp("foodnstuff");
|
||||||
|
* ```
|
||||||
* @param host - Hostname of the target server.
|
* @param host - Hostname of the target server.
|
||||||
*/
|
*/
|
||||||
relaysmtp(host: string): void;
|
relaysmtp(host: string): void;
|
||||||
@ -4301,8 +4479,14 @@ export interface NS extends Singularity {
|
|||||||
*
|
*
|
||||||
* @example
|
* @example
|
||||||
* ```ts
|
* ```ts
|
||||||
|
* // NS1:
|
||||||
* httpworm("foodnstuff");
|
* httpworm("foodnstuff");
|
||||||
* ```
|
* ```
|
||||||
|
* @example
|
||||||
|
* ```ts
|
||||||
|
* // NS2:
|
||||||
|
* ns.httpworm("foodnstuff");
|
||||||
|
* ```
|
||||||
* @param host - Hostname of the target server.
|
* @param host - Hostname of the target server.
|
||||||
*/
|
*/
|
||||||
httpworm(host: string): void;
|
httpworm(host: string): void;
|
||||||
@ -4316,8 +4500,14 @@ export interface NS extends Singularity {
|
|||||||
*
|
*
|
||||||
* @example
|
* @example
|
||||||
* ```ts
|
* ```ts
|
||||||
|
* // NS1:
|
||||||
* sqlinject("foodnstuff");
|
* sqlinject("foodnstuff");
|
||||||
* ```
|
* ```
|
||||||
|
* @example
|
||||||
|
* ```ts
|
||||||
|
* // NS2:
|
||||||
|
* ns.sqlinject("foodnstuff");
|
||||||
|
* ```
|
||||||
* @remarks RAM cost: 0.05 GB
|
* @remarks RAM cost: 0.05 GB
|
||||||
* @param host - Hostname of the target server.
|
* @param host - Hostname of the target server.
|
||||||
*/
|
*/
|
||||||
@ -4343,18 +4533,27 @@ export interface NS extends Singularity {
|
|||||||
*
|
*
|
||||||
* @example
|
* @example
|
||||||
* ```ts
|
* ```ts
|
||||||
|
* // NS1:
|
||||||
* //The simplest way to use the run command is to call it with just the script name. The following example will run ‘foo.script’ single-threaded with no arguments:
|
* //The simplest way to use the run command is to call it with just the script name. The following example will run ‘foo.script’ single-threaded with no arguments:
|
||||||
* run("foo.script");
|
* run("foo.script");
|
||||||
* ```
|
*
|
||||||
* @example
|
|
||||||
* ```ts
|
|
||||||
* //The following example will run ‘foo.script’ but with 5 threads instead of single-threaded:
|
* //The following example will run ‘foo.script’ but with 5 threads instead of single-threaded:
|
||||||
* run("foo.script", 5);
|
* run("foo.script", 5);
|
||||||
|
*
|
||||||
|
* //This next example will run ‘foo.script’ single-threaded, and will pass the string ‘foodnstuff’ into the script as an argument:
|
||||||
|
* run("foo.script", 1, 'foodnstuff');
|
||||||
* ```
|
* ```
|
||||||
* @example
|
* @example
|
||||||
* ```ts
|
* ```ts
|
||||||
|
* // NS2:
|
||||||
|
* //The simplest way to use the run command is to call it with just the script name. The following example will run ‘foo.script’ single-threaded with no arguments:
|
||||||
|
* ns.run("foo.script");
|
||||||
|
*
|
||||||
|
* //The following example will run ‘foo.script’ but with 5 threads instead of single-threaded:
|
||||||
|
* ns.run("foo.script", 5);
|
||||||
|
*
|
||||||
* //This next example will run ‘foo.script’ single-threaded, and will pass the string ‘foodnstuff’ into the script as an argument:
|
* //This next example will run ‘foo.script’ single-threaded, and will pass the string ‘foodnstuff’ into the script as an argument:
|
||||||
* run("foo.script", 1, 'foodnstuff');
|
* ns.run("foo.script", 1, 'foodnstuff');
|
||||||
* ```
|
* ```
|
||||||
* @param script - Filename of script to run.
|
* @param script - Filename of script to run.
|
||||||
* @param numThreads - Optional thread count for new script. Set to 1 by default. Will be rounded to nearest integer.
|
* @param numThreads - Optional thread count for new script. Set to 1 by default. Will be rounded to nearest integer.
|
||||||
@ -4382,19 +4581,28 @@ export interface NS extends Singularity {
|
|||||||
*
|
*
|
||||||
* @example
|
* @example
|
||||||
* ```ts
|
* ```ts
|
||||||
|
* // NS1:
|
||||||
* //The simplest way to use the exec command is to call it with just the script name and the target server. The following example will try to run generic-hack.script on the foodnstuff server:
|
* //The simplest way to use the exec command is to call it with just the script name and the target server. The following example will try to run generic-hack.script on the foodnstuff server:
|
||||||
* exec("generic-hack.script", "foodnstuff");
|
* exec("generic-hack.script", "foodnstuff");
|
||||||
* ```
|
*
|
||||||
* @example
|
|
||||||
* ```ts
|
|
||||||
* //The following example will try to run the script generic-hack.script on the joesguns server with 10 threads:
|
* //The following example will try to run the script generic-hack.script on the joesguns server with 10 threads:
|
||||||
* exec("generic-hack.script", "joesguns", 10);
|
* exec("generic-hack.script", "joesguns", 10);
|
||||||
* ```
|
*
|
||||||
* @example
|
|
||||||
* ```ts
|
|
||||||
* //This last example will try to run the script foo.script on the foodnstuff server with 5 threads. It will also pass the number 1 and the string “test” in as arguments to the script:
|
* //This last example will try to run the script foo.script on the foodnstuff server with 5 threads. It will also pass the number 1 and the string “test” in as arguments to the script:
|
||||||
* exec("foo.script", "foodnstuff", 5, 1, "test");
|
* exec("foo.script", "foodnstuff", 5, 1, "test");
|
||||||
* ```
|
* ```
|
||||||
|
* * @example
|
||||||
|
* ```ts
|
||||||
|
* // NS2:
|
||||||
|
* //The simplest way to use the exec command is to call it with just the script name and the target server. The following example will try to run generic-hack.script on the foodnstuff server:
|
||||||
|
* ns.exec("generic-hack.script", "foodnstuff");
|
||||||
|
*
|
||||||
|
* //The following example will try to run the script generic-hack.script on the joesguns server with 10 threads:
|
||||||
|
* ns.exec("generic-hack.script", "joesguns", 10);
|
||||||
|
*
|
||||||
|
* //This last example will try to run the script foo.script on the foodnstuff server with 5 threads. It will also pass the number 1 and the string “test” in as arguments to the script:
|
||||||
|
* ns.exec("foo.script", "foodnstuff", 5, 1, "test");
|
||||||
|
* ```
|
||||||
* @param script - Filename of script to execute.
|
* @param script - Filename of script to execute.
|
||||||
* @param host - Hostname of the `target server` on which to execute the script.
|
* @param host - Hostname of the `target server` on which to execute the script.
|
||||||
* @param numThreads - Optional thread count for new script. Set to 1 by default. Will be rounded to nearest integer.
|
* @param numThreads - Optional thread count for new script. Set to 1 by default. Will be rounded to nearest integer.
|
||||||
@ -4417,9 +4625,16 @@ export interface NS extends Singularity {
|
|||||||
*
|
*
|
||||||
* @example
|
* @example
|
||||||
* ```ts
|
* ```ts
|
||||||
|
* // NS1:
|
||||||
* //The following example will execute the script ‘foo.script’ with 10 threads and the arguments ‘foodnstuff’ and 90:
|
* //The following example will execute the script ‘foo.script’ with 10 threads and the arguments ‘foodnstuff’ and 90:
|
||||||
* spawn('foo.script', 10, 'foodnstuff', 90);
|
* spawn('foo.script', 10, 'foodnstuff', 90);
|
||||||
* ```
|
* ```
|
||||||
|
* @example
|
||||||
|
* ```ts
|
||||||
|
* // NS2:
|
||||||
|
* //The following example will execute the script ‘foo.script’ with 10 threads and the arguments ‘foodnstuff’ and 90:
|
||||||
|
* ns.spawn('foo.script', 10, 'foodnstuff', 90);
|
||||||
|
* ```
|
||||||
* @param script - Filename of script to execute.
|
* @param script - Filename of script to execute.
|
||||||
* @param numThreads - Number of threads to spawn new script with. Will be rounded to nearest integer.
|
* @param numThreads - Number of threads to spawn new script with. Will be rounded to nearest integer.
|
||||||
* @param args - Additional arguments to pass into the new script that is being run.
|
* @param args - Additional arguments to pass into the new script that is being run.
|
||||||
@ -4438,18 +4653,27 @@ export interface NS extends Singularity {
|
|||||||
*
|
*
|
||||||
* @example
|
* @example
|
||||||
* ```ts
|
* ```ts
|
||||||
|
* // NS1:
|
||||||
* //The following example will try to kill a script named foo.script on the foodnstuff server that was ran with no arguments:
|
* //The following example will try to kill a script named foo.script on the foodnstuff server that was ran with no arguments:
|
||||||
* kill("foo.script", "foodnstuff");
|
* kill("foo.script", "foodnstuff");
|
||||||
* ```
|
*
|
||||||
* @example
|
|
||||||
* ```ts
|
|
||||||
* //The following will try to kill a script named foo.script on the current server that was ran with no arguments:
|
* //The following will try to kill a script named foo.script on the current server that was ran with no arguments:
|
||||||
* kill("foo.script", getHostname());
|
* kill("foo.script", getHostname());
|
||||||
|
*
|
||||||
|
* //The following will try to kill a script named foo.script on the current server that was ran with the arguments 1 and “foodnstuff”:
|
||||||
|
* kill("foo.script", getHostname(), 1, "foodnstuff");
|
||||||
* ```
|
* ```
|
||||||
* @example
|
* @example
|
||||||
* ```ts
|
* ```ts
|
||||||
|
* // NS2:
|
||||||
|
* //The following example will try to kill a script named foo.script on the foodnstuff server that was ran with no arguments:
|
||||||
|
* ns.kill("foo.script", "foodnstuff");
|
||||||
|
*
|
||||||
|
* //The following will try to kill a script named foo.script on the current server that was ran with no arguments:
|
||||||
|
* ns.kill("foo.script", getHostname());
|
||||||
|
*
|
||||||
* //The following will try to kill a script named foo.script on the current server that was ran with the arguments 1 and “foodnstuff”:
|
* //The following will try to kill a script named foo.script on the current server that was ran with the arguments 1 and “foodnstuff”:
|
||||||
* kill("foo.script", getHostname(), 1, "foodnstuff");
|
* ns.kill("foo.script", getHostname(), 1, "foodnstuff");
|
||||||
* ```
|
* ```
|
||||||
* @param script - Filename or pid of the script to kill
|
* @param script - Filename or pid of the script to kill
|
||||||
* @param host - Hostname of the server on which to kill the script.
|
* @param host - Hostname of the server on which to kill the script.
|
||||||
@ -4489,17 +4713,26 @@ export interface NS extends Singularity {
|
|||||||
*
|
*
|
||||||
* @example
|
* @example
|
||||||
* ```ts
|
* ```ts
|
||||||
|
* // NS1:
|
||||||
* //Copies foo.lit from the helios server to the home computer:
|
* //Copies foo.lit from the helios server to the home computer:
|
||||||
* scp("foo.lit", "helios", "home");
|
* scp("foo.lit", "helios", "home");
|
||||||
* ```
|
*
|
||||||
* @example
|
|
||||||
* ```ts
|
|
||||||
* //Tries to copy three files from rothman-uni to home computer:
|
* //Tries to copy three files from rothman-uni to home computer:
|
||||||
* files = ["foo1.lit", "foo2.script", "foo3.script"];
|
* files = ["foo1.lit", "foo2.script", "foo3.script"];
|
||||||
* scp(files, "rothman-uni", "home");
|
* scp(files, "rothman-uni", "home");
|
||||||
* ```
|
* ```
|
||||||
* @example
|
* @example
|
||||||
* ```ts
|
* ```ts
|
||||||
|
* // NS2:
|
||||||
|
* //Copies foo.lit from the helios server to the home computer:
|
||||||
|
* await ns.scp("foo.lit", "helios", "home");
|
||||||
|
*
|
||||||
|
* //Tries to copy three files from rothman-uni to home computer:
|
||||||
|
* files = ["foo1.lit", "foo2.script", "foo3.script"];
|
||||||
|
* await ns.scp(files, "rothman-uni", "home");
|
||||||
|
* ```
|
||||||
|
* @example
|
||||||
|
* ```ts
|
||||||
* //ns2, copies files from home to a target server
|
* //ns2, copies files from home to a target server
|
||||||
* const server = ns.args[0];
|
* const server = ns.args[0];
|
||||||
* const files = ["hack.js","weaken.js","grow.js"];
|
* const files = ["hack.js","weaken.js","grow.js"];
|
||||||
@ -4535,13 +4768,20 @@ export interface NS extends Singularity {
|
|||||||
*
|
*
|
||||||
* @example
|
* @example
|
||||||
* ```ts
|
* ```ts
|
||||||
* //(using NetscriptJS (Netscript 2.0))
|
* // NS1:
|
||||||
* export async function main(ns) {
|
* const scripts = ps("home");
|
||||||
* const ps = ns.ps("home");
|
* for (let i = 0; i < scripts.length; ++i) {
|
||||||
* for (let i = 0; i < ps.length; ++i) {
|
* tprint(scripts[i].filename + ' ' + scripts[i].threads);
|
||||||
* ns.tprint(ps[i].filename + ' ' + ps[i].threads);
|
* tprint(scripts[i].args);
|
||||||
* ns.tprint(ps[i].args);
|
* }
|
||||||
* }
|
* ```
|
||||||
|
* @example
|
||||||
|
* ```ts
|
||||||
|
* // NS2:
|
||||||
|
* const ps = ns.ps("home");
|
||||||
|
* for (script of ps) {
|
||||||
|
* ns.tprint(`${script.filename} ${ps[i].threads}`);
|
||||||
|
* ns.tprint(script.args);
|
||||||
* }
|
* }
|
||||||
* ```
|
* ```
|
||||||
* @param host - Host address of the target server. If not specified, it will be the current server’s IP by default.
|
* @param host - Host address of the target server. If not specified, it will be the current server’s IP by default.
|
||||||
@ -4558,10 +4798,18 @@ export interface NS extends Singularity {
|
|||||||
*
|
*
|
||||||
* @example
|
* @example
|
||||||
* ```ts
|
* ```ts
|
||||||
|
* // NS1:
|
||||||
* if (hasRootAccess("foodnstuff") == false) {
|
* if (hasRootAccess("foodnstuff") == false) {
|
||||||
* nuke("foodnstuff");
|
* nuke("foodnstuff");
|
||||||
* }
|
* }
|
||||||
* ```
|
* ```
|
||||||
|
* @example
|
||||||
|
* ```ts
|
||||||
|
* // NS2:
|
||||||
|
* if (ns.hasRootAccess("foodnstuff") == false) {
|
||||||
|
* ns.nuke("foodnstuff");
|
||||||
|
* }
|
||||||
|
* ```
|
||||||
* @param host - Host of the target server
|
* @param host - Host of the target server
|
||||||
* @returns True if player has root access to the specified target server, and false otherwise.
|
* @returns True if player has root access to the specified target server, and false otherwise.
|
||||||
*/
|
*/
|
||||||
@ -4596,11 +4844,20 @@ export interface NS extends Singularity {
|
|||||||
*
|
*
|
||||||
* @example
|
* @example
|
||||||
* ```ts
|
* ```ts
|
||||||
* //Example of how this can be used:
|
* // NS1:
|
||||||
* mults = getHackingMultipliers();
|
* // Example of how this can be used:
|
||||||
|
* var mults = getHackingMultipliers();
|
||||||
* print(mults.chance);
|
* print(mults.chance);
|
||||||
* print(mults.growth);
|
* print(mults.growth);
|
||||||
* ```
|
* ```
|
||||||
|
* @example
|
||||||
|
* ```ts
|
||||||
|
* // NS2:
|
||||||
|
* // Example of how this can be used:
|
||||||
|
* const {chance, growth} = ns.getHackingMultipliers();
|
||||||
|
* print(chance);
|
||||||
|
* print(growth);
|
||||||
|
* ```
|
||||||
* @returns Object containing the Player’s hacking related multipliers.
|
* @returns Object containing the Player’s hacking related multipliers.
|
||||||
*/
|
*/
|
||||||
getHackingMultipliers(): HackingMultipliers;
|
getHackingMultipliers(): HackingMultipliers;
|
||||||
@ -4616,11 +4873,20 @@ export interface NS extends Singularity {
|
|||||||
*
|
*
|
||||||
* @example
|
* @example
|
||||||
* ```ts
|
* ```ts
|
||||||
* //Example of how this can be used:
|
* // NS1:
|
||||||
* mults = getHacknetMultipliers();
|
* // Example of how this can be used:
|
||||||
|
* var mults = getHacknetMultipliers();
|
||||||
* print(mults.production);
|
* print(mults.production);
|
||||||
* print(mults.purchaseCost);
|
* print(mults.purchaseCost);
|
||||||
* ```
|
* ```
|
||||||
|
* @example
|
||||||
|
* ```ts
|
||||||
|
* // NS2:
|
||||||
|
* // Example of how this can be used:
|
||||||
|
* const {production, purchaseCost} = ns.getHacknetMultipliers();
|
||||||
|
* print(production);
|
||||||
|
* print(purchaseCost);
|
||||||
|
* ```
|
||||||
* @returns Object containing the Player’s hacknet related multipliers.
|
* @returns Object containing the Player’s hacknet related multipliers.
|
||||||
*/
|
*/
|
||||||
getHacknetMultipliers(): HacknetMultipliers;
|
getHacknetMultipliers(): HacknetMultipliers;
|
||||||
@ -4645,9 +4911,16 @@ export interface NS extends Singularity {
|
|||||||
*
|
*
|
||||||
* @example
|
* @example
|
||||||
* ```ts
|
* ```ts
|
||||||
|
* // NS1:
|
||||||
* getServerMoneyAvailable("foodnstuff");
|
* getServerMoneyAvailable("foodnstuff");
|
||||||
* getServerMoneyAvailable("home"); //Returns player's money
|
* getServerMoneyAvailable("home"); //Returns player's money
|
||||||
* ```
|
* ```
|
||||||
|
* @example
|
||||||
|
* ```ts
|
||||||
|
* // NS2:
|
||||||
|
* ns.getServerMoneyAvailable("foodnstuff");
|
||||||
|
* ns.getServerMoneyAvailable("home"); // Returns player's money
|
||||||
|
* ```
|
||||||
* @param host - Host of target server
|
* @param host - Host of target server
|
||||||
* @returns Amount of money available on the server.
|
* @returns Amount of money available on the server.
|
||||||
*/
|
*/
|
||||||
@ -4734,9 +5007,15 @@ export interface NS extends Singularity {
|
|||||||
*
|
*
|
||||||
* @example
|
* @example
|
||||||
* ```ts
|
* ```ts
|
||||||
* res = getServerRam("helios");
|
* // NS1:
|
||||||
* totalRam = res[0];
|
* var serverRam = getServerRam("helios");
|
||||||
* ramUsed = res[1];
|
* var totalRam = serverRam[0];
|
||||||
|
* var ramUsed = serverRam[1];
|
||||||
|
* ```
|
||||||
|
* @example
|
||||||
|
* ```ts
|
||||||
|
* // NS2:
|
||||||
|
* const [totalRam, ramUsed] = ns.getServerRam("helios");
|
||||||
* ```
|
* ```
|
||||||
* @param host - Host of target server.
|
* @param host - Host of target server.
|
||||||
* @returns Array with total and used memory on the specified server.
|
* @returns Array with total and used memory on the specified server.
|
||||||
@ -4804,14 +5083,22 @@ export interface NS extends Singularity {
|
|||||||
*
|
*
|
||||||
* @example
|
* @example
|
||||||
* ```ts
|
* ```ts
|
||||||
|
* // NS1:
|
||||||
* //The function call will return true if the script named foo.script exists on the foodnstuff server, and false otherwise.
|
* //The function call will return true if the script named foo.script exists on the foodnstuff server, and false otherwise.
|
||||||
* fileExists("foo.script", "foodnstuff");
|
* fileExists("foo.script", "foodnstuff");
|
||||||
* ```
|
*
|
||||||
* @example
|
|
||||||
* ```ts
|
|
||||||
* //The function call will return true if the current server contains the FTPCrack.exe program, and false otherwise.
|
* //The function call will return true if the current server contains the FTPCrack.exe program, and false otherwise.
|
||||||
* fileExists("ftpcrack.exe");
|
* fileExists("ftpcrack.exe");
|
||||||
* ```
|
* ```
|
||||||
|
* * @example
|
||||||
|
* ```ts
|
||||||
|
* // NS2:
|
||||||
|
* // The function call will return true if the script named foo.script exists on the foodnstuff server, and false otherwise.
|
||||||
|
* ns.fileExists("foo.script", "foodnstuff");
|
||||||
|
*
|
||||||
|
* // The function call will return true if the current server contains the FTPCrack.exe program, and false otherwise.
|
||||||
|
* ns.fileExists("ftpcrack.exe");
|
||||||
|
* ```
|
||||||
* @param filename - Filename of file to check.
|
* @param filename - Filename of file to check.
|
||||||
* @param host - Host of target server. This is optional. If it is not specified then the function will use the current server as the target server.
|
* @param host - Host of target server. This is optional. If it is not specified then the function will use the current server as the target server.
|
||||||
* @returns True if specified file exists, and false otherwise.
|
* @returns True if specified file exists, and false otherwise.
|
||||||
@ -4828,18 +5115,27 @@ export interface NS extends Singularity {
|
|||||||
*
|
*
|
||||||
* @example
|
* @example
|
||||||
* ```ts
|
* ```ts
|
||||||
|
* // NS1:
|
||||||
* //The function call will return true if there is a script named foo.script with no arguments running on the foodnstuff server, and false otherwise:
|
* //The function call will return true if there is a script named foo.script with no arguments running on the foodnstuff server, and false otherwise:
|
||||||
* isRunning("foo.script", "foodnstuff");
|
* isRunning("foo.script", "foodnstuff");
|
||||||
* ```
|
*
|
||||||
* @example
|
|
||||||
* ```ts
|
|
||||||
* //The function call will return true if there is a script named foo.script with no arguments running on the current server, and false otherwise:
|
* //The function call will return true if there is a script named foo.script with no arguments running on the current server, and false otherwise:
|
||||||
* isRunning("foo.script", getHostname());
|
* isRunning("foo.script", getHostname());
|
||||||
|
*
|
||||||
|
* //The function call will return true if there is a script named foo.script running with the arguments 1, 5, and “test” (in that order) on the joesguns server, and false otherwise:
|
||||||
|
* isRunning("foo.script", "joesguns", 1, 5, "test");
|
||||||
* ```
|
* ```
|
||||||
* @example
|
* @example
|
||||||
* ```ts
|
* ```ts
|
||||||
|
* // NS2:
|
||||||
|
* //The function call will return true if there is a script named foo.script with no arguments running on the foodnstuff server, and false otherwise:
|
||||||
|
* ns.isRunning("foo.script", "foodnstuff");
|
||||||
|
*
|
||||||
|
* //The function call will return true if there is a script named foo.script with no arguments running on the current server, and false otherwise:
|
||||||
|
* ns.isRunning("foo.script", ns.getHostname());
|
||||||
|
*
|
||||||
* //The function call will return true if there is a script named foo.script running with the arguments 1, 5, and “test” (in that order) on the joesguns server, and false otherwise:
|
* //The function call will return true if there is a script named foo.script running with the arguments 1, 5, and “test” (in that order) on the joesguns server, and false otherwise:
|
||||||
* isRunning("foo.script", "joesguns", 1, 5, "test");
|
* ns.isRunning("foo.script", "joesguns", 1, 5, "test");
|
||||||
* ```
|
* ```
|
||||||
* @param script - Filename of script to check. This is case-sensitive.
|
* @param script - Filename of script to check. This is case-sensitive.
|
||||||
* @param host - Host of target server.
|
* @param host - Host of target server.
|
||||||
@ -4868,10 +5164,18 @@ export interface NS extends Singularity {
|
|||||||
*
|
*
|
||||||
* @example
|
* @example
|
||||||
* ```ts
|
* ```ts
|
||||||
|
* // NS1:
|
||||||
* for (i = 1; i <= 20; i++) {
|
* for (i = 1; i <= 20; i++) {
|
||||||
* tprint(i + " -- " + getPurchasedServerCost(Math.pow(2, i)));
|
* tprint(i + " -- " + getPurchasedServerCost(Math.pow(2, i)));
|
||||||
* }
|
* }
|
||||||
* ```
|
* ```
|
||||||
|
* @example
|
||||||
|
* ```ts
|
||||||
|
* // NS2:
|
||||||
|
* for (i = 1; i <= 20; i++) {
|
||||||
|
* ns.tprint(i + " -- " + ns.getPurchasedServerCost(Math.pow(2, i)));
|
||||||
|
* }
|
||||||
|
* ```
|
||||||
* @param ram - Amount of RAM of a potential purchased server. Must be a power of 2 (2, 4, 8, 16, etc.). Maximum value of 1048576 (2^20).
|
* @param ram - Amount of RAM of a potential purchased server. Must be a power of 2 (2, 4, 8, 16, etc.). Maximum value of 1048576 (2^20).
|
||||||
* @returns The cost to purchase a server with the specified amount of ram.
|
* @returns The cost to purchase a server with the specified amount of ram.
|
||||||
*/
|
*/
|
||||||
@ -4903,10 +5207,20 @@ export interface NS extends Singularity {
|
|||||||
*
|
*
|
||||||
* @example
|
* @example
|
||||||
* ```ts
|
* ```ts
|
||||||
* ram = 64;
|
* // NS1:
|
||||||
* hn = "pserv-";
|
* var ram = 64;
|
||||||
|
* var prefix = "pserv-";
|
||||||
* for (i = 0; i < 5; ++i) {
|
* for (i = 0; i < 5; ++i) {
|
||||||
* purchaseServer(hn + i, ram);
|
* purchaseServer(prefix + i, ram);
|
||||||
|
* }
|
||||||
|
* ```
|
||||||
|
* @example
|
||||||
|
* ```ts
|
||||||
|
* // NS2:
|
||||||
|
* const ram = 64;
|
||||||
|
* const prefix = "pserv-";
|
||||||
|
* for (i = 0; i < 5; ++i) {
|
||||||
|
* ns.purchaseServer(prefix + i, ram);
|
||||||
* }
|
* }
|
||||||
* ```
|
* ```
|
||||||
* @param hostname - Host of the purchased server.
|
* @param hostname - Host of the purchased server.
|
||||||
@ -5104,14 +5418,22 @@ export interface NS extends Singularity {
|
|||||||
*
|
*
|
||||||
* @example
|
* @example
|
||||||
* ```ts
|
* ```ts
|
||||||
|
* // NS1:
|
||||||
* //The function call will return true if there is any script named foo.script running on the foodnstuff server, and false otherwise:
|
* //The function call will return true if there is any script named foo.script running on the foodnstuff server, and false otherwise:
|
||||||
* scriptRunning("foo.script", "foodnstuff");
|
* scriptRunning("foo.script", "foodnstuff");
|
||||||
* ```
|
*
|
||||||
* @example
|
|
||||||
* ```ts
|
|
||||||
* //The function call will return true if there is any script named “foo.script” running on the current server, and false otherwise:
|
* //The function call will return true if there is any script named “foo.script” running on the current server, and false otherwise:
|
||||||
* scriptRunning("foo.script", getHostname());
|
* scriptRunning("foo.script", getHostname());
|
||||||
* ```
|
* ```
|
||||||
|
* * @example
|
||||||
|
* ```ts
|
||||||
|
* // NS2:
|
||||||
|
* //The function call will return true if there is any script named foo.script running on the foodnstuff server, and false otherwise:
|
||||||
|
* ns.scriptRunning("foo.script", "foodnstuff");
|
||||||
|
*
|
||||||
|
* //The function call will return true if there is any script named “foo.script” running on the current server, and false otherwise:
|
||||||
|
* ns.scriptRunning("foo.script", ns.getHostname());
|
||||||
|
* ```
|
||||||
* @param script - Filename of script to check. This is case-sensitive.
|
* @param script - Filename of script to check. This is case-sensitive.
|
||||||
* @param host - Host of target server.
|
* @param host - Host of target server.
|
||||||
* @returns True if the specified script is running, and false otherwise.
|
* @returns True if the specified script is running, and false otherwise.
|
||||||
@ -5360,8 +5682,14 @@ export interface NS extends Singularity {
|
|||||||
*
|
*
|
||||||
* @example
|
* @example
|
||||||
* ```ts
|
* ```ts
|
||||||
|
* // NS1:
|
||||||
* wget("https://raw.githubusercontent.com/danielyxie/bitburner/master/README.md", "game_readme.txt");
|
* wget("https://raw.githubusercontent.com/danielyxie/bitburner/master/README.md", "game_readme.txt");
|
||||||
* ```
|
* ```
|
||||||
|
* @example
|
||||||
|
* ```ts
|
||||||
|
* // NS2:
|
||||||
|
* await ns.wget("https://raw.githubusercontent.com/danielyxie/bitburner/master/README.md", "game_readme.txt");
|
||||||
|
* ```
|
||||||
* @param url - URL to pull data from.
|
* @param url - URL to pull data from.
|
||||||
* @param target - Filename to write data to. Must be script or text file.
|
* @param target - Filename to write data to. Must be script or text file.
|
||||||
* @param host - Optional hostname/ip of server for target file.
|
* @param host - Optional hostname/ip of server for target file.
|
||||||
@ -5394,10 +5722,18 @@ export interface NS extends Singularity {
|
|||||||
*
|
*
|
||||||
* @example
|
* @example
|
||||||
* ```ts
|
* ```ts
|
||||||
* mults = getBitNodeMultipliers();
|
* // NS1:
|
||||||
|
* var mults = getBitNodeMultipliers();
|
||||||
* print(mults.ServerMaxMoney);
|
* print(mults.ServerMaxMoney);
|
||||||
* print(mults.HackExpGain);
|
* print(mults.HackExpGain);
|
||||||
* ```
|
* ```
|
||||||
|
* @example
|
||||||
|
* ```ts
|
||||||
|
* // NS2:
|
||||||
|
* const {ServerMaxMoney, HackExpGain} = ns.getBitNodeMultipliers();
|
||||||
|
* print(ServerMaxMoney);
|
||||||
|
* print(HackExpGain);
|
||||||
|
* ```
|
||||||
* @returns Object containing the current BitNode multipliers.
|
* @returns Object containing the current BitNode multipliers.
|
||||||
*/
|
*/
|
||||||
getBitNodeMultipliers(): BitNodeMultipliers;
|
getBitNodeMultipliers(): BitNodeMultipliers;
|
||||||
@ -5451,6 +5787,17 @@ export interface NS extends Singularity {
|
|||||||
* ['help', false], // a default boolean means this flag is a boolean
|
* ['help', false], // a default boolean means this flag is a boolean
|
||||||
* ]);
|
* ]);
|
||||||
* tprint(data);
|
* tprint(data);
|
||||||
|
*
|
||||||
|
* // example.ns
|
||||||
|
* export async function main(ns) {
|
||||||
|
* const data = ns.flags([
|
||||||
|
* ['delay', 0], // a default number means this flag is a number
|
||||||
|
* ['server', 'foodnstuff'], // a default string means this flag is a string
|
||||||
|
* ['exclude', []], // a default array means this flag is a default array of string
|
||||||
|
* ['help', false], // a default boolean means this flag is a boolean
|
||||||
|
* ]);
|
||||||
|
* ns.tprint(data);
|
||||||
|
* }
|
||||||
*
|
*
|
||||||
* // [home ~/]> run example.script
|
* // [home ~/]> run example.script
|
||||||
* // {"_":[],"delay":0,"server":"foodnstuff","exclude":[],"help":false}
|
* // {"_":[],"delay":0,"server":"foodnstuff","exclude":[],"help":false}
|
||||||
|
Loading…
Reference in New Issue
Block a user