Addded Perk class, Traveling functionality, fixed bugs with script logging and terminal commands

This commit is contained in:
Daniel Xie
2017-04-13 12:33:34 -05:00
parent 3ecbed1351
commit 52297268f6
13 changed files with 151 additions and 46 deletions
+6 -6
View File
@@ -68,7 +68,7 @@ function Script() {
this.code = "";
this.ramUsage = 0;
this.server = ""; //IP of server this script is on
this.log = []; //Script logging. Array of strings, with each element being a log entry
this.logs = []; //Script logging. Array of strings, with each element being a log entry
/* Properties to calculate offline progress. Only applies for infinitely looping scripts */
@@ -127,18 +127,18 @@ Script.prototype.updateRamUsage = function() {
}
Script.prototype.log = function(txt) {
if (this.log.length > CONSTANTS.MaxLogCapacity) {
if (this.logs.length > CONSTANTS.MaxLogCapacity) {
//Delete first element and add new log entry to the end.
//TODO Eventually it might be better to replace this with circular array
//to improve performance
this.log.shift();
this.logs.shift();
}
this.log.push(txt);
this.logs.push(txt);
}
Script.prototype.displayLog = function() {
for (var i = 0; i < this.log.length; ++i) {
post(this.log[i]);
for (var i = 0; i < this.logs.length; ++i) {
post(this.logs[i]);
}
}