diff --git a/css/menupages.css b/css/menupages.css index 2d50a9b2c..998a65876 100644 --- a/css/menupages.css +++ b/css/menupages.css @@ -145,7 +145,8 @@ background-color: #555; overflow-y: scroll; } -#active-scripts-text { +#active-scripts-text, +#active-scripts-total-prod { width: 70%; margin: 6px; padding: 4px; diff --git a/index.html b/index.html index 445e20edd..7bf409b5a 100644 --- a/index.html +++ b/index.html @@ -166,6 +166,7 @@

This page displays a list of all scripts that are currently running across every machine. It also gives information about their production

+

Total online production rate:

diff --git a/src/HacknetNode.js b/src/HacknetNode.js index c4391cfbe..35e5904d0 100644 --- a/src/HacknetNode.js +++ b/src/HacknetNode.js @@ -77,9 +77,8 @@ HacknetNode.prototype.purchaseLevelUpgrade = function(levels=1) { if (cost > Player.money) {return false;} Player.loseMoney(cost); if (this.level + levels >= CONSTANTS.HacknetNodeMaxLevel) { - this.level = CONSTANTS.HacknetNodeMaxLevel; - this.updateMoneyGainRate(); - return true; + var diff = Math.max(0, CONSTANTS.HacknetNodeMaxLevel - this.level); + return this.purchaseLevelUpgrade(diff); } this.level += levels; this.updateMoneyGainRate(); @@ -373,7 +372,8 @@ updateHacknetNodeDomElement = function(nodeObj) { //Max multiplier = getMaxNumberLevelUpgrades(nodeObj); } else { - multiplier = hacknetNodePurchaseMultiplier; + var levelsToMax = CONSTANTS.HacknetNodeMaxLevel - nodeObj.level; + multiplier = Math.min(levelsToMax, hacknetNodePurchaseMultiplier); } var upgradeLevelCost = nodeObj.calculateLevelUpgradeCost(multiplier); diff --git a/src/NetscriptWorker.js b/src/NetscriptWorker.js index 1076ced86..fc0ab078c 100644 --- a/src/NetscriptWorker.js +++ b/src/NetscriptWorker.js @@ -57,6 +57,7 @@ function runScriptsLoop() { if (errorTextArray.length != 4) { console.log("ERROR: Something wrong with Error text in evaluator..."); console.log("Error text: " + errorText); + return; } var serverIp = errorTextArray[1]; var scriptName = errorTextArray[2]; @@ -78,6 +79,7 @@ function runScriptsLoop() { if (errorTextArray.length != 4) { console.log("ERROR: Something wrong with Error text in evaluator..."); console.log("Error text: " + errorText); + return; } var serverIp = errorTextArray[1]; var scriptName = errorTextArray[2]; @@ -87,7 +89,28 @@ function runScriptsLoop() { } w.running = false; w.env.stopFlag = true; - } + } else if (isScriptErrorMessage(w)) { + var errorTextArray = errorText.split("|"); + if (errorTextArray.length != 4) { + console.log("ERROR: Something wrong with Error text in evaluator..."); + console.log("Error text: " + errorText); + return; + } + var serverIp = errorTextArray[1]; + var scriptName = errorTextArray[2]; + var errorMsg = errorTextArray[3]; + + dialogBoxCreate("Script runtime error: ", "Server Ip: " + serverIp, "Script name: " + scriptName, errorMsg); + + //Find the corresponding workerscript and set its flags to kill it + for (var i = 0; i < workerScripts.length; ++i) { + if (workerScripts[i].serverIp == serverIp && workerScripts[i].name == scriptName) { + workerScripts[i].running = false; + workerScripts[i].env.stopFlag = true; + return; + } + } + } }); } } diff --git a/src/engine.js b/src/engine.js index 56535293d..23b28909f 100644 --- a/src/engine.js +++ b/src/engine.js @@ -363,9 +363,12 @@ var Engine = { //Update the ActiveScriptsItems array updateActiveScriptsItems: function() { + var total = 0; for (var i = 0; i < workerScripts.length; ++i) { - Engine.updateActiveScriptsItemContent(i, workerScripts[i]); + total += Engine.updateActiveScriptsItemContent(i, workerScripts[i]); } + document.getElementById("active-scripts-total-prod").innerHTML = + "Total online production rate: $" + formatNumber(total, 2) + " / second"; }, //Updates the content of the given item in the Active Scripts list @@ -382,8 +385,8 @@ var Engine = { item.removeChild(item.firstChild); } - //Add the updated text back - Engine.createActiveScriptsText(workerscript, item); + //Add the updated text back. Returns the total online production rate + return Engine.createActiveScriptsText(workerscript, item); }, createActiveScriptsText: function(workerscript, item) { @@ -421,6 +424,9 @@ var Engine = { offlineMpsText + "
" + offlineEpsText + "
"; item.appendChild(itemText); + + //Return total online production rate + return onlineMps; }, displayFactionsInfo: function() {