diff --git a/src/Script.js b/src/Script.js index dbdb5dbc3..6e2540ff8 100644 --- a/src/Script.js +++ b/src/Script.js @@ -71,7 +71,8 @@ function Script() { /* Properties to calculate offline progress. Only applies for infinitely looping scripts */ //Time it takes to execute one iteration of the entire script - //Each function takes 1 second, plus hacking time plus and sleep commands + //Each function takes CONSTANTS.CodeInstructionRunTime seconds, + //plus hacking time plus and sleep commands this.executionTimeMillis = 0; //Number of instructions ("lines") in the code. Any call ending in a ; @@ -82,14 +83,6 @@ function Script() { this.serversHacked = []; }; -//Execute the next function in the Script's function queue -Script.prototype.executeNext = function() { - if (this.functionQueue.length <= 0) {return;} - - //Shift the next element off ths function queue and then execute it - (this.functionQueue.shift())(); -} - //Get the script data from the Script Editor and save it to the object Script.prototype.saveScript = function() { if (Engine.currentPage == Engine.Page.ScriptEditor) { @@ -106,3 +99,13 @@ Script.prototype.saveScript = function() { //TODO Calculate/update number of instructions, ram usage, execution time, etc. } } + +Script.prototype.toJSON = function() { + return Generic_toJSON("Script", this); +} + +Script.fromJSON = function(value) { + return Generic_fromJSON(Script, value.data); +} + +Reviver.constructors.Script = Script; \ No newline at end of file diff --git a/src/engine.js b/src/engine.js index b2a692303..3da8ad29a 100644 --- a/src/engine.js +++ b/src/engine.js @@ -152,7 +152,7 @@ var Engine = { var diff = _thisUpdate - Engine._lastUpdate; //Divide this by cycle time to determine how many cycles have elapsed since last update - diff = Math.round(diff / Engine._idleSpeed); + diff = Math.floor(diff / Engine._idleSpeed); if (diff > 0) { //Update the game engine by the calculated number of cycles