Merge pull request #1787 from danielyxie/dev

Scripting stuff
This commit is contained in:
hydroflame 2021-11-25 11:47:56 -05:00 committed by GitHub
commit 01a6dd7aab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
19 changed files with 339 additions and 8 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

@ -0,0 +1,73 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
width="256"
height="256"
viewBox="0 0 67.733332 67.733335"
version="1.1"
id="svg5"
inkscape:version="1.1.1 (c3084ef, 2021-09-22)"
sodipodi:docname="sf1.1.svg"
inkscape:export-filename="/Users/hydroflame/bitburner/assets/Steam/achievements/sf1.2-.png"
inkscape:export-xdpi="96.000008"
inkscape:export-ydpi="96.000008"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg">
<sodipodi:namedview
id="namedview7"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageshadow="2"
inkscape:pageopacity="0.0"
inkscape:pagecheckerboard="0"
inkscape:document-units="mm"
showgrid="true"
units="px"
inkscape:zoom="1.5823796"
inkscape:cx="-25.594364"
inkscape:cy="46.449032"
inkscape:window-width="2402"
inkscape:window-height="1245"
inkscape:window-x="0"
inkscape:window-y="23"
inkscape:window-maximized="0"
inkscape:current-layer="layer1">
<inkscape:grid
type="xygrid"
id="grid824" />
</sodipodi:namedview>
<defs
id="defs2" />
<g
inkscape:groupmode="layer"
id="layer2"
inkscape:label="Layer 2">
<rect
style="fill:#000000;fill-opacity:1;stroke:none;stroke-width:7.54569;stroke-opacity:1"
id="rect1951"
width="67.73333"
height="67.73333"
x="0"
y="0" />
</g>
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1">
<text
xml:space="preserve"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:19.7556px;line-height:1.25;font-family:monospace;-inkscape-font-specification:monospace;fill:#00ff00;fill-opacity:1;stroke-width:0.264583"
x="4.9740596"
y="41.359879"
id="text1444"><tspan
sodipodi:role="line"
id="tspan1442"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-family:monospace;-inkscape-font-specification:monospace;fill:#00ff00;fill-opacity:1;stroke-width:0.264583"
x="4.9740596"
y="41.359879">SF1.1</tspan></text>
</g>
</svg>

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

@ -0,0 +1,73 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
width="256"
height="256"
viewBox="0 0 67.733332 67.733335"
version="1.1"
id="svg5"
inkscape:version="1.1.1 (c3084ef, 2021-09-22)"
sodipodi:docname="sf1.2.svg"
inkscape:export-filename="/Users/hydroflame/bitburner/assets/Steam/achievements/sf1.2.png"
inkscape:export-xdpi="96.000008"
inkscape:export-ydpi="96.000008"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg">
<sodipodi:namedview
id="namedview7"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageshadow="2"
inkscape:pageopacity="0.0"
inkscape:pagecheckerboard="0"
inkscape:document-units="mm"
showgrid="true"
units="px"
inkscape:zoom="1.5823796"
inkscape:cx="-25.594364"
inkscape:cy="46.449032"
inkscape:window-width="2402"
inkscape:window-height="1245"
inkscape:window-x="0"
inkscape:window-y="23"
inkscape:window-maximized="0"
inkscape:current-layer="layer1">
<inkscape:grid
type="xygrid"
id="grid824" />
</sodipodi:namedview>
<defs
id="defs2" />
<g
inkscape:groupmode="layer"
id="layer2"
inkscape:label="Layer 2">
<rect
style="fill:#000000;fill-opacity:1;stroke:none;stroke-width:7.54569;stroke-opacity:1"
id="rect1951"
width="67.73333"
height="67.73333"
x="0"
y="0" />
</g>
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1">
<text
xml:space="preserve"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:19.7556px;line-height:1.25;font-family:monospace;-inkscape-font-specification:monospace;fill:#00ff00;fill-opacity:1;stroke-width:0.264583"
x="4.9740596"
y="41.359879"
id="text1444"><tspan
sodipodi:role="line"
id="tspan1442"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-family:monospace;-inkscape-font-specification:monospace;fill:#00ff00;fill-opacity:1;stroke-width:0.264583"
x="4.9740596"
y="41.359879">SF1.2</tspan></text>
</g>
</svg>

After

Width:  |  Height:  |  Size: 2.4 KiB

20
dist/bitburner.d.ts vendored

