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 {
|
||||||
|
const userAgent = navigator.userAgent.toLowerCase();
|
||||||
|
if (userAgent.indexOf(' electron/') > -1) {
|
||||||
|
// Electron-specific code
|
||||||
setAchievements([]);
|
setAchievements([]);
|
||||||
initWebserver();
|
initWebserver();
|
||||||
setInterval(calculateAchievements, 5000);
|
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;
|
||||||
|
}
|
||||||
|
19
src/ScriptEditor/NetscriptDefinitions.d.ts
vendored
19
src/ScriptEditor/NetscriptDefinitions.d.ts
vendored
@ -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;
|
||||||
|
|
||||||
@ -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.
|
||||||
@ -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.
|
||||||
|
@ -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