Changed the game speed so that it wasn't running faster (Rounding the number of game cycles usually caused it to speed up). Save Load function SHOULD be working now

This commit is contained in:
Daniel Xie 2016-12-01 16:39:13 -06:00
parent d5d198cbb4
commit 2fe4e8a19a
2 changed files with 13 additions and 10 deletions

@ -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;

@ -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