@ -4326,6 +4326,26 @@ export declare interface Singularity {
* @returns True if the installation was successful. * @returns True if the installation was successful.
*/ */
installBackdoor(): Promise<void>; installBackdoor(): Promise<void>;
/**
* Check if the player is focused.
* @remarks
* RAM cost: 0.1 GB
*
* Singularity - Level 2
*
* @returns True if the player is focused.
*/
isFocused(): void;
/**
* Set the players focus.
* @remarks
* RAM cost: 0.1 GB
*
* Singularity - Level 2
*/
setFocus(focus: boolean): void;
} }
/** /**

@ -21307,6 +21307,34 @@
"parameters": [], "parameters": [],
"name": "isBusy" "name": "isBusy"
}, },
{
"kind": "MethodSignature",
"canonicalReference": "bitburner!Singularity#isFocused:member(1)",
"docComment": "/**\n * Check if the player is focused.\n *\n * @remarks\n *\n * RAM cost: 0.1 GB\n *\n * Singularity - Level 2\n *\n * @returns True if the player is focused.\n */\n",
"excerptTokens": [
{
"kind": "Content",
"text": "isFocused(): "
},
{
"kind": "Content",
"text": "void"
},
{
"kind": "Content",
"text": ";"
}
],
"isOptional": false,
"returnTypeTokenRange": {
"startIndex": 1,
"endIndex": 2
},
"releaseTag": "Public",
"overloadIndex": 1,
"parameters": [],
"name": "isFocused"
},
{ {
"kind": "MethodSignature", "kind": "MethodSignature",
"canonicalReference": "bitburner!Singularity#joinFaction:member(1)", "canonicalReference": "bitburner!Singularity#joinFaction:member(1)",
@ -21515,6 +21543,50 @@
"parameters": [], "parameters": [],
"name": "purchaseTor" "name": "purchaseTor"
}, },
{
"kind": "MethodSignature",
"canonicalReference": "bitburner!Singularity#setFocus:member(1)",
"docComment": "/**\n * Set the players focus.\n *\n * @remarks\n *\n * RAM cost: 0.1 GB\n *\n * Singularity - Level 2\n */\n",
"excerptTokens": [
{
"kind": "Content",
"text": "setFocus(focus: "
},
{
"kind": "Content",
"text": "boolean"
},
{
"kind": "Content",
"text": "): "
},
{
"kind": "Content",
"text": "void"
},
{
"kind": "Content",
"text": ";"
}
],
"isOptional": false,
"returnTypeTokenRange": {
"startIndex": 3,
"endIndex": 4
},
"releaseTag": "Public",
"overloadIndex": 1,
"parameters": [
{
"parameterName": "focus",
"parameterTypeTokenRange": {
"startIndex": 1,
"endIndex": 2
}
}
],
"name": "setFocus"
},
{ {
"kind": "MethodSignature", "kind": "MethodSignature",
"canonicalReference": "bitburner!Singularity#softReset:member(1)", "canonicalReference": "bitburner!Singularity#softReset:member(1)",

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -0,0 +1,25 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) &gt; [bitburner](./bitburner.md) &gt; [Singularity](./bitburner.singularity.md) &gt; [isFocused](./bitburner.singularity.isfocused.md)
## Singularity.isFocused() method
Check if the player is focused.
<b>Signature:</b>
```typescript
isFocused(): void;
```
<b>Returns:</b>
void
True if the player is focused.
## Remarks
RAM cost: 0.1 GB
Singularity - Level 2

@ -53,11 +53,13 @@ This API requires Source-File 4 level 1 / 2 / 3 to use.
| [installAugmentations(cbScript)](./bitburner.singularity.installaugmentations.md) | Install your purchased augmentations. | | [installAugmentations(cbScript)](./bitburner.singularity.installaugmentations.md) | Install your purchased augmentations. |
| [installBackdoor()](./bitburner.singularity.installbackdoor.md) | Run the backdoor command in the terminal. | | [installBackdoor()](./bitburner.singularity.installbackdoor.md) | Run the backdoor command in the terminal. |
| [isBusy()](./bitburner.singularity.isbusy.md) | Check if the player is busy. | | [isBusy()](./bitburner.singularity.isbusy.md) | Check if the player is busy. |
| [isFocused()](./bitburner.singularity.isfocused.md) | Check if the player is focused. |
| [joinFaction(faction)](./bitburner.singularity.joinfaction.md) | Join a faction. | | [joinFaction(faction)](./bitburner.singularity.joinfaction.md) | Join a faction. |
| [manualHack()](./bitburner.singularity.manualhack.md) | Run the hack command in the terminal. | | [manualHack()](./bitburner.singularity.manualhack.md) | Run the hack command in the terminal. |
| [purchaseAugmentation(faction, augmentation)](./bitburner.singularity.purchaseaugmentation.md) | Purchase an augmentation | | [purchaseAugmentation(faction, augmentation)](./bitburner.singularity.purchaseaugmentation.md) | Purchase an augmentation |
| [purchaseProgram(programName)](./bitburner.singularity.purchaseprogram.md) | Purchase a program from the dark web. | | [purchaseProgram(programName)](./bitburner.singularity.purchaseprogram.md) | Purchase a program from the dark web. |
| [purchaseTor()](./bitburner.singularity.purchasetor.md) | Purchase the TOR router. | | [purchaseTor()](./bitburner.singularity.purchasetor.md) | Purchase the TOR router. |
| [setFocus(focus)](./bitburner.singularity.setfocus.md) | Set the players focus. |
| [softReset(cbScript)](./bitburner.singularity.softreset.md) | Soft reset the game. | | [softReset(cbScript)](./bitburner.singularity.softreset.md) | Soft reset the game. |
| [stopAction()](./bitburner.singularity.stopaction.md) | Stop the current action. | | [stopAction()](./bitburner.singularity.stopaction.md) | Stop the current action. |
| [travelToCity(city)](./bitburner.singularity.traveltocity.md) | Travel to another city. | | [travelToCity(city)](./bitburner.singularity.traveltocity.md) | Travel to another city. |

@ -0,0 +1,30 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) &gt; [bitburner](./bitburner.md) &gt; [Singularity](./bitburner.singularity.md) &gt; [setFocus](./bitburner.singularity.setfocus.md)
## Singularity.setFocus() method
Set the players focus.
<b>Signature:</b>
```typescript
setFocus(focus: boolean): void;
```
## Parameters
| Parameter | Type | Description |
| --- | --- | --- |
| focus | boolean | |
<b>Returns:</b>
void
## Remarks
RAM cost: 0.1 GB
Singularity - Level 2

