mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-23 08:03:48 +01:00
Merge pull request #1550 from danielyxie/dev
Throw error when trying to pass non-string/number to other scripts
This commit is contained in:
commit
2ffb435598
26
dist/vendor.bundle.js
vendored
26
dist/vendor.bundle.js
vendored
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -3,35 +3,17 @@ import { IMap } from "../types";
|
|||||||
|
|
||||||
export const GeneralActions: IMap<Action> = {};
|
export const GeneralActions: IMap<Action> = {};
|
||||||
|
|
||||||
(function () {
|
let actionNames : Array<string> = [
|
||||||
// General Actions
|
"Training",
|
||||||
let actionName;
|
"Field Analysis",
|
||||||
actionName = "Training";
|
"Recruitment",
|
||||||
GeneralActions[actionName] = new Action({
|
"Diplomacy",
|
||||||
name: actionName,
|
"Hyperbolic Regeneration Chamber",
|
||||||
});
|
"Incite Violence"
|
||||||
|
];
|
||||||
|
|
||||||
actionName = "Field Analysis";
|
for (let actionName of actionNames){
|
||||||
GeneralActions[actionName] = new Action({
|
GeneralActions[actionName] = new Action({
|
||||||
name: actionName,
|
name: actionName,
|
||||||
});
|
});
|
||||||
|
}
|
||||||
actionName = "Recruitment";
|
|
||||||
GeneralActions[actionName] = new Action({
|
|
||||||
name: actionName,
|
|
||||||
});
|
|
||||||
|
|
||||||
actionName = "Diplomacy";
|
|
||||||
GeneralActions[actionName] = new Action({
|
|
||||||
name: actionName,
|
|
||||||
});
|
|
||||||
|
|
||||||
actionName = "Hyperbolic Regeneration Chamber";
|
|
||||||
GeneralActions[actionName] = new Action({
|
|
||||||
name: actionName,
|
|
||||||
});
|
|
||||||
actionName = "Incite Violence";
|
|
||||||
GeneralActions[actionName] = new Action({
|
|
||||||
name: actionName,
|
|
||||||
});
|
|
||||||
})();
|
|
@ -16,7 +16,6 @@ interface IMarketTA2Props {
|
|||||||
function MarketTA2(props: IMarketTA2Props): React.ReactElement {
|
function MarketTA2(props: IMarketTA2Props): React.ReactElement {
|
||||||
const division = useDivision();
|
const division = useDivision();
|
||||||
if (!division.hasResearch("Market-TA.II")) return <></>;
|
if (!division.hasResearch("Market-TA.II")) return <></>;
|
||||||
props.mat.marketTa2 = false;
|
|
||||||
const [newCost, setNewCost] = useState<number>(props.mat.bCost);
|
const [newCost, setNewCost] = useState<number>(props.mat.bCost);
|
||||||
const setRerender = useState(false)[1];
|
const setRerender = useState(false)[1];
|
||||||
function rerender(): void {
|
function rerender(): void {
|
||||||
@ -88,7 +87,6 @@ interface IProps {
|
|||||||
|
|
||||||
// Create a popup that lets the player use the Market TA research for Materials
|
// Create a popup that lets the player use the Market TA research for Materials
|
||||||
export function MaterialMarketTaModal(props: IProps): React.ReactElement {
|
export function MaterialMarketTaModal(props: IProps): React.ReactElement {
|
||||||
const division = useDivision();
|
|
||||||
const setRerender = useState(false)[1];
|
const setRerender = useState(false)[1];
|
||||||
function rerender(): void {
|
function rerender(): void {
|
||||||
setRerender((old) => !old);
|
setRerender((old) => !old);
|
||||||
@ -102,13 +100,12 @@ export function MaterialMarketTaModal(props: IProps): React.ReactElement {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<Modal open={props.open} onClose={props.onClose}>
|
<Modal open={props.open} onClose={props.onClose}>
|
||||||
{!division.hasResearch("Market-TA.II") && (
|
|
||||||
<>
|
<>
|
||||||
<Typography variant="h4">Market-TA.I</Typography>
|
<Typography variant="h4">Market-TA.I</Typography>
|
||||||
<Typography>
|
<Typography>
|
||||||
The maximum sale price you can mark this up to is{" "}
|
The maximum sale price you can mark this up to is {numeralWrapper.formatMoney(props.mat.bCost + markupLimit)}.
|
||||||
{numeralWrapper.formatMoney(props.mat.bCost + markupLimit)}. This means that if you set the sale price
|
This means that if you set the sale price higher than this, you will begin to experience a loss in number of
|
||||||
higher than this, you will begin to experience a loss in number of sales
|
sales
|
||||||
</Typography>
|
</Typography>
|
||||||
|
|
||||||
<FormControlLabel
|
<FormControlLabel
|
||||||
@ -127,7 +124,7 @@ export function MaterialMarketTaModal(props: IProps): React.ReactElement {
|
|||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
</>
|
</>
|
||||||
)}
|
|
||||||
<MarketTA2 mat={props.mat} />
|
<MarketTA2 mat={props.mat} />
|
||||||
</Modal>
|
</Modal>
|
||||||
);
|
);
|
||||||
|
@ -16,7 +16,6 @@ interface ITa2Props {
|
|||||||
function MarketTA2(props: ITa2Props): React.ReactElement {
|
function MarketTA2(props: ITa2Props): React.ReactElement {
|
||||||
const division = useDivision();
|
const division = useDivision();
|
||||||
if (!division.hasResearch("Market-TA.II")) return <></>;
|
if (!division.hasResearch("Market-TA.II")) return <></>;
|
||||||
props.product.marketTa1 = false;
|
|
||||||
const markupLimit = props.product.rat / props.product.mku;
|
const markupLimit = props.product.rat / props.product.mku;
|
||||||
const [value, setValue] = useState(props.product.pCost);
|
const [value, setValue] = useState(props.product.pCost);
|
||||||
const setRerender = useState(false)[1];
|
const setRerender = useState(false)[1];
|
||||||
@ -93,7 +92,6 @@ export function ProductMarketTaModal(props: IProps): React.ReactElement {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<Modal open={props.open} onClose={props.onClose}>
|
<Modal open={props.open} onClose={props.onClose}>
|
||||||
{!division.hasResearch("Market-TA.II") && (
|
|
||||||
<>
|
<>
|
||||||
<Typography variant="h4">Market-TA.I</Typography>
|
<Typography variant="h4">Market-TA.I</Typography>
|
||||||
<Typography>
|
<Typography>
|
||||||
@ -118,7 +116,7 @@ export function ProductMarketTaModal(props: IProps): React.ReactElement {
|
|||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
</>
|
</>
|
||||||
)}
|
|
||||||
<MarketTA2 product={props.product} />
|
<MarketTA2 product={props.product} />
|
||||||
</Modal>
|
</Modal>
|
||||||
);
|
);
|
||||||
|
@ -646,9 +646,9 @@ export function runScriptFromScript(
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
args = args.map((arg) => {
|
args.forEach((arg) => {
|
||||||
if (typeof arg === "number") return arg;
|
if (typeof arg !== "string" && typeof arg !== "number")
|
||||||
return arg + ""; // force cast to string
|
throw new Error("Only strings and numbers can be passed as arguments to otherscripts.");
|
||||||
});
|
});
|
||||||
|
|
||||||
// Check if the script is already running
|
// Check if the script is already running
|
||||||
|
@ -265,7 +265,7 @@ export function InteractiveTutorialRoot(): React.ReactElement {
|
|||||||
content: (
|
content: (
|
||||||
<>
|
<>
|
||||||
<Typography>You now have root access! You can hack the server using </Typography>
|
<Typography>You now have root access! You can hack the server using </Typography>
|
||||||
<Typography classes={{ root: classes.textfield }}>{"[home ~/]> hack"}</Typography>
|
<Typography classes={{ root: classes.textfield }}>{"[n00dles ~/]> hack"}</Typography>
|
||||||
|
|
||||||
<Typography> Try doing that now.</Typography>
|
<Typography> Try doing that now.</Typography>
|
||||||
</>
|
</>
|
||||||
@ -296,7 +296,7 @@ export function InteractiveTutorialRoot(): React.ReactElement {
|
|||||||
content: (
|
content: (
|
||||||
<>
|
<>
|
||||||
<Typography>From any server you can get back home using</Typography>
|
<Typography>From any server you can get back home using</Typography>
|
||||||
<Typography classes={{ root: classes.textfield }}>{"[home ~/]> home"}</Typography>
|
<Typography classes={{ root: classes.textfield }}>{"[n00dles ~/]> home"}</Typography>
|
||||||
|
|
||||||
<Typography>Let's head home before creating our first script!</Typography>
|
<Typography>Let's head home before creating our first script!</Typography>
|
||||||
</>
|
</>
|
||||||
@ -468,7 +468,7 @@ export function InteractiveTutorialRoot(): React.ReactElement {
|
|||||||
[iTutorialSteps.HacknetNodesIntroduction as number]: {
|
[iTutorialSteps.HacknetNodesIntroduction as number]: {
|
||||||
content: (
|
content: (
|
||||||
<Typography>
|
<Typography>
|
||||||
here you can purchase new Hacknet Nodes and upgrade your existing ones. Let's purchase a new one now.
|
Here you can purchase new Hacknet Nodes and upgrade your existing ones. Let's purchase a new one now.
|
||||||
</Typography>
|
</Typography>
|
||||||
),
|
),
|
||||||
canNext: true,
|
canNext: true,
|
||||||
|
@ -11,8 +11,6 @@ import Table from "@mui/material/Table";
|
|||||||
import TableBody from "@mui/material/TableBody";
|
import TableBody from "@mui/material/TableBody";
|
||||||
import TableCell from "@mui/material/TableCell";
|
import TableCell from "@mui/material/TableCell";
|
||||||
import TableRow from "@mui/material/TableRow";
|
import TableRow from "@mui/material/TableRow";
|
||||||
import Paper from "@mui/material/Paper";
|
|
||||||
import Box from "@mui/material/Box";
|
|
||||||
import Typography from "@mui/material/Typography";
|
import Typography from "@mui/material/Typography";
|
||||||
import Button from "@mui/material/Button";
|
import Button from "@mui/material/Button";
|
||||||
import IconButton from "@mui/material/IconButton";
|
import IconButton from "@mui/material/IconButton";
|
||||||
@ -150,9 +148,7 @@ export function CharacterOverview({ save }: IProps): React.ReactElement {
|
|||||||
|
|
||||||
const classes = useStyles();
|
const classes = useStyles();
|
||||||
return (
|
return (
|
||||||
<Paper square>
|
<Table sx={{ display: "block", m: 1 }}>
|
||||||
<Box m={1}>
|
|
||||||
<Table size="small">
|
|
||||||
<TableBody>
|
<TableBody>
|
||||||
<TableRow>
|
<TableRow>
|
||||||
<TableCell component="th" scope="row" classes={{ root: classes.cellNone }}>
|
<TableCell component="th" scope="row" classes={{ root: classes.cellNone }}>
|
||||||
@ -191,9 +187,7 @@ export function CharacterOverview({ save }: IProps): React.ReactElement {
|
|||||||
<Typography classes={{ root: classes.hack }}>Hack </Typography>
|
<Typography classes={{ root: classes.hack }}>Hack </Typography>
|
||||||
</TableCell>
|
</TableCell>
|
||||||
<TableCell align="right" classes={{ root: classes.cell }}>
|
<TableCell align="right" classes={{ root: classes.cell }}>
|
||||||
<Typography classes={{ root: classes.hack }}>
|
<Typography classes={{ root: classes.hack }}>{numeralWrapper.formatSkill(player.hacking_skill)}</Typography>
|
||||||
{numeralWrapper.formatSkill(player.hacking_skill)}
|
|
||||||
</Typography>
|
|
||||||
</TableCell>
|
</TableCell>
|
||||||
<TableCell align="right" classes={{ root: classes.cell }}>
|
<TableCell align="right" classes={{ root: classes.cell }}>
|
||||||
<Typography id="overview-hack-hook" classes={{ root: classes.hack }}>
|
<Typography id="overview-hack-hook" classes={{ root: classes.hack }}>
|
||||||
@ -207,9 +201,7 @@ export function CharacterOverview({ save }: IProps): React.ReactElement {
|
|||||||
<Typography classes={{ root: classes.combat }}>Str </Typography>
|
<Typography classes={{ root: classes.combat }}>Str </Typography>
|
||||||
</TableCell>
|
</TableCell>
|
||||||
<TableCell align="right" classes={{ root: classes.cellNone }}>
|
<TableCell align="right" classes={{ root: classes.cellNone }}>
|
||||||
<Typography classes={{ root: classes.combat }}>
|
<Typography classes={{ root: classes.combat }}>{numeralWrapper.formatSkill(player.strength)}</Typography>
|
||||||
{numeralWrapper.formatSkill(player.strength)}
|
|
||||||
</Typography>
|
|
||||||
</TableCell>
|
</TableCell>
|
||||||
<TableCell align="right" classes={{ root: classes.cellNone }}>
|
<TableCell align="right" classes={{ root: classes.cellNone }}>
|
||||||
<Typography id="overview-str-hook" classes={{ root: classes.combat }}>
|
<Typography id="overview-str-hook" classes={{ root: classes.combat }}>
|
||||||
@ -237,9 +229,7 @@ export function CharacterOverview({ save }: IProps): React.ReactElement {
|
|||||||
<Typography classes={{ root: classes.combat }}>Dex </Typography>
|
<Typography classes={{ root: classes.combat }}>Dex </Typography>
|
||||||
</TableCell>
|
</TableCell>
|
||||||
<TableCell align="right" classes={{ root: classes.cellNone }}>
|
<TableCell align="right" classes={{ root: classes.cellNone }}>
|
||||||
<Typography classes={{ root: classes.combat }}>
|
<Typography classes={{ root: classes.combat }}>{numeralWrapper.formatSkill(player.dexterity)}</Typography>
|
||||||
{numeralWrapper.formatSkill(player.dexterity)}
|
|
||||||
</Typography>
|
|
||||||
</TableCell>
|
</TableCell>
|
||||||
<TableCell align="right" classes={{ root: classes.cellNone }}>
|
<TableCell align="right" classes={{ root: classes.cellNone }}>
|
||||||
<Typography id="overview-dex-hook" classes={{ root: classes.combat }}>
|
<Typography id="overview-dex-hook" classes={{ root: classes.combat }}>
|
||||||
@ -305,7 +295,5 @@ export function CharacterOverview({ save }: IProps): React.ReactElement {
|
|||||||
</TableRow>
|
</TableRow>
|
||||||
</TableBody>
|
</TableBody>
|
||||||
</Table>
|
</Table>
|
||||||
</Box>
|
|
||||||
</Paper>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -1,17 +1,29 @@
|
|||||||
import React, { useState } from "react";
|
import React, { useState } from "react";
|
||||||
|
|
||||||
import makeStyles from "@mui/styles/makeStyles";
|
import makeStyles from "@mui/styles/makeStyles";
|
||||||
import Box from "@mui/material/Box";
|
|
||||||
import Collapse from "@mui/material/Collapse";
|
import Collapse from "@mui/material/Collapse";
|
||||||
import Fab from "@mui/material/Fab";
|
import Fab from "@mui/material/Fab";
|
||||||
|
import Paper from "@mui/material/Paper";
|
||||||
import VisibilityOffIcon from "@mui/icons-material/VisibilityOff";
|
import VisibilityOffIcon from "@mui/icons-material/VisibilityOff";
|
||||||
import VisibilityIcon from "@mui/icons-material/Visibility";
|
import VisibilityIcon from "@mui/icons-material/Visibility";
|
||||||
import { use } from "../Context";
|
import { use } from "../Context";
|
||||||
import { Page } from "../Router";
|
import { Page } from "../Router";
|
||||||
|
|
||||||
const useStyles = makeStyles({
|
const useStyles = makeStyles({
|
||||||
nobackground: {
|
visibilityToggle: {
|
||||||
backgroundColor: "#0000",
|
backgroundColor: "transparent",
|
||||||
|
position: "absolute",
|
||||||
|
top: "100%",
|
||||||
|
right: 0,
|
||||||
|
},
|
||||||
|
overviewContainer: {
|
||||||
|
position: "fixed",
|
||||||
|
top: 0,
|
||||||
|
right: 0,
|
||||||
|
zIndex: 1500,
|
||||||
|
display: "flex",
|
||||||
|
justifyContent: "flex-end",
|
||||||
|
flexDirection: "column",
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -30,16 +42,13 @@ export function Overview({ children }: IProps): React.ReactElement {
|
|||||||
} else {
|
} else {
|
||||||
icon = <VisibilityIcon color="primary" />;
|
icon = <VisibilityIcon color="primary" />;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div style={{ position: "fixed", top: 0, right: 0, zIndex: 1500 }}>
|
<Paper square classes={{ root: classes.overviewContainer }}>
|
||||||
<Box display="flex" justifyContent="flex-end" flexDirection={"column"}>
|
|
||||||
<Collapse in={open}>{children}</Collapse>
|
<Collapse in={open}>{children}</Collapse>
|
||||||
<Box display="flex" justifyContent="flex-end">
|
<Fab size="small" classes={{ root: classes.visibilityToggle }} onClick={() => setOpen((old) => !old)}>
|
||||||
<Fab classes={{ root: classes.nobackground }} onClick={() => setOpen((old) => !old)}>
|
|
||||||
{icon}
|
{icon}
|
||||||
</Fab>
|
</Fab>
|
||||||
</Box>
|
</Paper>
|
||||||
</Box>
|
|
||||||
</div>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user