fix previous commit, improve argument page on docs

This commit is contained in:
Mughur 2023-01-30 21:42:46 +02:00
parent 6369ab434b
commit 23199ee705
4 changed files with 47 additions and 14 deletions

@ -16,9 +16,16 @@ This includes information such as function signatures, what they do, and their r
sleep() <basicfunctions/sleep> sleep() <basicfunctions/sleep>
print() <basicfunctions/print> print() <basicfunctions/print>
tprint() <basicfunctions/tprint> tprint() <basicfunctions/tprint>
tFormat() <basicfunctions/tFormat>
nFormat() <basicfunctions/nFormat>
disableLog() <basicfunctions/disableLog> disableLog() <basicfunctions/disableLog>
enableLog() <basicfunctions/enableLog> enableLog() <basicfunctions/enableLog>
isLogEnabled() <basicfunctions/isLogEnabled> isLogEnabled() <basicfunctions/isLogEnabled>
clearLog() <basicfunctions/clearLog>
tail() <basicfunctions/tail>
closeTail() <basicfunctions/closeTail>
moveTail() <basicfunctions/moveTail>
resizeTail() <basicfunctions/resizeTail>
scan() <basicfunctions/scan> scan() <basicfunctions/scan>
nuke() <basicfunctions/nuke> nuke() <basicfunctions/nuke>
brutessh() <basicfunctions/brutessh> brutessh() <basicfunctions/brutessh>
@ -31,10 +38,14 @@ This includes information such as function signatures, what they do, and their r
spawn() <basicfunctions/spawn> spawn() <basicfunctions/spawn>
kill() <basicfunctions/kill> kill() <basicfunctions/kill>
killall() <basicfunctions/killall> killall() <basicfunctions/killall>
scriptKill() <basicfunctions/scriptKill>
scriptRunning() <basicfunctions/scriptRunning>
scp() <basicfunctions/scp> scp() <basicfunctions/scp>
ls() <basicfunctions/ls> ls() <basicfunctions/ls>
ps() <basicfunctions/ps> ps() <basicfunctions/ps>
mv() <basicfunctions/mv>
hasRootAccess() <basicfunctions/hasRootAccess> hasRootAccess() <basicfunctions/hasRootAccess>
getHostname() <basicfunctions/getHostname>
getHackingLevel() <basicfunctions/getHackingLevel> getHackingLevel() <basicfunctions/getHackingLevel>
getHackingMultipliers() <basicfunctions/getHackingMultipliers> getHackingMultipliers() <basicfunctions/getHackingMultipliers>
getHacknetMultipliers() <basicfunctions/getHacknetMultipliers> getHacknetMultipliers() <basicfunctions/getHacknetMultipliers>
@ -49,14 +60,14 @@ This includes information such as function signatures, what they do, and their r
serverExists() <basicfunctions/serverExists> serverExists() <basicfunctions/serverExists>
fileExists() <basicfunctions/fileExists> fileExists() <basicfunctions/fileExists>
isRunning() <basicfunctions/isRunning> isRunning() <basicfunctions/isRunning>
getPurchasedServerCost() <basicfunctions/getPurchasedServerCost>
purchaseServer() <basicfunctions/purchaseServer> purchaseServer() <basicfunctions/purchaseServer>
deleteServer() <basicfunctions/deleteServer> deleteServer() <basicfunctions/deleteServer>
upgradePurchasedServer() <basicfunctions/upgradePurchasedServer> upgradePurchasedServer() <basicfunctions/upgradePurchasedServer>
getPurchasedServers() <basicfunctions/getPurchasedServers> getPurchasedServers() <basicfunctions/getPurchasedServers>
getPurchasedServerLimit() <basicfunctions/getPurchasedServerLimit> getPurchasedServerLimit() <basicfunctions/getPurchasedServerLimit>
getPurchasedServerMaxRam() <basicfunctions/getPurchasedServerMaxRam> getPurchasedServerMaxRam() <basicfunctions/getPurchasedServerMaxRam>
getPurchasedServerCost() <basicfunctions/getPurchasedServerCost>
getPurchasedServerUpgradeCost() <basicfunctions/getPurchasedServerUpgradeCost> getPurchasedServerUpgradeCost() <basicfunctions/getPurchasedServerUpgradeCost>
scriptRunning() <basicfunctions/scriptRunning>
scriptKill() <basicfunctions/scriptKill>
getScriptRam() <basicfunctions/getScriptRam> getScriptRam() <basicfunctions/getScriptRam>
share() <basicfunctions/share>
getSharePower() <basicfunctions/getSharePower>

@ -17,7 +17,9 @@ specified in the second argument. The code would look like:
.. code:: javascript .. code:: javascript
run(args[0], args[1]); var fileName = args[0];
var threads = args[1];
run(fileName, threads);
And it could be ran from the terminal like: And it could be ran from the terminal like:
@ -28,8 +30,29 @@ In .js / ns2, the above script would look like:
.. code:: javascript .. code:: javascript
export async function main(ns) { export async function main(ns) {
ns.run(ns.args[0], ns.args[1]); let fileName = ns.args[0];
let threads = ns.args[1];
ns.run(fileName, threads);
} }
It is also possible to get the number of arguments that were passed It is also possible to get the number of arguments that were passed
into a script using ``args.length``. into a script using ``args.length``.
If we want to make a script like ``foo.js`` that gets 2 arguments: a string to print
and a number of time to print that string, the code could look like:
.. code:: javascript
export async function main(ns) {
for (let i=0; i<ns.args[1];i++){
ns.tprint(ns.args[0])
}
}
Then we can have another script launch ``foo.js`` with the 2 arguments like:
.. code:: javascript
export async function main(ns) {
ns.exec("foo.js","n00dles",1,"this will be printed twice", 2)
}

@ -88,9 +88,7 @@ const Exclusive = (props: IExclusiveProps): React.ReactElement => {
Certain <b>gangs</b> Certain <b>gangs</b>
</li> </li>
)} )}
{Player.canAccessGrafting() && {Player.canAccessGrafting() && !props.aug.isSpecial && props.aug.name !== AugmentationNames.TheRedPill && (
!props.aug.isSpecial &&
props.aug.name !== AugmentationNames.TheRedPill && (
<li> <li>
<b>Grafting</b> <b>Grafting</b>
</li> </li>

@ -229,7 +229,8 @@ export class OfficeSpace {
} }
const diff = target - this.employeeNextJobs[job]; const diff = target - this.employeeNextJobs[job];
if (diff === 0) return true; // We are already at the desired number if (diff === 0) return true;
// We are already at the desired number
else if (diff <= this.employeeNextJobs[EmployeePositions.Unassigned]) { else if (diff <= this.employeeNextJobs[EmployeePositions.Unassigned]) {
// This covers both a negative diff (reducing the amount of employees in position) and a positive (increasing and using up unassigned employees) // This covers both a negative diff (reducing the amount of employees in position) and a positive (increasing and using up unassigned employees)
this.employeeNextJobs[EmployeePositions.Unassigned] -= diff; this.employeeNextJobs[EmployeePositions.Unassigned] -= diff;