mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-12-18 12:15:44 +01:00
Merge branch 'dev' of github.com:danielyxie/bitburner into dev
This commit is contained in:
commit
dfae337d26
7
dist/bitburner.d.ts
vendored
7
dist/bitburner.d.ts
vendored
@ -2720,7 +2720,7 @@ export declare interface NS extends Singularity {
|
|||||||
* @param args - Additional arguments to pass into the new script that is being run. Note that if any arguments are being passed into the new script, then the second argument numThreads must be filled in with a value.
|
* @param args - Additional arguments to pass into the new script that is being run. Note that if any arguments are being passed into the new script, then the second argument numThreads must be filled in with a value.
|
||||||
* @returns Returns the PID of a successfully started script, and 0 otherwise.
|
* @returns Returns the PID of a successfully started script, and 0 otherwise.
|
||||||
*/
|
*/
|
||||||
run(script: string, numThreads?: number, ...args: string[]): number;
|
run(script: string, numThreads?: number, ...args: Array<string | number | boolean>): number;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Start another script on any server.
|
* Start another script on any server.
|
||||||
@ -2760,7 +2760,7 @@ export declare interface NS extends Singularity {
|
|||||||
* @param args - Additional arguments to pass into the new script that is being run. Note that if any arguments are being passed into the new script, then the third argument numThreads must be filled in with a value.
|
* @param args - Additional arguments to pass into the new script that is being run. Note that if any arguments are being passed into the new script, then the third argument numThreads must be filled in with a value.
|
||||||
* @returns Returns the PID of a successfully started script, and 0 otherwise.
|
* @returns Returns the PID of a successfully started script, and 0 otherwise.
|
||||||
*/
|
*/
|
||||||
exec(script: string, host: string, numThreads?: number, ...args: string[]): number;
|
exec(script: string, host: string, numThreads?: number, ...args: Array<string | number | boolean>): number;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Terminate current script and start another in 10s.
|
* Terminate current script and start another in 10s.
|
||||||
@ -3678,8 +3678,9 @@ export declare interface NS extends Singularity {
|
|||||||
* Queue a toast (bottom-right notification).
|
* Queue a toast (bottom-right notification).
|
||||||
* @param msg - Message in the toast.
|
* @param msg - Message in the toast.
|
||||||
* @param variant - Type of toast, must be one of success, info, warning, error. Defaults to success.
|
* @param variant - Type of toast, must be one of success, info, warning, error. Defaults to success.
|
||||||
|
* @param duration - Duration of toast in ms, defaults to 2000
|
||||||
*/
|
*/
|
||||||
toast(msg: any, variant?: string): void;
|
toast(msg: any, variant?: string, duration?: number): void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Download a file from the internet.
|
* Download a file from the internet.
|
||||||
|
16
dist/vendor.bundle.js
vendored
16
dist/vendor.bundle.js
vendored
File diff suppressed because one or more lines are too long
@ -13,7 +13,8 @@ Server RAM
|
|||||||
Perhaps the most important property of a server to make note of is its RAM,
|
Perhaps the most important property of a server to make note of is its RAM,
|
||||||
which refers to how much memory is available on that machine. RAM is
|
which refers to how much memory is available on that machine. RAM is
|
||||||
important because it is required to run Scripts. More RAM allows
|
important because it is required to run Scripts. More RAM allows
|
||||||
the user to run more powerful and complicated scripts.
|
the user to run more powerful and complicated scripts as well as executing
|
||||||
|
a script with :ref:`more threads <gameplay_scripts_multithreadingscripts>`.
|
||||||
|
|
||||||
The `free`, `scan-analyze`, and `analyze` Terminal commands
|
The `free`, `scan-analyze`, and `analyze` Terminal commands
|
||||||
can be used to check how much RAM a server has.
|
can be used to check how much RAM a server has.
|
||||||
|
@ -520,10 +520,12 @@ will appear that simply says :code:`Work`. Click this to start working.
|
|||||||
Working at :code:`Joe's Guns` earns $110 per second and also grants some experience
|
Working at :code:`Joe's Guns` earns $110 per second and also grants some experience
|
||||||
for every stat except hacking.
|
for every stat except hacking.
|
||||||
|
|
||||||
Working for a company is completely passive. However, you will not be able to do anything
|
Working for a company is completely passive. You can choose to focus on your work, do
|
||||||
else in the game while you work. You can cancel working at any time. You'll notice that
|
something else simultaneously, or switch between those two. While you focus on work,
|
||||||
cancelling your work early causes you to lose out on some reputation gains, but
|
you will not be able to do anything else in the game. If you do something else meanwhile,
|
||||||
you shouldn't worry about this. Company reputation isn't important right now.
|
you will not gain reputation at the same speed. You can cancel working at any time.
|
||||||
|
You'll notice that cancelling your work early causes you to lose out on some reputation
|
||||||
|
gains, but you shouldn't worry about this. Company reputation isn't important right now.
|
||||||
|
|
||||||
Once your hacking hits level 75, you can visit :code:`Carmichael Security` in the city
|
Once your hacking hits level 75, you can visit :code:`Carmichael Security` in the city
|
||||||
and get a software job there. This job offers higher pay and also earns you
|
and get a software job there. This job offers higher pay and also earns you
|
||||||
@ -720,9 +722,10 @@ navigation menu, and from there select |CyberSec|. In the middle of
|
|||||||
the page there should be a button for :code:`Hacking Contracts`.
|
the page there should be a button for :code:`Hacking Contracts`.
|
||||||
Click it to start earning reputation for the |CyberSec| faction (as well
|
Click it to start earning reputation for the |CyberSec| faction (as well
|
||||||
as some hacking experience). The higher your hacking level, the more reputation you
|
as some hacking experience). The higher your hacking level, the more reputation you
|
||||||
will gain. Note that while you are working for a faction, you cannot interact with
|
will gain. Note that while you are working for a faction, you can choose to not interact
|
||||||
the rest of the game in any way. You can cancel your faction work at any time
|
with the rest of the game in any way to gain reputation at full speed. You can also select to
|
||||||
with no penalty.
|
do something else simultaneously, gaining reputation a bit more slowly, until you focus again.
|
||||||
|
You can cancel your faction work at any time with no penalty to your reputation gained so far.
|
||||||
|
|
||||||
Purchasing Upgrades and Augmentations
|
Purchasing Upgrades and Augmentations
|
||||||
-------------------------------------
|
-------------------------------------
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* eslint-disable @typescript-eslint/no-var-requires */
|
/* eslint-disable @typescript-eslint/no-var-requires */
|
||||||
const { app, BrowserWindow, shell } = require("electron");
|
const { app, BrowserWindow } = require("electron");
|
||||||
const log = require("electron-log");
|
const log = require("electron-log");
|
||||||
const utils = require("./utils");
|
const utils = require("./utils");
|
||||||
const achievements = require("./achievements");
|
const achievements = require("./achievements");
|
||||||
@ -31,9 +31,7 @@ async function createWindow(killall) {
|
|||||||
|
|
||||||
// and open every other protocols on the browser
|
// and open every other protocols on the browser
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
shell.openExternal(url);
|
utils.openExternal(url);
|
||||||
|
|
||||||
global.app_playerOpenedExternalLink = true;
|
|
||||||
});
|
});
|
||||||
window.webContents.backgroundThrottling = false;
|
window.webContents.backgroundThrottling = false;
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* eslint-disable @typescript-eslint/no-var-requires */
|
/* eslint-disable @typescript-eslint/no-var-requires */
|
||||||
const { Menu, clipboard } = require("electron");
|
const { Menu, clipboard, dialog } = require("electron");
|
||||||
const log = require("electron-log");
|
const log = require("electron-log");
|
||||||
const api = require("./api-server");
|
const api = require("./api-server");
|
||||||
const utils = require("./utils");
|
const utils = require("./utils");
|
||||||
@ -54,12 +54,21 @@ function getMenu(window) {
|
|||||||
{
|
{
|
||||||
label: api.isListening() ? 'Disable Server' : 'Enable Server',
|
label: api.isListening() ? 'Disable Server' : 'Enable Server',
|
||||||
click: (async () => {
|
click: (async () => {
|
||||||
|
let success = false;
|
||||||
try {
|
try {
|
||||||
await api.toggleServer();
|
await api.toggleServer();
|
||||||
|
success = true;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
log.error(error);
|
log.error(error);
|
||||||
utils.showErrorBox('Error Toggling Server', error);
|
utils.showErrorBox('Error Toggling Server', error);
|
||||||
}
|
}
|
||||||
|
if (success && api.isListening()) {
|
||||||
|
utils.writeToast(window, "Started API Server", "success");
|
||||||
|
} else if (success && !api.isListening()) {
|
||||||
|
utils.writeToast(window, "Stopped API Server", "success");
|
||||||
|
} else {
|
||||||
|
utils.writeToast(window, 'Error Toggling Server', "error");
|
||||||
|
}
|
||||||
refreshMenu(window);
|
refreshMenu(window);
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
@ -67,6 +76,11 @@ function getMenu(window) {
|
|||||||
label: api.isAutostart() ? 'Disable Autostart' : 'Enable Autostart',
|
label: api.isAutostart() ? 'Disable Autostart' : 'Enable Autostart',
|
||||||
click: (async () => {
|
click: (async () => {
|
||||||
api.toggleAutostart();
|
api.toggleAutostart();
|
||||||
|
if (api.isAutostart()) {
|
||||||
|
utils.writeToast(window, "Enabled API Server Autostart", "success");
|
||||||
|
} else {
|
||||||
|
utils.writeToast(window, "Disabled API Server Autostart", "success");
|
||||||
|
}
|
||||||
refreshMenu(window);
|
refreshMenu(window);
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
@ -76,8 +90,33 @@ function getMenu(window) {
|
|||||||
const token = api.getAuthenticationToken();
|
const token = api.getAuthenticationToken();
|
||||||
log.log('Wrote authentication token to clipboard');
|
log.log('Wrote authentication token to clipboard');
|
||||||
clipboard.writeText(token);
|
clipboard.writeText(token);
|
||||||
|
utils.writeToast(window, "Copied Authentication Token to Clipboard", "info");
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
type: 'separator',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Information',
|
||||||
|
click: () => {
|
||||||
|
dialog.showMessageBox({
|
||||||
|
type: 'info',
|
||||||
|
title: 'Bitburner > API Server Information',
|
||||||
|
message: 'The API Server is used to write script files to your in-game home.',
|
||||||
|
detail: 'There is an official Visual Studio Code extension that makes use of that feature.\n\n' +
|
||||||
|
'It allows you to write your script file in an external IDE and have them pushed over to the game automatically.\n' +
|
||||||
|
'If you want more information, head over to: https://github.com/bitburner-official/bitburner-vscode.',
|
||||||
|
buttons: ['Dismiss', 'Open Extension Link (GitHub)'],
|
||||||
|
defaultId: 0,
|
||||||
|
cancelId: 0,
|
||||||
|
noLink: true,
|
||||||
|
}).then(({response}) => {
|
||||||
|
if (response === 1) {
|
||||||
|
utils.openExternal('https://github.com/bitburner-official/bitburner-vscode');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* eslint-disable @typescript-eslint/no-var-requires */
|
/* eslint-disable @typescript-eslint/no-var-requires */
|
||||||
const { app, dialog } = require("electron");
|
const { app, dialog, shell } = require("electron");
|
||||||
const log = require("electron-log");
|
const log = require("electron-log");
|
||||||
|
|
||||||
const achievements = require("./achievements");
|
const achievements = require("./achievements");
|
||||||
@ -93,7 +93,23 @@ async function exportSave(window) {
|
|||||||
.executeJavaScript(`${exportSaveFromIndexedDb.toString()}; exportSaveFromIndexedDb();`, true);
|
.executeJavaScript(`${exportSaveFromIndexedDb.toString()}; exportSaveFromIndexedDb();`, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function writeTerminal(window, message, type = null) {
|
||||||
|
await window.webContents
|
||||||
|
.executeJavaScript(`window.appNotifier.terminal("${message}", "${type}");`, true)
|
||||||
|
}
|
||||||
|
|
||||||
|
async function writeToast(window, message, type = "info", duration = 2000) {
|
||||||
|
await window.webContents
|
||||||
|
.executeJavaScript(`window.appNotifier.toast("${message}", "${type}", ${duration});`, true)
|
||||||
|
}
|
||||||
|
|
||||||
|
function openExternal(url) {
|
||||||
|
shell.openExternal(url);
|
||||||
|
global.app_playerOpenedExternalLink = true;
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
reloadAndKill, showErrorBox, exportSave,
|
reloadAndKill, showErrorBox, exportSave,
|
||||||
attachUnresponsiveAppHandler, detachUnresponsiveAppHandler,
|
attachUnresponsiveAppHandler, detachUnresponsiveAppHandler,
|
||||||
|
openExternal, writeTerminal, writeToast,
|
||||||
}
|
}
|
||||||
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -9,7 +9,7 @@ Start another script on the current server.
|
|||||||
<b>Signature:</b>
|
<b>Signature:</b>
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
run(script: string, numThreads?: number, ...args: string[]): number;
|
run(script: string, numThreads?: number, ...args: Array<string | number | boolean>): number;
|
||||||
```
|
```
|
||||||
|
|
||||||
## Parameters
|
## Parameters
|
||||||
@ -18,7 +18,7 @@ run(script: string, numThreads?: number, ...args: string[]): number;
|
|||||||
| --- | --- | --- |
|
| --- | --- | --- |
|
||||||
| script | string | Filename of script to run. |
|
| script | string | Filename of script to run. |
|
||||||
| numThreads | number | Optional thread count for new script. Set to 1 by default. Will be rounded to nearest integer. |
|
| numThreads | number | Optional thread count for new script. Set to 1 by default. Will be rounded to nearest integer. |
|
||||||
| args | string\[\] | Additional arguments to pass into the new script that is being run. Note that if any arguments are being passed into the new script, then the second argument numThreads must be filled in with a value. |
|
| args | Array<string | number | boolean> | Additional arguments to pass into the new script that is being run. Note that if any arguments are being passed into the new script, then the second argument numThreads must be filled in with a value. |
|
||||||
|
|
||||||
<b>Returns:</b>
|
<b>Returns:</b>
|
||||||
|
|
||||||
|
@ -108,26 +108,32 @@ function WarehouseRoot(props: IProps): React.ReactElement {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const breakdownItems: string[] = [];
|
const breakdownItems: JSX.Element[] = [];
|
||||||
for (const matName in props.warehouse.materials) {
|
for (const matName in props.warehouse.materials) {
|
||||||
const mat = props.warehouse.materials[matName];
|
const mat = props.warehouse.materials[matName];
|
||||||
if (!MaterialSizes.hasOwnProperty(matName)) continue;
|
if (!MaterialSizes.hasOwnProperty(matName)) continue;
|
||||||
if (mat.qty === 0) continue;
|
if (mat.qty === 0) continue;
|
||||||
breakdownItems.push(`${matName}: ${numeralWrapper.format(mat.qty * MaterialSizes[matName], "0,0.0")}`);
|
breakdownItems.push(<>{matName}: {numeralWrapper.format(mat.qty * MaterialSizes[matName], "0,0.0")}</>);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const prodName in division.products) {
|
for (const prodName in division.products) {
|
||||||
const prod = division.products[prodName];
|
const prod = division.products[prodName];
|
||||||
if (prod === undefined) continue;
|
if (prod === undefined) continue;
|
||||||
breakdownItems.push(`${prodName}: ${numeralWrapper.format(prod.data[props.warehouse.loc][0] * prod.siz, "0,0.0")}`);
|
breakdownItems.push(<>{prodName}: {numeralWrapper.format(prod.data[props.warehouse.loc][0] * prod.siz, "0,0.0")}</>);
|
||||||
}
|
}
|
||||||
|
|
||||||
const breakdown = <>{breakdownItems.join('<br />')}</>
|
let breakdown;
|
||||||
|
if (breakdownItems && breakdownItems.length > 0) {
|
||||||
|
breakdown = breakdownItems.reduce(
|
||||||
|
(previous: JSX.Element, current: JSX.Element): JSX.Element => previous && <>{previous}<br />{current}</> || <>{current}</>);
|
||||||
|
} else {
|
||||||
|
breakdown = <>No items in storage.</>
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Paper>
|
<Paper>
|
||||||
<Box display="flex" alignItems="center">
|
<Box display="flex" alignItems="center">
|
||||||
<Tooltip title={props.warehouse.sizeUsed !== 0 ? <Typography>{breakdown}</Typography> : ""}>
|
<Tooltip title={props.warehouse.sizeUsed !== 0 ? <Typography><>{breakdown}</></Typography> : ""}>
|
||||||
<Typography color={props.warehouse.sizeUsed >= props.warehouse.size ? "error" : "primary"}>
|
<Typography color={props.warehouse.sizeUsed >= props.warehouse.size ? "error" : "primary"}>
|
||||||
Storage: {numeralWrapper.formatBigNumber(props.warehouse.sizeUsed)} /{" "}
|
Storage: {numeralWrapper.formatBigNumber(props.warehouse.sizeUsed)} /{" "}
|
||||||
{numeralWrapper.formatBigNumber(props.warehouse.size)}
|
{numeralWrapper.formatBigNumber(props.warehouse.size)}
|
||||||
|
@ -22,6 +22,9 @@ import { Server } from "./Server/Server";
|
|||||||
import { Router } from "./ui/GameRoot";
|
import { Router } from "./ui/GameRoot";
|
||||||
import { Page } from "./ui/Router";
|
import { Page } from "./ui/Router";
|
||||||
import { removeLeadingSlash } from "./Terminal/DirectoryHelpers";
|
import { removeLeadingSlash } from "./Terminal/DirectoryHelpers";
|
||||||
|
import { Terminal } from './Terminal';
|
||||||
|
import { SnackbarEvents } from "./ui/React/Snackbar";
|
||||||
|
import { IMap } from "./types";
|
||||||
|
|
||||||
interface Achievement {
|
interface Achievement {
|
||||||
ID: string;
|
ID: string;
|
||||||
@ -414,9 +417,14 @@ function calculateAchievements(): void {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function initElectron(): void {
|
export function initElectron(): void {
|
||||||
setAchievements([]);
|
const userAgent = navigator.userAgent.toLowerCase();
|
||||||
initWebserver();
|
if (userAgent.indexOf(' electron/') > -1) {
|
||||||
setInterval(calculateAchievements, 5000);
|
// Electron-specific code
|
||||||
|
setAchievements([]);
|
||||||
|
initWebserver();
|
||||||
|
setInterval(calculateAchievements, 5000);
|
||||||
|
initAppNotifier();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function initWebserver(): void {
|
function initWebserver(): void {
|
||||||
@ -446,3 +454,27 @@ function initWebserver(): void {
|
|||||||
return "not a script file";
|
return "not a script file";
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Expose certain alert functions to allow the wrapper to sends message to the game
|
||||||
|
function initAppNotifier(): void {
|
||||||
|
const funcs = {
|
||||||
|
terminal: (message: string, type?: string) => {
|
||||||
|
const typesFn: IMap<(s: string) => void> = {
|
||||||
|
info: Terminal.info,
|
||||||
|
warn: Terminal.warn,
|
||||||
|
error: Terminal.error,
|
||||||
|
success: Terminal.success
|
||||||
|
};
|
||||||
|
let fn;
|
||||||
|
if (type) fn = typesFn[type];
|
||||||
|
if (!fn) fn = Terminal.print;
|
||||||
|
fn.bind(Terminal)(message);
|
||||||
|
},
|
||||||
|
toast: (message: string, type: "info" | "success" | "warning" | "error" , duration = 2000) =>
|
||||||
|
SnackbarEvents.emit(message, type, duration),
|
||||||
|
}
|
||||||
|
|
||||||
|
// Will be consumud by the electron wrapper.
|
||||||
|
// @ts-ignore
|
||||||
|
window.appNotifier = funcs;
|
||||||
|
}
|
||||||
|
97
src/ScriptEditor/NetscriptDefinitions.d.ts
vendored
97
src/ScriptEditor/NetscriptDefinitions.d.ts
vendored
@ -1765,8 +1765,8 @@ export interface Singularity {
|
|||||||
* function will automatically cancel that action and give you your
|
* function will automatically cancel that action and give you your
|
||||||
* earnings.
|
* earnings.
|
||||||
*
|
*
|
||||||
* This function returns the number of milliseconds it takes to attempt the
|
* This function returns the number of milliseconds it takes to attempt the
|
||||||
* specified crime (e.g It takes 60 seconds to attempt the ‘Rob Store’ crime,
|
* specified crime (e.g It takes 60 seconds to attempt the ‘Rob Store’ crime,
|
||||||
* so running `commitCrime('rob store')` will return 60,000).
|
* so running `commitCrime('rob store')` will return 60,000).
|
||||||
*
|
*
|
||||||
* Warning: I do not recommend using the time returned from this function to try
|
* Warning: I do not recommend using the time returned from this function to try
|
||||||
@ -2305,7 +2305,7 @@ export interface Hacknet {
|
|||||||
*
|
*
|
||||||
* @example
|
* @example
|
||||||
* ```ts
|
* ```ts
|
||||||
* // NS1:
|
* // 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);
|
||||||
@ -2313,7 +2313,7 @@ export interface Hacknet {
|
|||||||
* ```
|
* ```
|
||||||
* @example
|
* @example
|
||||||
* ```ts
|
* ```ts
|
||||||
* // NS2:
|
* // NS2:
|
||||||
* const upgradeName = "Sell for Corporation Funds";
|
* const upgradeName = "Sell for Corporation Funds";
|
||||||
* if (ns.hacknet.numHashes() > ns.hacknet.hashCost(upgradeName)) {
|
* if (ns.hacknet.numHashes() > ns.hacknet.hashCost(upgradeName)) {
|
||||||
* ns.hacknet.spendHashes(upgName);
|
* ns.hacknet.spendHashes(upgName);
|
||||||
@ -2371,7 +2371,7 @@ export interface Hacknet {
|
|||||||
* ```
|
* ```
|
||||||
* @example
|
* @example
|
||||||
* ```ts
|
* ```ts
|
||||||
* // NS2:
|
* // NS2:
|
||||||
* const upgrades = ns.hacknet.getHashUpgrades(); // ["Sell for Money","Sell for Corporation Funds",...]
|
* 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
|
||||||
@ -4079,31 +4079,28 @@ export interface NS extends Singularity {
|
|||||||
hackAnalyzeThreads(host: string, hackAmount: number): number;
|
hackAnalyzeThreads(host: string, hackAmount: number): number;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the percent of money stolen with a single thread.
|
* Get the part of money stolen with a single thread.
|
||||||
* @remarks
|
* @remarks
|
||||||
* RAM cost: 1 GB
|
* RAM cost: 1 GB
|
||||||
*
|
*
|
||||||
* Returns the percentage of the specified server’s money you will steal with a single hack.
|
* Returns the part of the specified server’s money you will steal with a single thread hack.
|
||||||
* This value is returned in percentage form, not decimal
|
|
||||||
* (Netscript functions typically return in decimal form, but not this one).
|
|
||||||
* This percentage is influenced by the player's hacking skill.
|
|
||||||
*
|
*
|
||||||
* @example
|
* @example
|
||||||
* ```ts
|
* ```ts
|
||||||
* // NS1:
|
* // NS1:
|
||||||
* //For example, assume the following returns 0.01:
|
* //For example, assume the following returns 0.01:
|
||||||
* var hackAmount = 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.
|
* //This means that if hack the foodnstuff server using a single thread, then you will steal 1%, or 0.01 of its total money. If you hack using N threads, then you will steal N*0.01 times its total money.
|
||||||
* ```
|
* ```
|
||||||
* @example
|
* @example
|
||||||
* ```ts
|
* ```ts
|
||||||
* // NS2:
|
* // NS2:
|
||||||
* //For example, assume the following returns 0.01:
|
* //For example, assume the following returns 0.01:
|
||||||
* const hackAmount = ns.hackAnalyze("foodnstuff");
|
* 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 using a single thread, then you will steal 1%, or 0.01 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.
|
||||||
* @returns The percentage of money you will steal from the target server with a single hack.
|
* @returns The part of money you will steal from the target server with a single thread hack.
|
||||||
*/
|
*/
|
||||||
hackAnalyze(host: string): number;
|
hackAnalyze(host: string): number;
|
||||||
|
|
||||||
@ -4304,10 +4301,10 @@ export interface NS extends Singularity {
|
|||||||
* // NS1:
|
* // 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");
|
||||||
*
|
*
|
||||||
* //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"]
|
* //Open logs from foo.script on the foodnstuff server that was run with the arguments [1, "test"]
|
||||||
* getScriptLogs("foo.script", "foodnstuff", 1, "test");
|
* getScriptLogs("foo.script", "foodnstuff", 1, "test");
|
||||||
* ```
|
* ```
|
||||||
@ -4316,10 +4313,10 @@ export interface NS extends Singularity {
|
|||||||
* // NS2:
|
* // NS2:
|
||||||
* //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
|
||||||
* ns.getScriptLogs("foo.script");
|
* ns.getScriptLogs("foo.script");
|
||||||
*
|
*
|
||||||
* //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
|
||||||
* ns.getScriptLogs("foo.script", "foodnstuff");
|
* 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"]
|
||||||
* ns.getScriptLogs("foo.script", "foodnstuff", 1, "test");
|
* ns.getScriptLogs("foo.script", "foodnstuff", 1, "test");
|
||||||
* ```
|
* ```
|
||||||
@ -4347,10 +4344,10 @@ export interface NS extends Singularity {
|
|||||||
* // NS1:
|
* // 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");
|
||||||
*
|
*
|
||||||
* //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"]
|
* //Get logs from foo.script on the foodnstuff server that was run with the arguments [1, "test"]
|
||||||
* tail("foo.script", "foodnstuff", 1, "test");
|
* tail("foo.script", "foodnstuff", 1, "test");
|
||||||
* ```
|
* ```
|
||||||
@ -4359,10 +4356,10 @@ export interface NS extends Singularity {
|
|||||||
* // NS2:
|
* // NS2:
|
||||||
* //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
|
||||||
* ns.tail("foo.script");
|
* ns.tail("foo.script");
|
||||||
*
|
*
|
||||||
* //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
|
||||||
* ns.tail("foo.script", "foodnstuff");
|
* 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"]
|
||||||
* ns.tail("foo.script", "foodnstuff", 1, "test");
|
* ns.tail("foo.script", "foodnstuff", 1, "test");
|
||||||
* ```
|
* ```
|
||||||
@ -4536,10 +4533,10 @@ export interface NS extends Singularity {
|
|||||||
* // NS1:
|
* // 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");
|
||||||
*
|
*
|
||||||
* //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:
|
* //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');
|
* run("foo.script", 1, 'foodnstuff');
|
||||||
* ```
|
* ```
|
||||||
@ -4548,10 +4545,10 @@ export interface NS extends Singularity {
|
|||||||
* // NS2:
|
* // 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:
|
* //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");
|
* ns.run("foo.script");
|
||||||
*
|
*
|
||||||
* //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:
|
||||||
* ns.run("foo.script", 5);
|
* 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:
|
||||||
* ns.run("foo.script", 1, 'foodnstuff');
|
* ns.run("foo.script", 1, 'foodnstuff');
|
||||||
* ```
|
* ```
|
||||||
@ -4560,7 +4557,7 @@ export interface NS extends Singularity {
|
|||||||
* @param args - Additional arguments to pass into the new script that is being run. Note that if any arguments are being passed into the new script, then the second argument numThreads must be filled in with a value.
|
* @param args - Additional arguments to pass into the new script that is being run. Note that if any arguments are being passed into the new script, then the second argument numThreads must be filled in with a value.
|
||||||
* @returns Returns the PID of a successfully started script, and 0 otherwise.
|
* @returns Returns the PID of a successfully started script, and 0 otherwise.
|
||||||
*/
|
*/
|
||||||
run(script: string, numThreads?: number, ...args: string[]): number;
|
run(script: string, numThreads?: number, ...args: Array<string | number | boolean>): number;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Start another script on any server.
|
* Start another script on any server.
|
||||||
@ -4584,10 +4581,10 @@ export interface NS extends Singularity {
|
|||||||
* // NS1:
|
* // 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");
|
||||||
*
|
*
|
||||||
* //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);
|
||||||
*
|
*
|
||||||
* //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");
|
||||||
* ```
|
* ```
|
||||||
@ -4596,10 +4593,10 @@ export interface NS extends Singularity {
|
|||||||
* // NS2:
|
* // 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:
|
* //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");
|
* 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:
|
* //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);
|
* 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:
|
* //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");
|
* ns.exec("foo.script", "foodnstuff", 5, 1, "test");
|
||||||
* ```
|
* ```
|
||||||
@ -4656,10 +4653,10 @@ export interface NS extends Singularity {
|
|||||||
* // NS1:
|
* // 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");
|
||||||
*
|
*
|
||||||
* //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”:
|
* //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");
|
* kill("foo.script", getHostname(), 1, "foodnstuff");
|
||||||
* ```
|
* ```
|
||||||
@ -4668,10 +4665,10 @@ export interface NS extends Singularity {
|
|||||||
* // NS2:
|
* // NS2:
|
||||||
* //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:
|
||||||
* ns.kill("foo.script", "foodnstuff");
|
* 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:
|
* //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());
|
* 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”:
|
||||||
* ns.kill("foo.script", getHostname(), 1, "foodnstuff");
|
* ns.kill("foo.script", getHostname(), 1, "foodnstuff");
|
||||||
* ```
|
* ```
|
||||||
@ -4680,9 +4677,9 @@ export interface NS extends Singularity {
|
|||||||
* @param args - Arguments to identify which script to kill.
|
* @param args - Arguments to identify which script to kill.
|
||||||
* @returns True if the script is successfully killed, and false otherwise.
|
* @returns True if the script is successfully killed, and false otherwise.
|
||||||
*/
|
*/
|
||||||
kill(script: number): boolean;
|
kill(script: number): boolean;
|
||||||
kill(script: string, host: string, ...args: string[]): boolean;
|
kill(script: string, host: string, ...args: string[]): boolean;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Terminate all scripts on a server.
|
* Terminate all scripts on a server.
|
||||||
* @remarks
|
* @remarks
|
||||||
@ -4718,7 +4715,7 @@ export interface NS extends Singularity {
|
|||||||
* // NS1:
|
* // 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");
|
||||||
*
|
*
|
||||||
* //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");
|
||||||
@ -4728,7 +4725,7 @@ export interface NS extends Singularity {
|
|||||||
* // NS2:
|
* // NS2:
|
||||||
* //Copies foo.lit from the helios server to the home computer:
|
* //Copies foo.lit from the helios server to the home computer:
|
||||||
* await ns.scp("foo.lit", "helios", "home");
|
* await ns.scp("foo.lit", "helios", "home");
|
||||||
*
|
*
|
||||||
* //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"];
|
||||||
* await ns.scp(files, "rothman-uni", "home");
|
* await ns.scp(files, "rothman-uni", "home");
|
||||||
@ -5088,7 +5085,7 @@ export interface NS extends Singularity {
|
|||||||
* // NS1:
|
* // 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");
|
||||||
*
|
*
|
||||||
* //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");
|
||||||
* ```
|
* ```
|
||||||
@ -5097,7 +5094,7 @@ export interface NS extends Singularity {
|
|||||||
* // NS2:
|
* // NS2:
|
||||||
* // 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.
|
||||||
* ns.fileExists("foo.script", "foodnstuff");
|
* ns.fileExists("foo.script", "foodnstuff");
|
||||||
*
|
*
|
||||||
* // 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.
|
||||||
* ns.fileExists("ftpcrack.exe");
|
* ns.fileExists("ftpcrack.exe");
|
||||||
* ```
|
* ```
|
||||||
@ -5120,10 +5117,10 @@ export interface NS extends Singularity {
|
|||||||
* // NS1:
|
* // 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");
|
||||||
*
|
*
|
||||||
* //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:
|
* //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");
|
* isRunning("foo.script", "joesguns", 1, 5, "test");
|
||||||
* ```
|
* ```
|
||||||
@ -5132,10 +5129,10 @@ export interface NS extends Singularity {
|
|||||||
* // NS2:
|
* // 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:
|
* //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");
|
* 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:
|
* //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());
|
* 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:
|
||||||
* ns.isRunning("foo.script", "joesguns", 1, 5, "test");
|
* ns.isRunning("foo.script", "joesguns", 1, 5, "test");
|
||||||
* ```
|
* ```
|
||||||
@ -5155,7 +5152,7 @@ export interface NS extends Singularity {
|
|||||||
*
|
*
|
||||||
* @returns info about a running script
|
* @returns info about a running script
|
||||||
*/
|
*/
|
||||||
getRunningScript(filename: string | number, hostname: string, ...args: (string | number)[]): RunningScript;
|
getRunningScript(filename?: string | number, hostname?: string, ...args: (string | number)[]): RunningScript;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get cost of purchasing a server.
|
* Get cost of purchasing a server.
|
||||||
@ -5289,7 +5286,7 @@ export interface NS extends Singularity {
|
|||||||
* @param data - Data to write.
|
* @param data - Data to write.
|
||||||
* @param mode - Defines the write mode. Only valid when writing to text files.
|
* @param mode - Defines the write mode. Only valid when writing to text files.
|
||||||
*/
|
*/
|
||||||
write(handle: string, data?: string[] | number, mode?: "w" | "a"): Promise<void>;
|
write(handle: string, data?: string[] | number | string, mode?: "w" | "a"): Promise<void>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attempt to write to a port.
|
* Attempt to write to a port.
|
||||||
@ -5423,7 +5420,7 @@ export interface NS extends Singularity {
|
|||||||
* // NS1:
|
* // 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");
|
||||||
*
|
*
|
||||||
* //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());
|
||||||
* ```
|
* ```
|
||||||
@ -5432,7 +5429,7 @@ export interface NS extends Singularity {
|
|||||||
* // NS2:
|
* // NS2:
|
||||||
* //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:
|
||||||
* ns.scriptRunning("foo.script", "foodnstuff");
|
* 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:
|
* //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());
|
* ns.scriptRunning("foo.script", ns.getHostname());
|
||||||
* ```
|
* ```
|
||||||
@ -5785,7 +5782,7 @@ 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
|
* // example.ns
|
||||||
* export async function main(ns) {
|
* export async function main(ns) {
|
||||||
* const data = ns.flags([
|
* const data = ns.flags([
|
||||||
|
@ -221,13 +221,6 @@ export function GameOptionsRoot(props: IProps): React.ReactElement {
|
|||||||
}
|
}
|
||||||
const contents = result;
|
const contents = result;
|
||||||
|
|
||||||
// https://stackoverflow.com/a/35002237
|
|
||||||
const base64regex = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/;
|
|
||||||
if (!base64regex.test(contents)) {
|
|
||||||
SnackbarEvents.emit("Save game was not a base64 string", "error", 5000);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
let newSave;
|
let newSave;
|
||||||
try {
|
try {
|
||||||
newSave = window.atob(contents);
|
newSave = window.atob(contents);
|
||||||
@ -237,7 +230,7 @@ export function GameOptionsRoot(props: IProps): React.ReactElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!newSave || newSave === '') {
|
if (!newSave || newSave === '') {
|
||||||
SnackbarEvents.emit("Save game had not content", "error", 5000);
|
SnackbarEvents.emit("Save game had not content or was not base64 encoded", "error", 5000);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user