Added offline properties for Script object

This commit is contained in:
Daniel Xie
2016-11-21 05:22:18 -06:00
parent d372ce5980
commit 1a600ad560
3 changed files with 19 additions and 18 deletions
+18 -2
View File
@@ -7,9 +7,21 @@ function Script() {
//is executed every second (this may change)
this.functionQueue = [];
this.code = "";
this.ramUsage = 0;
this.code = "";
this.ramUsage = 0;
/* 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
this.executionTimeMillis = 0;
//Number of instructions ("lines") in the code. Any call ending in a ;
//is considered one instruction. Used to calculate executionTime
this.numInstructions = 0;
//Which servers are hacked in one iteration of the script. May contain duplicates
this.serversHacked = [];
}
//Execute the next function in the Script's function queue
@@ -20,6 +32,10 @@ Script.prototype.executeNext() {
(this.functionQueue.shift())();
}
Script.prototype.setCode(code) {
this.code = code;
}
/* Wrapper object that wraps a function with its arguments.
* These objects are pushed onto a Script object's function queue.
* The functions can be called with the standard () operator