Added a ?noScripts query string that can be used to start the game without loading any scripts.

This commit is contained in:
danielyxie 2018-05-17 14:50:27 -05:00
parent 8f23a20719
commit c0ca464b5d
14 changed files with 82 additions and 112 deletions

62
dist/engine.bundle.js vendored

@ -2957,7 +2957,7 @@ function generateRandomString(n) {
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CONSTANTS", function() { return CONSTANTS; });
let CONSTANTS = {
Version: "0.36.1",
Version: "0.37.0",
//Max level for any skill, assuming no multipliers. Determined by max numerical value in javascript for experience
//and the skill level formula in Player.js. Note that all this means it that when experience hits MAX_INT, then
@ -4098,30 +4098,10 @@ let CONSTANTS = {
"World Stock Exchange account and TIX API Access<br>",
LatestUpdate:
"v0.36.1<br>" +
"* Bladeburner Changes: <br>" +
"** Bug Fix: You can no longer get Bladeburner faction reputation through Infiltration<br>" +
"** Initial difficulty of Tracking contracts reduced<br>" +
"** Datamancer skill effect increased from 4% per level to 5%<br>" +
"** Slightly decreased the base stamina cost of contracts/operations<br>" +
"** Slightly increased the effects of the Tracer, Digital Observer, Short Circuit, Cloak, and Blade's Intuition skills<br>" +
"** Overclock skill capped at level 95, rather than 99<br>" +
"** Training gives significantly more exp/s<br>" +
"* Crime, Infiltration, and Hacking are now slightly more profitable in BN-6<br>" +
"* Gyms are now more expensive, but give slightly more exp<br>" +
"* Added getScriptName() and getHacknetMultipliers() Netscript functions (added by Github user hydroflame)<br>" +
"* getScriptRam() Netscript function now has default value for the second argument, which is hostname/ip (implemented by Github user hydroflame)<br>" +
"* There is now a soft-cap on stock price, which means it's no longer possible for the price of a stock to reach insanely-high values<br>" +
"* The ctrl+b hotkey in the text editor should now also be triggered by command+b on OSX (I don't have OSX so I can't confirm if this works)<br>" +
"* Many servers now have additional RAM<br>" +
"* Added an option to disable hotkeys/keyboard shortcuts<br>" +
"* Refactored 'Active Scripts' UI page to optimize its performance<br>" +
"* Added a new .fconf Terminal setting: ENABLE_TIMESTAMP<br>" +
"* 'Netscript Execution Time', which can be found in the Options, now has a minimum value of 15ms rather than 25ms<br>" +
"* Bug Fix: Fixed a typo in the Fulcrum Technologies company name (Technolgies -> Technologies)<br>" +
"* Bug Fix: hacknetnodes keyword should no longer incur RAM cost if its in a comment<br>" +
"* Bug Fix: disableLog() now works for the commitCrime() Netscript function (fixed by Github user hydroflame)"
"v0.37.0<br>" +
"* NetscriptJS (Netscript 2.0) released<br>" +
"* Running the game with the '?noScripts' query will start the game without loading any of your scripts. " +
"This should be used if you accidentally write a script that crashes your game<br>"
}
@ -8133,8 +8113,6 @@ window.onload = function() {
var db = e.target.result;
var objectStore = db.createObjectStore("savestring");
}
console.log(window.location.href);
};
@ -18617,10 +18595,12 @@ function startJsScript(workerScript) {
//Loop through workerScripts and run every script that is not currently running
function runScriptsLoop() {
//Delete any scripts that finished or have been killed. Loop backwards bc removing
//items fucks up the indexing
var scriptDeleted = false;
//Delete any scripts that finished or have been killed. Loop backwards bc removing items screws up indexing
for (var i = workerScripts.length - 1; i >= 0; i--) {
if (workerScripts[i].running == false && workerScripts[i].env.stopFlag == true) {
scriptDeleted = true;
//Delete script from the runningScripts array on its host serverIp
var ip = workerScripts[i].serverIp;
var name = workerScripts[i].name;
@ -18643,7 +18623,8 @@ function runScriptsLoop() {
workerScripts.splice(i, 1);
}
}
Object(_ActiveScriptsUI_js__WEBPACK_IMPORTED_MODULE_0__["updateActiveScriptsItems"])(); //Force Update
if (scriptDeleted) {Object(_ActiveScriptsUI_js__WEBPACK_IMPORTED_MODULE_0__["updateActiveScriptsItems"])();} //Force Update
//Run any scripts that haven't been started
for (var i = 0; i < workerScripts.length; i++) {
@ -26528,6 +26509,8 @@ _utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_14__["Reviver"].constructors.Scri
function loadAllRunningScripts() {
var count = 0;
var total = 0;
let skipScriptLoad = (window.location.href.toLowerCase().indexOf("?noscripts") !== -1);
if (skipScriptLoad) {console.log("Skipping the load of any scripts during startup");}
for (var property in _Server_js__WEBPACK_IMPORTED_MODULE_8__["AllServers"]) {
if (_Server_js__WEBPACK_IMPORTED_MODULE_8__["AllServers"].hasOwnProperty(property)) {
var server = _Server_js__WEBPACK_IMPORTED_MODULE_8__["AllServers"][property];
@ -26540,14 +26523,19 @@ function loadAllRunningScripts() {
server.scripts[i].module = "";
}
for (var j = 0; j < server.runningScripts.length; ++j) {
count++;
server.runningScripts[j].scriptRef.module = "";
Object(_NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_6__["addWorkerScript"])(server.runningScripts[j], server);
if (skipScriptLoad) {
//Start game with no scripts
server.runningScripts.length = 0;
} else {
for (var j = 0; j < server.runningScripts.length; ++j) {
count++;
server.runningScripts[j].scriptRef.module = "";
Object(_NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_6__["addWorkerScript"])(server.runningScripts[j], server);
//Offline production
total += scriptCalculateOfflineProduction(server.runningScripts[j]);
}
//Offline production
total += scriptCalculateOfflineProduction(server.runningScripts[j]);
}
}
}
}
return total;

62
dist/tests.bundle.js vendored

@ -2957,7 +2957,7 @@ function generateRandomString(n) {
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CONSTANTS", function() { return CONSTANTS; });
let CONSTANTS = {
Version: "0.36.1",
Version: "0.37.0",
//Max level for any skill, assuming no multipliers. Determined by max numerical value in javascript for experience
//and the skill level formula in Player.js. Note that all this means it that when experience hits MAX_INT, then
@ -4098,30 +4098,10 @@ let CONSTANTS = {
"World Stock Exchange account and TIX API Access<br>",
LatestUpdate:
"v0.36.1<br>" +
"* Bladeburner Changes: <br>" +
"** Bug Fix: You can no longer get Bladeburner faction reputation through Infiltration<br>" +
"** Initial difficulty of Tracking contracts reduced<br>" +
"** Datamancer skill effect increased from 4% per level to 5%<br>" +
"** Slightly decreased the base stamina cost of contracts/operations<br>" +
"** Slightly increased the effects of the Tracer, Digital Observer, Short Circuit, Cloak, and Blade's Intuition skills<br>" +
"** Overclock skill capped at level 95, rather than 99<br>" +
"** Training gives significantly more exp/s<br>" +
"* Crime, Infiltration, and Hacking are now slightly more profitable in BN-6<br>" +
"* Gyms are now more expensive, but give slightly more exp<br>" +
"* Added getScriptName() and getHacknetMultipliers() Netscript functions (added by Github user hydroflame)<br>" +
"* getScriptRam() Netscript function now has default value for the second argument, which is hostname/ip (implemented by Github user hydroflame)<br>" +
"* There is now a soft-cap on stock price, which means it's no longer possible for the price of a stock to reach insanely-high values<br>" +
"* The ctrl+b hotkey in the text editor should now also be triggered by command+b on OSX (I don't have OSX so I can't confirm if this works)<br>" +
"* Many servers now have additional RAM<br>" +
"* Added an option to disable hotkeys/keyboard shortcuts<br>" +
"* Refactored 'Active Scripts' UI page to optimize its performance<br>" +
"* Added a new .fconf Terminal setting: ENABLE_TIMESTAMP<br>" +
"* 'Netscript Execution Time', which can be found in the Options, now has a minimum value of 15ms rather than 25ms<br>" +
"* Bug Fix: Fixed a typo in the Fulcrum Technologies company name (Technolgies -> Technologies)<br>" +
"* Bug Fix: hacknetnodes keyword should no longer incur RAM cost if its in a comment<br>" +
"* Bug Fix: disableLog() now works for the commitCrime() Netscript function (fixed by Github user hydroflame)"
"v0.37.0<br>" +
"* NetscriptJS (Netscript 2.0) released<br>" +
"* Running the game with the '?noScripts' query will start the game without loading any of your scripts. " +
"This should be used if you accidentally write a script that crashes your game<br>"
}
@ -8133,8 +8113,6 @@ window.onload = function() {
var db = e.target.result;
var objectStore = db.createObjectStore("savestring");
}
console.log(window.location.href);
};
@ -18617,10 +18595,12 @@ function startJsScript(workerScript) {
//Loop through workerScripts and run every script that is not currently running
function runScriptsLoop() {
//Delete any scripts that finished or have been killed. Loop backwards bc removing
//items fucks up the indexing
var scriptDeleted = false;
//Delete any scripts that finished or have been killed. Loop backwards bc removing items screws up indexing
for (var i = workerScripts.length - 1; i >= 0; i--) {
if (workerScripts[i].running == false && workerScripts[i].env.stopFlag == true) {
scriptDeleted = true;
//Delete script from the runningScripts array on its host serverIp
var ip = workerScripts[i].serverIp;
var name = workerScripts[i].name;
@ -18643,7 +18623,8 @@ function runScriptsLoop() {
workerScripts.splice(i, 1);
}
}
Object(_ActiveScriptsUI_js__WEBPACK_IMPORTED_MODULE_0__["updateActiveScriptsItems"])(); //Force Update
if (scriptDeleted) {Object(_ActiveScriptsUI_js__WEBPACK_IMPORTED_MODULE_0__["updateActiveScriptsItems"])();} //Force Update
//Run any scripts that haven't been started
for (var i = 0; i < workerScripts.length; i++) {
@ -26528,6 +26509,8 @@ _utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_14__["Reviver"].constructors.Scri
function loadAllRunningScripts() {
var count = 0;
var total = 0;
let skipScriptLoad = (window.location.href.toLowerCase().indexOf("?noscripts") !== -1);
if (skipScriptLoad) {console.log("Skipping the load of any scripts during startup");}
for (var property in _Server_js__WEBPACK_IMPORTED_MODULE_8__["AllServers"]) {
if (_Server_js__WEBPACK_IMPORTED_MODULE_8__["AllServers"].hasOwnProperty(property)) {
var server = _Server_js__WEBPACK_IMPORTED_MODULE_8__["AllServers"][property];
@ -26540,14 +26523,19 @@ function loadAllRunningScripts() {
server.scripts[i].module = "";
}
for (var j = 0; j < server.runningScripts.length; ++j) {
count++;
server.runningScripts[j].scriptRef.module = "";
Object(_NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_6__["addWorkerScript"])(server.runningScripts[j], server);
if (skipScriptLoad) {
//Start game with no scripts
server.runningScripts.length = 0;
} else {
for (var j = 0; j < server.runningScripts.length; ++j) {
count++;
server.runningScripts[j].scriptRef.module = "";
Object(_NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_6__["addWorkerScript"])(server.runningScripts[j], server);
//Offline production
total += scriptCalculateOfflineProduction(server.runningScripts[j]);
}
//Offline production
total += scriptCalculateOfflineProduction(server.runningScripts[j]);
}
}
}
}
return total;

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

@ -41,6 +41,8 @@ Therefore, the signature of the :code:`main()` function must be::
export async function main(ns) {
ns.print("Starting script here");
ns.hack("foodnstuff"); //Use Netscript hack function
ns.print(ns.args); //The script arguments must be prefaced with ns as well
}
Here is a summary of all rules you need to follow when writing Netscript JS code:

@ -86,6 +86,8 @@ the main function. This environment includes all of the pre-defined Netscript fu
<p>Therefore, the signature of the <code class="code docutils literal"><span class="pre">main()</span></code> function must be:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">export</span> <span class="k">async</span> <span class="n">function</span> <span class="n">main</span><span class="p">(</span><span class="n">ns</span><span class="p">)</span> <span class="p">{</span>
<span class="n">ns</span><span class="o">.</span><span class="n">print</span><span class="p">(</span><span class="s2">&quot;Starting script here&quot;</span><span class="p">);</span>
<span class="n">ns</span><span class="o">.</span><span class="n">hack</span><span class="p">(</span><span class="s2">&quot;foodnstuff&quot;</span><span class="p">);</span> <span class="o">//</span><span class="n">Use</span> <span class="n">Netscript</span> <span class="n">hack</span> <span class="n">function</span>
<span class="n">ns</span><span class="o">.</span><span class="n">print</span><span class="p">(</span><span class="n">ns</span><span class="o">.</span><span class="n">args</span><span class="p">);</span> <span class="o">//</span><span class="n">The</span> <span class="n">script</span> <span class="n">arguments</span> <span class="n">must</span> <span class="n">be</span> <span class="n">prefaced</span> <span class="k">with</span> <span class="n">ns</span> <span class="k">as</span> <span class="n">well</span>
<span class="p">}</span>
</pre></div>
</div>

File diff suppressed because one or more lines are too long

@ -41,6 +41,8 @@ Therefore, the signature of the :code:`main()` function must be::
export async function main(ns) {
ns.print("Starting script here");
ns.hack("foodnstuff"); //Use Netscript hack function
ns.print(ns.args); //The script arguments must be prefaced with ns as well
}
Here is a summary of all rules you need to follow when writing Netscript JS code:

@ -1,5 +1,5 @@
let CONSTANTS = {
Version: "0.36.1",
Version: "0.37.0",
//Max level for any skill, assuming no multipliers. Determined by max numerical value in javascript for experience
//and the skill level formula in Player.js. Note that all this means it that when experience hits MAX_INT, then
@ -1140,30 +1140,10 @@ let CONSTANTS = {
"World Stock Exchange account and TIX API Access<br>",
LatestUpdate:
"v0.36.1<br>" +
"* Bladeburner Changes: <br>" +
"** Bug Fix: You can no longer get Bladeburner faction reputation through Infiltration<br>" +
"** Initial difficulty of Tracking contracts reduced<br>" +
"** Datamancer skill effect increased from 4% per level to 5%<br>" +
"** Slightly decreased the base stamina cost of contracts/operations<br>" +
"** Slightly increased the effects of the Tracer, Digital Observer, Short Circuit, Cloak, and Blade's Intuition skills<br>" +
"** Overclock skill capped at level 95, rather than 99<br>" +
"** Training gives significantly more exp/s<br>" +
"* Crime, Infiltration, and Hacking are now slightly more profitable in BN-6<br>" +
"* Gyms are now more expensive, but give slightly more exp<br>" +
"* Added getScriptName() and getHacknetMultipliers() Netscript functions (added by Github user hydroflame)<br>" +
"* getScriptRam() Netscript function now has default value for the second argument, which is hostname/ip (implemented by Github user hydroflame)<br>" +
"* There is now a soft-cap on stock price, which means it's no longer possible for the price of a stock to reach insanely-high values<br>" +
"* The ctrl+b hotkey in the text editor should now also be triggered by command+b on OSX (I don't have OSX so I can't confirm if this works)<br>" +
"* Many servers now have additional RAM<br>" +
"* Added an option to disable hotkeys/keyboard shortcuts<br>" +
"* Refactored 'Active Scripts' UI page to optimize its performance<br>" +
"* Added a new .fconf Terminal setting: ENABLE_TIMESTAMP<br>" +
"* 'Netscript Execution Time', which can be found in the Options, now has a minimum value of 15ms rather than 25ms<br>" +
"* Bug Fix: Fixed a typo in the Fulcrum Technologies company name (Technolgies -> Technologies)<br>" +
"* Bug Fix: hacknetnodes keyword should no longer incur RAM cost if its in a comment<br>" +
"* Bug Fix: disableLog() now works for the commitCrime() Netscript function (fixed by Github user hydroflame)"
"v0.37.0<br>" +
"* NetscriptJS (Netscript 2.0) released<br>" +
"* Running the game with the '?noScripts' query will start the game without loading any of your scripts. " +
"This should be used if you accidentally write a script that crashes your game<br>"
}
export {CONSTANTS};

@ -141,10 +141,12 @@ function startJsScript(workerScript) {
//Loop through workerScripts and run every script that is not currently running
function runScriptsLoop() {
//Delete any scripts that finished or have been killed. Loop backwards bc removing
//items fucks up the indexing
var scriptDeleted = false;
//Delete any scripts that finished or have been killed. Loop backwards bc removing items screws up indexing
for (var i = workerScripts.length - 1; i >= 0; i--) {
if (workerScripts[i].running == false && workerScripts[i].env.stopFlag == true) {
scriptDeleted = true;
//Delete script from the runningScripts array on its host serverIp
var ip = workerScripts[i].serverIp;
var name = workerScripts[i].name;
@ -167,7 +169,8 @@ function runScriptsLoop() {
workerScripts.splice(i, 1);
}
}
updateActiveScriptsItems(); //Force Update
if (scriptDeleted) {updateActiveScriptsItems();} //Force Update
//Run any scripts that haven't been started
for (var i = 0; i < workerScripts.length; i++) {

@ -709,6 +709,8 @@ Reviver.constructors.Script = Script;
function loadAllRunningScripts() {
var count = 0;
var total = 0;
let skipScriptLoad = (window.location.href.toLowerCase().indexOf("?noscripts") !== -1);
if (skipScriptLoad) {console.log("Skipping the load of any scripts during startup");}
for (var property in AllServers) {
if (AllServers.hasOwnProperty(property)) {
var server = AllServers[property];
@ -721,14 +723,19 @@ function loadAllRunningScripts() {
server.scripts[i].module = "";
}
for (var j = 0; j < server.runningScripts.length; ++j) {
count++;
server.runningScripts[j].scriptRef.module = "";
addWorkerScript(server.runningScripts[j], server);
if (skipScriptLoad) {
//Start game with no scripts
server.runningScripts.length = 0;
} else {
for (var j = 0; j < server.runningScripts.length; ++j) {
count++;
server.runningScripts[j].scriptRef.module = "";
addWorkerScript(server.runningScripts[j], server);
//Offline production
total += scriptCalculateOfflineProduction(server.runningScripts[j]);
}
//Offline production
total += scriptCalculateOfflineProduction(server.runningScripts[j]);
}
}
}
}
return total;

@ -1764,8 +1764,6 @@ window.onload = function() {
var db = e.target.result;
var objectStore = db.createObjectStore("savestring");
}
console.log(window.location.href);
};
export {Engine};