Merged and updated top command implementation

This commit is contained in:
Daniel Xie 2017-07-04 10:42:47 -05:00
parent a1943ce1c0
commit 147a7393c5
2 changed files with 6 additions and 7 deletions

@ -901,6 +901,9 @@ CONSTANTS = {
"-You can now see what an Augmentation does and its price even while its locked<br><br>", "-You can now see what an Augmentation does and its price even while its locked<br><br>",
LatestUpdate: LatestUpdate:
"v0.24.1<br>" +
"-'top' Terminal command implemented courtesy of Github user LTCNugget<br><br>" +
"v0.24.0<br>" + "v0.24.0<br>" +
"-Players now have HP, which is displayed in the top right. To regain HP, visit the hospital. Currently " + "-Players now have HP, which is displayed in the top right. To regain HP, visit the hospital. Currently " +
"the only way to lose HP is through infiltration<br>" + "the only way to lose HP is through infiltration<br>" +

@ -1043,11 +1043,9 @@ var Terminal = {
post("Script Threads RAM Usage"); post("Script Threads RAM Usage");
var currRunningScripts = Player.getCurrentServer().runningScripts; var currRunningScripts = Player.getCurrentServer().runningScripts;
var currScripts = Player.getCurrentServer().scripts;
//Iterate through scripts on current server //Iterate through scripts on current server
for(var i = 0; i < currScripts.length; i++) { for(var i = 0; i < currRunningScripts.length; i++) {
if(currRunningScripts.includes(currScripts[i].filename)) { //If the script is running var script = currRunningScripts[i];
var script = currScripts[i];
//Calculate name padding //Calculate name padding
var numSpacesScript = 26 - script.filename.length; //26 -> width of name column var numSpacesScript = 26 - script.filename.length; //26 -> width of name column
@ -1058,13 +1056,11 @@ var Terminal = {
var spacesThread = Array(numSpacesThread+1).join(" "); var spacesThread = Array(numSpacesThread+1).join(" ");
//Calculate and transform RAM usage //Calculate and transform RAM usage
var ramUsage = script.ramUsage * script.threads * Math.pow(1.02, script.threads - 1); ramUsage = (script.scriptRef.ramUsage * script.threads) + "GB";
ramUsage = ramUsage + "GB";
var entry = [script.filename, spacesScript, script.threads, spacesThread, ramUsage]; var entry = [script.filename, spacesScript, script.threads, spacesThread, ramUsage];
post(entry.join("")); post(entry.join(""));
} }
}
break; break;
case "unalias": case "unalias":
if (commandArray.length != 2) { if (commandArray.length != 2) {