mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-09 17:23:53 +01:00
NETSCRIPT: add ns.getResetInfo(#490)
* Move lastAugReset and lastNodeReset back to main API under getResetInfo, also included currentNode. * The associated properties are deprecated on getPlayer()
This commit is contained in:
parent
62adaf3006
commit
6024c81113
@ -86,6 +86,7 @@
|
|||||||
| [Product](./bitburner.product.md) | Product in a warehouse |
|
| [Product](./bitburner.product.md) | Product in a warehouse |
|
||||||
| [RecentScript](./bitburner.recentscript.md) | |
|
| [RecentScript](./bitburner.recentscript.md) | |
|
||||||
| [ReputationFormulas](./bitburner.reputationformulas.md) | Reputation formulas |
|
| [ReputationFormulas](./bitburner.reputationformulas.md) | Reputation formulas |
|
||||||
|
| [ResetInfo](./bitburner.resetinfo.md) | Various info about resets |
|
||||||
| [RunningScript](./bitburner.runningscript.md) | |
|
| [RunningScript](./bitburner.runningscript.md) | |
|
||||||
| [RunOptions](./bitburner.runoptions.md) | |
|
| [RunOptions](./bitburner.runoptions.md) | |
|
||||||
| [Server](./bitburner.server.md) | A server. Not all servers have all of these properties - optional properties are missing on certain servers. |
|
| [Server](./bitburner.server.md) | A server. Not all servers have all of these properties - optional properties are missing on certain servers. |
|
||||||
|
31
markdown/bitburner.ns.getresetinfo.md
Normal file
31
markdown/bitburner.ns.getresetinfo.md
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||||
|
|
||||||
|
[Home](./index.md) > [bitburner](./bitburner.md) > [NS](./bitburner.ns.md) > [getResetInfo](./bitburner.ns.getresetinfo.md)
|
||||||
|
|
||||||
|
## NS.getResetInfo() method
|
||||||
|
|
||||||
|
Get information about resets.
|
||||||
|
|
||||||
|
**Signature:**
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
getResetInfo(): ResetInfo;
|
||||||
|
```
|
||||||
|
**Returns:**
|
||||||
|
|
||||||
|
[ResetInfo](./bitburner.resetinfo.md)
|
||||||
|
|
||||||
|
## Remarks
|
||||||
|
|
||||||
|
RAM cost: 1 GB
|
||||||
|
|
||||||
|
## Example
|
||||||
|
|
||||||
|
|
||||||
|
```js
|
||||||
|
const resetInfo = ns.getResetInfo();
|
||||||
|
const lastAugReset = resetInfo.lastAugReset;
|
||||||
|
ns.tprint(`The last augmentation reset was: ${new Date(lastAugReset)}`);
|
||||||
|
ns.tprint(`It has been ${Date.now() - lastAugReset}ms since the last augmentation reset.`);
|
||||||
|
```
|
||||||
|
|
@ -97,6 +97,7 @@ export async function main(ns) {
|
|||||||
| [getPurchasedServers()](./bitburner.ns.getpurchasedservers.md) | Returns an array with the hostnames of all of the servers you have purchased. |
|
| [getPurchasedServers()](./bitburner.ns.getpurchasedservers.md) | Returns an array with the hostnames of all of the servers you have purchased. |
|
||||||
| [getPurchasedServerUpgradeCost(hostname, ram)](./bitburner.ns.getpurchasedserverupgradecost.md) | Get cost of upgrading a purchased server to the given ram. |
|
| [getPurchasedServerUpgradeCost(hostname, ram)](./bitburner.ns.getpurchasedserverupgradecost.md) | Get cost of upgrading a purchased server to the given ram. |
|
||||||
| [getRecentScripts()](./bitburner.ns.getrecentscripts.md) | Get an array of recently killed scripts across all servers. |
|
| [getRecentScripts()](./bitburner.ns.getrecentscripts.md) | Get an array of recently killed scripts across all servers. |
|
||||||
|
| [getResetInfo()](./bitburner.ns.getresetinfo.md) | Get information about resets. |
|
||||||
| [getRunningScript(filename, hostname, args)](./bitburner.ns.getrunningscript.md) | Get general info about a running script. |
|
| [getRunningScript(filename, hostname, args)](./bitburner.ns.getrunningscript.md) | Get general info about a running script. |
|
||||||
| [getScriptExpGain(script, host, args)](./bitburner.ns.getscriptexpgain.md) | Get the exp gain of a script. |
|
| [getScriptExpGain(script, host, args)](./bitburner.ns.getscriptexpgain.md) | Get the exp gain of a script. |
|
||||||
| [getScriptIncome(script, host, args)](./bitburner.ns.getscriptincome.md) | Get the income of a script. |
|
| [getScriptIncome(script, host, args)](./bitburner.ns.getscriptincome.md) | Get the income of a script. |
|
||||||
@ -138,7 +139,7 @@ export async function main(ns) {
|
|||||||
| [ls(host, substring)](./bitburner.ns.ls.md) | List files on a server. |
|
| [ls(host, substring)](./bitburner.ns.ls.md) | List files on a server. |
|
||||||
| [moveTail(x, y, pid)](./bitburner.ns.movetail.md) | Move a tail window. |
|
| [moveTail(x, y, pid)](./bitburner.ns.movetail.md) | Move a tail window. |
|
||||||
| [mv(host, source, destination)](./bitburner.ns.mv.md) | Move a file on the target server. |
|
| [mv(host, source, destination)](./bitburner.ns.mv.md) | Move a file on the target server. |
|
||||||
| [nFormat(n, format)](./bitburner.ns.nformat.md) | Format a number using the numeral library. This function is deprecated and will be removed in 2.3. |
|
| [nFormat(n, format)](./bitburner.ns.nformat.md) | Format a number using the numeral library. This function is deprecated and will be removed in 2.4. |
|
||||||
| [nuke(host)](./bitburner.ns.nuke.md) | Runs NUKE.exe on a server. |
|
| [nuke(host)](./bitburner.ns.nuke.md) | Runs NUKE.exe on a server. |
|
||||||
| [peek(portNumber)](./bitburner.ns.peek.md) | Get a copy of the data from a port without popping it. |
|
| [peek(portNumber)](./bitburner.ns.peek.md) | Get a copy of the data from a port without popping it. |
|
||||||
| [print(args)](./bitburner.ns.print.md) | Prints one or more values or variables to the script’s logs. |
|
| [print(args)](./bitburner.ns.print.md) | Prints one or more values or variables to the script’s logs. |
|
||||||
|
@ -28,8 +28,6 @@ void
|
|||||||
|
|
||||||
RAM cost: 0 GB
|
RAM cost: 0 GB
|
||||||
|
|
||||||
NS2 exclusive.
|
|
||||||
|
|
||||||
Move the source file to the specified destination on the target server.
|
Move the source file to the specified destination on the target server.
|
||||||
|
|
||||||
This command only works for scripts and text files (.txt). It cannot, however, be used to convert from script to text file, or vice versa.
|
This command only works for scripts and text files (.txt). It cannot, however, be used to convert from script to text file, or vice versa.
|
||||||
|
@ -6,10 +6,10 @@
|
|||||||
|
|
||||||
> Warning: This API is now obsolete.
|
> Warning: This API is now obsolete.
|
||||||
>
|
>
|
||||||
> Use ns.formatNumber, formatRam, or formatPercent instead. Will be removed in 2.3.
|
> Use ns.formatNumber, formatRam, or formatPercent instead. Will be removed in 2.4.
|
||||||
>
|
>
|
||||||
|
|
||||||
Format a number using the numeral library. This function is deprecated and will be removed in 2.3.
|
Format a number using the numeral library. This function is deprecated and will be removed in 2.4.
|
||||||
|
|
||||||
**Signature:**
|
**Signature:**
|
||||||
|
|
||||||
|
@ -1,11 +0,0 @@
|
|||||||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
|
||||||
|
|
||||||
[Home](./index.md) > [bitburner](./bitburner.md) > [Player](./bitburner.player.md) > [bitNodeN](./bitburner.player.bitnoden.md)
|
|
||||||
|
|
||||||
## Player.bitNodeN property
|
|
||||||
|
|
||||||
**Signature:**
|
|
||||||
|
|
||||||
```typescript
|
|
||||||
bitNodeN: number;
|
|
||||||
```
|
|
@ -16,7 +16,6 @@ interface Player extends Person
|
|||||||
|
|
||||||
| Property | Modifiers | Type | Description |
|
| Property | Modifiers | Type | Description |
|
||||||
| --- | --- | --- | --- |
|
| --- | --- | --- | --- |
|
||||||
| [bitNodeN](./bitburner.player.bitnoden.md) | | number | |
|
|
||||||
| [entropy](./bitburner.player.entropy.md) | | number | |
|
| [entropy](./bitburner.player.entropy.md) | | number | |
|
||||||
| [factions](./bitburner.player.factions.md) | | string\[\] | |
|
| [factions](./bitburner.player.factions.md) | | string\[\] | |
|
||||||
| [jobs](./bitburner.player.jobs.md) | | Record<string, string> | |
|
| [jobs](./bitburner.player.jobs.md) | | Record<string, string> | |
|
||||||
|
13
markdown/bitburner.resetinfo.currentnode.md
Normal file
13
markdown/bitburner.resetinfo.currentnode.md
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||||
|
|
||||||
|
[Home](./index.md) > [bitburner](./bitburner.md) > [ResetInfo](./bitburner.resetinfo.md) > [currentNode](./bitburner.resetinfo.currentnode.md)
|
||||||
|
|
||||||
|
## ResetInfo.currentNode property
|
||||||
|
|
||||||
|
The current bitnode
|
||||||
|
|
||||||
|
**Signature:**
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
currentNode: number;
|
||||||
|
```
|
13
markdown/bitburner.resetinfo.lastaugreset.md
Normal file
13
markdown/bitburner.resetinfo.lastaugreset.md
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||||
|
|
||||||
|
[Home](./index.md) > [bitburner](./bitburner.md) > [ResetInfo](./bitburner.resetinfo.md) > [lastAugReset](./bitburner.resetinfo.lastaugreset.md)
|
||||||
|
|
||||||
|
## ResetInfo.lastAugReset property
|
||||||
|
|
||||||
|
Numeric timestamp (from Date.now()) of last augmentation reset
|
||||||
|
|
||||||
|
**Signature:**
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
lastAugReset: number;
|
||||||
|
```
|
13
markdown/bitburner.resetinfo.lastnodereset.md
Normal file
13
markdown/bitburner.resetinfo.lastnodereset.md
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||||
|
|
||||||
|
[Home](./index.md) > [bitburner](./bitburner.md) > [ResetInfo](./bitburner.resetinfo.md) > [lastNodeReset](./bitburner.resetinfo.lastnodereset.md)
|
||||||
|
|
||||||
|
## ResetInfo.lastNodeReset property
|
||||||
|
|
||||||
|
Numeric timestamp (from Date.now()) of last bitnode reset
|
||||||
|
|
||||||
|
**Signature:**
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
lastNodeReset: number;
|
||||||
|
```
|
22
markdown/bitburner.resetinfo.md
Normal file
22
markdown/bitburner.resetinfo.md
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||||
|
|
||||||
|
[Home](./index.md) > [bitburner](./bitburner.md) > [ResetInfo](./bitburner.resetinfo.md)
|
||||||
|
|
||||||
|
## ResetInfo interface
|
||||||
|
|
||||||
|
Various info about resets
|
||||||
|
|
||||||
|
**Signature:**
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
interface ResetInfo
|
||||||
|
```
|
||||||
|
|
||||||
|
## Properties
|
||||||
|
|
||||||
|
| Property | Modifiers | Type | Description |
|
||||||
|
| --- | --- | --- | --- |
|
||||||
|
| [currentNode](./bitburner.resetinfo.currentnode.md) | | number | The current bitnode |
|
||||||
|
| [lastAugReset](./bitburner.resetinfo.lastaugreset.md) | | number | Numeric timestamp (from Date.now()) of last augmentation reset |
|
||||||
|
| [lastNodeReset](./bitburner.resetinfo.lastnodereset.md) | | number | Numeric timestamp (from Date.now()) of last bitnode reset |
|
||||||
|
|
@ -1,23 +0,0 @@
|
|||||||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
|
||||||
|
|
||||||
[Home](./index.md) > [bitburner](./bitburner.md) > [Singularity](./bitburner.singularity.md) > [getLastAugReset](./bitburner.singularity.getlastaugreset.md)
|
|
||||||
|
|
||||||
## Singularity.getLastAugReset() method
|
|
||||||
|
|
||||||
Get the last timestamp from when you installed augmentations.
|
|
||||||
|
|
||||||
**Signature:**
|
|
||||||
|
|
||||||
```typescript
|
|
||||||
getLastAugReset(): number;
|
|
||||||
```
|
|
||||||
**Returns:**
|
|
||||||
|
|
||||||
number
|
|
||||||
|
|
||||||
The timestamp in milliseconds from your last augmentation install.
|
|
||||||
|
|
||||||
## Remarks
|
|
||||||
|
|
||||||
RAM cost: 0.5 GB \* 16/4/1
|
|
||||||
|
|
@ -1,23 +0,0 @@
|
|||||||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
|
||||||
|
|
||||||
[Home](./index.md) > [bitburner](./bitburner.md) > [Singularity](./bitburner.singularity.md) > [getLastNodeReset](./bitburner.singularity.getlastnodereset.md)
|
|
||||||
|
|
||||||
## Singularity.getLastNodeReset() method
|
|
||||||
|
|
||||||
Get the last timestamp from when you finished a bitnode.
|
|
||||||
|
|
||||||
**Signature:**
|
|
||||||
|
|
||||||
```typescript
|
|
||||||
getLastNodeReset(): number;
|
|
||||||
```
|
|
||||||
**Returns:**
|
|
||||||
|
|
||||||
number
|
|
||||||
|
|
||||||
The timestamp in milliseconds from your last bitnode finish.
|
|
||||||
|
|
||||||
## Remarks
|
|
||||||
|
|
||||||
RAM cost: 0.5 GB \* 16/4/1
|
|
||||||
|
|
@ -50,8 +50,6 @@ This API requires Source-File 4 to use. The RAM cost of all these functions is m
|
|||||||
| [getFactionFavor(faction)](./bitburner.singularity.getfactionfavor.md) | Get faction favor. |
|
| [getFactionFavor(faction)](./bitburner.singularity.getfactionfavor.md) | Get faction favor. |
|
||||||
| [getFactionFavorGain(faction)](./bitburner.singularity.getfactionfavorgain.md) | Get faction favor gain. |
|
| [getFactionFavorGain(faction)](./bitburner.singularity.getfactionfavorgain.md) | Get faction favor gain. |
|
||||||
| [getFactionRep(faction)](./bitburner.singularity.getfactionrep.md) | Get faction reputation. |
|
| [getFactionRep(faction)](./bitburner.singularity.getfactionrep.md) | Get faction reputation. |
|
||||||
| [getLastAugReset()](./bitburner.singularity.getlastaugreset.md) | Get the last timestamp from when you installed augmentations. |
|
|
||||||
| [getLastNodeReset()](./bitburner.singularity.getlastnodereset.md) | Get the last timestamp from when you finished a bitnode. |
|
|
||||||
| [getOwnedAugmentations(purchased)](./bitburner.singularity.getownedaugmentations.md) | Get a list of owned augmentation. |
|
| [getOwnedAugmentations(purchased)](./bitburner.singularity.getownedaugmentations.md) | Get a list of owned augmentation. |
|
||||||
| [getOwnedSourceFiles()](./bitburner.singularity.getownedsourcefiles.md) | Get a list of acquired Source-Files. |
|
| [getOwnedSourceFiles()](./bitburner.singularity.getownedsourcefiles.md) | Get a list of acquired Source-Files. |
|
||||||
| [getUpgradeHomeCoresCost()](./bitburner.singularity.getupgradehomecorescost.md) | Get the price of upgrading home cores. |
|
| [getUpgradeHomeCoresCost()](./bitburner.singularity.getupgradehomecorescost.md) | Get the price of upgrading home cores. |
|
||||||
|
@ -204,8 +204,6 @@ const singularity = {
|
|||||||
b1tflum3: SF4Cost(16),
|
b1tflum3: SF4Cost(16),
|
||||||
destroyW0r1dD43m0n: SF4Cost(32),
|
destroyW0r1dD43m0n: SF4Cost(32),
|
||||||
getCurrentWork: SF4Cost(0.5),
|
getCurrentWork: SF4Cost(0.5),
|
||||||
getLastAugReset: SF4Cost(0.5),
|
|
||||||
getLastNodeReset: SF4Cost(0.5),
|
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
// Gang API
|
// Gang API
|
||||||
@ -535,6 +533,7 @@ export const RamCosts: RamCostTree<NSFull> = {
|
|||||||
getPlayer: RamCostConstants.SingularityFn1 / 4,
|
getPlayer: RamCostConstants.SingularityFn1 / 4,
|
||||||
getMoneySources: RamCostConstants.GetMoneySourcesCost,
|
getMoneySources: RamCostConstants.GetMoneySourcesCost,
|
||||||
mv: 0,
|
mv: 0,
|
||||||
|
getResetInfo: 1,
|
||||||
tail: 0,
|
tail: 0,
|
||||||
toast: 0,
|
toast: 0,
|
||||||
moveTail: 0,
|
moveTail: 0,
|
||||||
|
@ -76,7 +76,7 @@ import { Flags } from "./NetscriptFunctions/Flags";
|
|||||||
import { calculateIntelligenceBonus } from "./PersonObjects/formulas/intelligence";
|
import { calculateIntelligenceBonus } from "./PersonObjects/formulas/intelligence";
|
||||||
import { CalculateShareMult, StartSharing } from "./NetworkShare/Share";
|
import { CalculateShareMult, StartSharing } from "./NetworkShare/Share";
|
||||||
import { recentScripts } from "./Netscript/RecentScripts";
|
import { recentScripts } from "./Netscript/RecentScripts";
|
||||||
import { InternalAPI, removedFunction, NSProxy, NetscriptContext } from "./Netscript/APIWrapper";
|
import { InternalAPI, removedFunction, NSProxy } from "./Netscript/APIWrapper";
|
||||||
import { INetscriptExtra } from "./NetscriptFunctions/Extra";
|
import { INetscriptExtra } from "./NetscriptFunctions/Extra";
|
||||||
import { ScriptDeath } from "./Netscript/ScriptDeath";
|
import { ScriptDeath } from "./Netscript/ScriptDeath";
|
||||||
import { getBitNodeMultipliers } from "./BitNode/BitNode";
|
import { getBitNodeMultipliers } from "./BitNode/BitNode";
|
||||||
@ -1012,7 +1012,6 @@ export const ns: InternalAPI<NSFull> = {
|
|||||||
},
|
},
|
||||||
getServerBaseSecurityLevel: (ctx) => (_hostname) => {
|
getServerBaseSecurityLevel: (ctx) => (_hostname) => {
|
||||||
const hostname = helpers.string(ctx, "hostname", _hostname);
|
const hostname = helpers.string(ctx, "hostname", _hostname);
|
||||||
helpers.log(ctx, () => `getServerBaseSecurityLevel is deprecated because it's not useful.`);
|
|
||||||
const server = helpers.getServer(ctx, hostname);
|
const server = helpers.getServer(ctx, hostname);
|
||||||
if (!(server instanceof Server)) {
|
if (!(server instanceof Server)) {
|
||||||
helpers.log(ctx, () => "Cannot be executed on this server.");
|
helpers.log(ctx, () => "Cannot be executed on this server.");
|
||||||
@ -1568,8 +1567,12 @@ export const ns: InternalAPI<NSFull> = {
|
|||||||
const multStart = helpers.number(ctx, "multStart", _multStart);
|
const multStart = helpers.number(ctx, "multStart", _multStart);
|
||||||
return formatPercent(n, fractionalDigits, multStart);
|
return formatPercent(n, fractionalDigits, multStart);
|
||||||
},
|
},
|
||||||
// Todo: Remove function in 2.3. Until then it just directly wraps numeral.
|
// Todo: Remove function for real though in 2.4. Until then it just directly wraps numeral.
|
||||||
nFormat: (ctx) => (_n, _format) => {
|
nFormat: (ctx) => (_n, _format) => {
|
||||||
|
deprecationWarning(
|
||||||
|
"ns.nFormat",
|
||||||
|
"Use ns.formatNumber, formatRam, formatPercent, or js builtins like Intl.NumberFormat instead.",
|
||||||
|
);
|
||||||
const n = helpers.number(ctx, "n", _n);
|
const n = helpers.number(ctx, "n", _n);
|
||||||
const format = helpers.string(ctx, "format", _format);
|
const format = helpers.string(ctx, "format", _format);
|
||||||
return numeral(n).format(format);
|
return numeral(n).format(format);
|
||||||
@ -1580,6 +1583,7 @@ export const ns: InternalAPI<NSFull> = {
|
|||||||
return convertTimeMsToTimeElapsedString(milliseconds, milliPrecision);
|
return convertTimeMsToTimeElapsedString(milliseconds, milliPrecision);
|
||||||
},
|
},
|
||||||
getTimeSinceLastAug: () => () => {
|
getTimeSinceLastAug: () => () => {
|
||||||
|
deprecationWarning("ns.getTimeSinceLastAug()", "Use ns.getResetInfo().lastAugReset instead.");
|
||||||
return Player.playtimeSinceLastAug;
|
return Player.playtimeSinceLastAug;
|
||||||
},
|
},
|
||||||
alert: (ctx) => (_message) => {
|
alert: (ctx) => (_message) => {
|
||||||
@ -1670,38 +1674,40 @@ export const ns: InternalAPI<NSFull> = {
|
|||||||
getFavorToDonate: () => () => {
|
getFavorToDonate: () => () => {
|
||||||
return Math.floor(CONSTANTS.BaseFavorToDonate * BitNodeMultipliers.RepToDonateToFaction);
|
return Math.floor(CONSTANTS.BaseFavorToDonate * BitNodeMultipliers.RepToDonateToFaction);
|
||||||
},
|
},
|
||||||
getPlayer: (ctx) => () => {
|
getPlayer: () => () => {
|
||||||
const data = {
|
const data = {
|
||||||
|
// Person
|
||||||
hp: cloneDeep(Player.hp),
|
hp: cloneDeep(Player.hp),
|
||||||
skills: cloneDeep(Player.skills),
|
skills: cloneDeep(Player.skills),
|
||||||
exp: cloneDeep(Player.exp),
|
exp: cloneDeep(Player.exp),
|
||||||
mults: cloneDeep(Player.mults),
|
mults: cloneDeep(Player.mults),
|
||||||
|
city: Player.city,
|
||||||
|
// Player-specific
|
||||||
numPeopleKilled: Player.numPeopleKilled,
|
numPeopleKilled: Player.numPeopleKilled,
|
||||||
money: Player.money,
|
money: Player.money,
|
||||||
city: Player.city,
|
|
||||||
location: Player.location,
|
location: Player.location,
|
||||||
bitNodeN: Player.bitNodeN,
|
|
||||||
totalPlaytime: Player.totalPlaytime,
|
totalPlaytime: Player.totalPlaytime,
|
||||||
jobs: cloneDeep(Player.jobs),
|
jobs: cloneDeep(Player.jobs),
|
||||||
factions: Player.factions.slice(),
|
factions: Player.factions.slice(),
|
||||||
entropy: Player.entropy,
|
entropy: Player.entropy,
|
||||||
};
|
};
|
||||||
createDeprecatedProperty(
|
setDeprecatedProperties(data, {
|
||||||
ctx,
|
playtimeSinceLastAug: {
|
||||||
data,
|
identifier: "ns.getPlayer().playtimeSinceLastAug",
|
||||||
"playtimeSinceLastAug",
|
message: "Use ns.getResetInfo().lastAugReset instead. This is a static timestamp instead of an elapsed time.",
|
||||||
Player.playtimeSinceLastAug,
|
value: Player.playtimeSinceLastAug,
|
||||||
"getPlayer.playtimeSinceLastAug",
|
},
|
||||||
"Use ns.getPlaytimeSinceLastAug or ns.singularity.getLastAugReset instead.",
|
playtimeSinceLastBitnode: {
|
||||||
);
|
identifier: "ns.getPlayer().playtimeSinceLastBitnode",
|
||||||
createDeprecatedProperty(
|
message: "Use ns.getResetInfo().lastNodeReset instead. This is a static timestamp instead of an elapsed time.",
|
||||||
ctx,
|
value: Player.playtimeSinceLastBitnode,
|
||||||
data,
|
},
|
||||||
"playtimeSinceLastBitnode",
|
bitNodeN: {
|
||||||
Player.playtimeSinceLastBitnode,
|
identifier: "ns.getPlayer().bitNodeN",
|
||||||
"getPlayer.playtimeSinceLastBitnode",
|
message: "Use ns.getResetInto().currentNode instead",
|
||||||
"Use ns.singularity.getLastNodeReset instead.",
|
value: Player.bitNodeN,
|
||||||
);
|
},
|
||||||
|
});
|
||||||
return data;
|
return data;
|
||||||
},
|
},
|
||||||
getMoneySources: () => () => ({
|
getMoneySources: () => () => ({
|
||||||
@ -1747,6 +1753,11 @@ export const ns: InternalAPI<NSFull> = {
|
|||||||
}
|
}
|
||||||
helpers.log(ctx, () => `ERROR: Failed. Was unable to remove file ${sourcePath} from its original location.`);
|
helpers.log(ctx, () => `ERROR: Failed. Was unable to remove file ${sourcePath} from its original location.`);
|
||||||
},
|
},
|
||||||
|
getResetInfo: () => () => ({
|
||||||
|
lastAugReset: Player.lastAugReset,
|
||||||
|
lastNodeReset: Player.lastNodeReset,
|
||||||
|
currentNode: Player.bitNodeN,
|
||||||
|
}),
|
||||||
flags: Flags,
|
flags: Flags,
|
||||||
...NetscriptExtra(),
|
...NetscriptExtra(),
|
||||||
};
|
};
|
||||||
@ -1776,27 +1787,28 @@ function getFunctionNames(obj: object, prefix: string): string[] {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const deprecatedWarningsGiven = new Set();
|
const deprecatedWarningsGiven = new Set();
|
||||||
function createDeprecatedProperty(
|
function setDeprecatedProperties(
|
||||||
ctx: NetscriptContext,
|
|
||||||
obj: object,
|
obj: object,
|
||||||
propName: string,
|
properties: Record<string, { identifier: string; message: string; value: any }>,
|
||||||
value: any,
|
|
||||||
identifier: string,
|
|
||||||
message: string,
|
|
||||||
) {
|
) {
|
||||||
Object.defineProperty(obj, propName, {
|
for (const [name, info] of Object.entries(properties)) {
|
||||||
set: (newVal: any) => (value = newVal),
|
Object.defineProperty(obj, name, {
|
||||||
get: () => {
|
get: () => {
|
||||||
if (!deprecatedWarningsGiven.has(identifier)) {
|
deprecationWarning(info.identifier, info.message);
|
||||||
deprecatedWarningsGiven.add(identifier);
|
return info.value;
|
||||||
Terminal.warn(`Deprecated property ${propName} accessed from ns.${ctx.functionPath} return value.`);
|
|
||||||
Terminal.warn(`This is no longer supported usage and will be removed in a later version.`);
|
|
||||||
Terminal.warn(message);
|
|
||||||
Terminal.info(`Note that this message can also appear if you iterate through the object's values.`);
|
|
||||||
Terminal.info(`This message will only be shown once per game session for each deprecated property accessed.`);
|
|
||||||
}
|
|
||||||
return value;
|
|
||||||
},
|
},
|
||||||
|
set: (value: any) => (info.value = value),
|
||||||
enumerable: true,
|
enumerable: true,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
function deprecationWarning(identifier: string, message: string) {
|
||||||
|
if (!deprecatedWarningsGiven.has(identifier)) {
|
||||||
|
deprecatedWarningsGiven.add(identifier);
|
||||||
|
Terminal.warn(`Accessed deprecated function or property: ${identifier}`);
|
||||||
|
Terminal.warn(`This is no longer supported usage and will be removed in a later version.`);
|
||||||
|
Terminal.warn(message);
|
||||||
|
Terminal.info(`This message can also appear for object properties when the object's values are iterated.`);
|
||||||
|
Terminal.info(`This message will only be shown once per game session for each deprecated item accessed.`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -87,15 +87,16 @@ export function NetscriptFormulas(): InternalAPI<IFormulas> {
|
|||||||
serverGrowth: 0,
|
serverGrowth: 0,
|
||||||
}),
|
}),
|
||||||
mockPlayer: () => (): IPlayer => ({
|
mockPlayer: () => (): IPlayer => ({
|
||||||
|
// Person
|
||||||
hp: { current: 0, max: 0 },
|
hp: { current: 0, max: 0 },
|
||||||
skills: { hacking: 0, strength: 0, defense: 0, dexterity: 0, agility: 0, charisma: 0, intelligence: 0 },
|
skills: { hacking: 0, strength: 0, defense: 0, dexterity: 0, agility: 0, charisma: 0, intelligence: 0 },
|
||||||
exp: { hacking: 0, strength: 0, defense: 0, dexterity: 0, agility: 0, charisma: 0, intelligence: 0 },
|
exp: { hacking: 0, strength: 0, defense: 0, dexterity: 0, agility: 0, charisma: 0, intelligence: 0 },
|
||||||
mults: defaultMultipliers(),
|
mults: defaultMultipliers(),
|
||||||
|
city: CityName.Sector12,
|
||||||
|
// Player-specific
|
||||||
numPeopleKilled: 0,
|
numPeopleKilled: 0,
|
||||||
money: 0,
|
money: 0,
|
||||||
city: CityName.Sector12,
|
|
||||||
location: LocationName.TravelAgency,
|
location: LocationName.TravelAgency,
|
||||||
bitNodeN: 0,
|
|
||||||
totalPlaytime: 0,
|
totalPlaytime: 0,
|
||||||
jobs: {},
|
jobs: {},
|
||||||
factions: [],
|
factions: [],
|
||||||
|
@ -1254,14 +1254,6 @@ export function NetscriptSingularity(): InternalAPI<ISingularity> {
|
|||||||
helpers.checkSingularityAccess(ctx);
|
helpers.checkSingularityAccess(ctx);
|
||||||
return canGetBonus();
|
return canGetBonus();
|
||||||
},
|
},
|
||||||
getLastAugReset: (ctx) => () => {
|
|
||||||
helpers.checkSingularityAccess(ctx);
|
|
||||||
return Player.lastAugReset;
|
|
||||||
},
|
|
||||||
getLastNodeReset: (ctx) => () => {
|
|
||||||
helpers.checkSingularityAccess(ctx);
|
|
||||||
return Player.lastNodeReset;
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
Object.assign(singularityAPI, {
|
Object.assign(singularityAPI, {
|
||||||
getAugmentationCost: removedFunction(
|
getAugmentationCost: removedFunction(
|
||||||
|
50
src/ScriptEditor/NetscriptDefinitions.d.ts
vendored
50
src/ScriptEditor/NetscriptDefinitions.d.ts
vendored
@ -50,7 +50,6 @@ interface Player extends Person {
|
|||||||
entropy: number;
|
entropy: number;
|
||||||
jobs: Record<string, string>;
|
jobs: Record<string, string>;
|
||||||
factions: string[];
|
factions: string[];
|
||||||
bitNodeN: number;
|
|
||||||
totalPlaytime: number;
|
totalPlaytime: number;
|
||||||
location: string;
|
location: string;
|
||||||
}
|
}
|
||||||
@ -67,6 +66,17 @@ interface SleevePerson extends Person {
|
|||||||
storedCycles: number;
|
storedCycles: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Various info about resets
|
||||||
|
* @public */
|
||||||
|
interface ResetInfo {
|
||||||
|
/** Numeric timestamp (from Date.now()) of last augmentation reset */
|
||||||
|
lastAugReset: number;
|
||||||
|
/** Numeric timestamp (from Date.now()) of last bitnode reset */
|
||||||
|
lastNodeReset: number;
|
||||||
|
/** The current bitnode */
|
||||||
|
currentNode: number;
|
||||||
|
}
|
||||||
|
|
||||||
/** @public */
|
/** @public */
|
||||||
interface MoneySource {
|
interface MoneySource {
|
||||||
bladeburner: number;
|
bladeburner: number;
|
||||||
@ -2361,24 +2371,6 @@ export interface Singularity {
|
|||||||
* @returns - An object representing the current work. Fields depend on the kind of work.
|
* @returns - An object representing the current work. Fields depend on the kind of work.
|
||||||
*/
|
*/
|
||||||
getCurrentWork(): any | null;
|
getCurrentWork(): any | null;
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the last timestamp from when you installed augmentations.
|
|
||||||
* @remarks
|
|
||||||
* RAM cost: 0.5 GB * 16/4/1
|
|
||||||
*
|
|
||||||
* @returns The timestamp in milliseconds from your last augmentation install.
|
|
||||||
*/
|
|
||||||
getLastAugReset(): number;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the last timestamp from when you finished a bitnode.
|
|
||||||
* @remarks
|
|
||||||
* RAM cost: 0.5 GB * 16/4/1
|
|
||||||
*
|
|
||||||
* @returns The timestamp in milliseconds from your last bitnode finish.
|
|
||||||
*/
|
|
||||||
getLastNodeReset(): number;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -6573,8 +6565,8 @@ export interface NS {
|
|||||||
formatPercent(n: number, fractionalDigits?: number, multStart?: number): string;
|
formatPercent(n: number, fractionalDigits?: number, multStart?: number): string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Format a number using the numeral library. This function is deprecated and will be removed in 2.3.
|
* Format a number using the numeral library. This function is deprecated and will be removed in 2.4.
|
||||||
* @deprecated Use ns.formatNumber, formatRam, or formatPercent instead. Will be removed in 2.3.
|
* @deprecated Use ns.formatNumber, formatRam, or formatPercent instead. Will be removed in 2.4.
|
||||||
* @remarks
|
* @remarks
|
||||||
* RAM cost: 0 GB
|
* RAM cost: 0 GB
|
||||||
*
|
*
|
||||||
@ -6815,8 +6807,6 @@ export interface NS {
|
|||||||
* @remarks
|
* @remarks
|
||||||
* RAM cost: 0 GB
|
* RAM cost: 0 GB
|
||||||
*
|
*
|
||||||
* NS2 exclusive.
|
|
||||||
*
|
|
||||||
* Move the source file to the specified destination on the target server.
|
* Move the source file to the specified destination on the target server.
|
||||||
*
|
*
|
||||||
* This command only works for scripts and text files (.txt). It cannot, however, be used
|
* This command only works for scripts and text files (.txt). It cannot, however, be used
|
||||||
@ -6830,6 +6820,20 @@ export interface NS {
|
|||||||
*/
|
*/
|
||||||
mv(host: string, source: string, destination: string): void;
|
mv(host: string, source: string, destination: string): void;
|
||||||
|
|
||||||
|
/** Get information about resets.
|
||||||
|
* @remarks
|
||||||
|
* RAM cost: 1 GB
|
||||||
|
*
|
||||||
|
* @example
|
||||||
|
* ```js
|
||||||
|
* const resetInfo = ns.getResetInfo();
|
||||||
|
* const lastAugReset = resetInfo.lastAugReset;
|
||||||
|
* ns.tprint(`The last augmentation reset was: ${new Date(lastAugReset)}`);
|
||||||
|
* ns.tprint(`It has been ${Date.now() - lastAugReset}ms since the last augmentation reset.`);
|
||||||
|
* ```
|
||||||
|
* */
|
||||||
|
getResetInfo(): ResetInfo;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parse command line flags.
|
* Parse command line flags.
|
||||||
* @remarks
|
* @remarks
|
||||||
|
Loading…
Reference in New Issue
Block a user