@ -233,6 +233,8 @@ export const RamCosts: IMap<any> = {
purchaseAugmentation: RamCostConstants.ScriptSingularityFn3RamCost, purchaseAugmentation: RamCostConstants.ScriptSingularityFn3RamCost,
softReset: RamCostConstants.ScriptSingularityFn3RamCost, softReset: RamCostConstants.ScriptSingularityFn3RamCost,
installAugmentations: RamCostConstants.ScriptSingularityFn3RamCost, installAugmentations: RamCostConstants.ScriptSingularityFn3RamCost,
isFocused: 0.1,
setFocus: 0.1,
// Gang API // Gang API
gang: { gang: {

@ -372,7 +372,7 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
); );
server.fortify(CONSTANTS.ServerFortifyAmount * Math.min(threads, maxThreadNeeded)); server.fortify(CONSTANTS.ServerFortifyAmount * Math.min(threads, maxThreadNeeded));
if (stock) { if (stock) {
influenceStockThroughServerHack(server, moneyGained); influenceStockThroughServerHack(server, moneyDrained);
} }
if (manual) { if (manual) {
server.backdoorInstalled = true; server.backdoorInstalled = true;

@ -1218,5 +1218,19 @@ export function NetscriptSingularity(
return Object.assign({}, crime); return Object.assign({}, crime);
}, },
isFocused: function (): boolean {
helper.updateDynamicRam("isFocused", getRamCost("isFocused"));
helper.checkSingularityAccess("isFocused", 2);
return player.focus;
},
setFocus: function (focus: any): void {
helper.updateDynamicRam("isFocused", getRamCost("isFocused"));
helper.checkSingularityAccess("isFocused", 2);
if (focus === true) {
player.startFocusing();
} else if (focus === false) {
player.stopFocusing();
}
},
}; };
} }

@ -151,7 +151,7 @@ export function NetscriptStockMarket(player: IPlayer, workerScript: WorkerScript
const stock = getStockFromSymbol(symbol, "short"); const stock = getStockFromSymbol(symbol, "short");
const res = shortStock(stock, shares, workerScript, {}); const res = shortStock(stock, shares, workerScript, {});
return res ? stock.price : 0; return res ? stock.getBidPrice() : 0;
}, },
sellShort: function (symbol: any, shares: any): any { sellShort: function (symbol: any, shares: any): any {
helper.updateDynamicRam("sellShort", getRamCost("stock", "sellShort")); helper.updateDynamicRam("sellShort", getRamCost("stock", "sellShort"));
@ -167,7 +167,7 @@ export function NetscriptStockMarket(player: IPlayer, workerScript: WorkerScript
const stock = getStockFromSymbol(symbol, "sellShort"); const stock = getStockFromSymbol(symbol, "sellShort");
const res = sellShort(stock, shares, workerScript, {}); const res = sellShort(stock, shares, workerScript, {});
return res ? stock.price : 0; return res ? stock.getAskPrice() : 0;
}, },
placeOrder: function (symbol: any, shares: any, price: any, type: any, pos: any): any { placeOrder: function (symbol: any, shares: any, price: any, type: any, pos: any): any {
helper.updateDynamicRam("placeOrder", getRamCost("stock", "placeOrder")); helper.updateDynamicRam("placeOrder", getRamCost("stock", "placeOrder"));

@ -651,8 +651,8 @@ export function runScriptFromScript(
} }
args.forEach((arg) => { args.forEach((arg) => {
if (typeof arg !== "string" && typeof arg !== "number") if (typeof arg !== "string" && typeof arg !== "number" && typeof arg !== "boolean")
throw new Error("Only strings and numbers can be passed as arguments to otherscripts."); throw new Error("Only strings, numbers, and booleans can be passed as arguments to otherscripts.");
}); });
// Check if the script is already running // Check if the script is already running

@ -1993,6 +1993,26 @@ export interface Singularity {
* @returns True if the installation was successful. * @returns True if the installation was successful.
*/ */
installBackdoor(): Promise<void>; installBackdoor(): Promise<void>;
/**
* Check if the player is focused.
* @remarks
* RAM cost: 0.1 GB
*
* Singularity - Level 2
*
* @returns True if the player is focused.
*/
isFocused(): void;
/**
* Set the players focus.
* @remarks
* RAM cost: 0.1 GB
*
* Singularity - Level 2
*/
setFocus(focus: boolean): void;
} }
/** /**