Skip to content

Commit

Permalink
Fix a bunch of scripting related stuff.
Browse files Browse the repository at this point in the history
  • Loading branch information
Olivier Gagnon committed Nov 25, 2021
1 parent 8ad7ca5 commit f0a004e
Show file tree
Hide file tree
Showing 18 changed files with 337 additions and 6 deletions.
Binary file added assets/Steam/achievements/sf1.1-.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/Steam/achievements/sf1.1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
73 changes: 73 additions & 0 deletions assets/Steam/achievements/sf1.1.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/Steam/achievements/sf1.2-.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/Steam/achievements/sf1.2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
73 changes: 73 additions & 0 deletions assets/Steam/achievements/sf1.2.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 20 additions & 0 deletions dist/bitburner.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4326,6 +4326,26 @@ export declare interface Singularity {
* @returns True if the installation was successful.
*/
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;
}

/**
Expand Down
72 changes: 72 additions & 0 deletions input/bitburner.api.json
Original file line number Diff line number Diff line change
Expand Up @@ -21307,6 +21307,34 @@
"parameters": [],
"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",
"canonicalReference": "bitburner!Singularity#joinFaction:member(1)",
Expand Down Expand Up @@ -21515,6 +21543,50 @@
"parameters": [],
"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",
"canonicalReference": "bitburner!Singularity#softReset:member(1)",
Expand Down
4 changes: 2 additions & 2 deletions main.bundle.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion main.bundle.js.map

Large diffs are not rendered by default.

25 changes: 25 additions & 0 deletions markdown/bitburner.singularity.isfocused.md
Original file line number Diff line number Diff line change
@@ -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

2 changes: 2 additions & 0 deletions markdown/bitburner.singularity.md
Original file line number Diff line number Diff line change
Expand Up @@ -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. |
| [installBackdoor()](./bitburner.singularity.installbackdoor.md) | Run the backdoor command in the terminal. |
| [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. |
| [manualHack()](./bitburner.singularity.manualhack.md) | Run the hack command in the terminal. |
| [purchaseAugmentation(faction, augmentation)](./bitburner.singularity.purchaseaugmentation.md) | Purchase an augmentation |
| [purchaseProgram(programName)](./bitburner.singularity.purchaseprogram.md) | Purchase a program from the dark web. |
| [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. |
| [stopAction()](./bitburner.singularity.stopaction.md) | Stop the current action. |
| [travelToCity(city)](./bitburner.singularity.traveltocity.md) | Travel to another city. |
Expand Down
30 changes: 30 additions & 0 deletions markdown/bitburner.singularity.setfocus.md
Original file line number Diff line number Diff line change
@@ -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

2 changes: 2 additions & 0 deletions src/Netscript/RamCostGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,8 @@ export const RamCosts: IMap<any> = {
purchaseAugmentation: RamCostConstants.ScriptSingularityFn3RamCost,
softReset: RamCostConstants.ScriptSingularityFn3RamCost,
installAugmentations: RamCostConstants.ScriptSingularityFn3RamCost,
isFocused: 0.1,
setFocus: 0.1,

// Gang API
gang: {
Expand Down
2 changes: 1 addition & 1 deletion src/NetscriptFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
);
server.fortify(CONSTANTS.ServerFortifyAmount * Math.min(threads, maxThreadNeeded));
if (stock) {
influenceStockThroughServerHack(server, moneyGained);
influenceStockThroughServerHack(server, moneyDrained);
}
if (manual) {
server.backdoorInstalled = true;
Expand Down
14 changes: 14 additions & 0 deletions src/NetscriptFunctions/Singularity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1218,5 +1218,19 @@ export function NetscriptSingularity(

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();
}
},
};
}
4 changes: 2 additions & 2 deletions src/NetscriptWorker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -651,8 +651,8 @@ export function runScriptFromScript(
}

args.forEach((arg) => {
if (typeof arg !== "string" && typeof arg !== "number")
throw new Error("Only strings and numbers can be passed as arguments to otherscripts.");
if (typeof arg !== "string" && typeof arg !== "number" && typeof arg !== "boolean")
throw new Error("Only strings, numbers, and booleans can be passed as arguments to otherscripts.");
});

// Check if the script is already running
Expand Down
Loading

0 comments on commit f0a004e

Please sign in to comment.