Added mem command

This commit is contained in:
Daniel Xie 2017-05-14 21:46:52 -05:00
parent 6bbf28411f
commit 0019494ad2
2 changed files with 21 additions and 2 deletions

@ -63,4 +63,8 @@ Private beta feedback
For the last thing of the tutorial, I would just have a button like "Finish Tutorial" rather than "Next"
Command to see a script's RAM cost
Command to see a script's RAM cost
Netscript commands:
I just got two from the top of my head: a function to get the current cash on the server, and a function to know how much a hack would take
Like, if I want to grow each time I take 5000$ from the server, that would be practical

@ -205,7 +205,8 @@ function determineAllPossibilitiesForTabCompletion(input) {
}
if (input.startsWith("kill ") || input.startsWith("nano ") ||
input.startsWith("tail ") || input.startsWith("rm ")) {
input.startsWith("tail ") || input.startsWith("rm ") ||
input.startsWith("mem ")) {
//All Scripts
for (var i = 0; i < currServ.scripts.length; ++i) {
allPos.push(currServ.scripts[i].filename);
@ -598,6 +599,20 @@ var Terminal = {
case "ls":
Terminal.executeListCommand(commandArray);
break;
case "mem":
if (commandArray.length != 2) {
post("Incorrect usage of mem command. usage: mem [scriptname]"); return;
}
var scriptName = commandArray[1];
var currServ = Player.getCurrentServer();
for (var i = 0; i < currServ.scripts.length; ++i) {
if (scriptName == currServ.scripts[i].filename) {
post("This script requires " + formatNumber(currServ.scripts[i].ramUsage, 2) + "GB of RAM to run");
return;
}
}
post("ERR: No such script exists!");
break;
case "nano":
if (commandArray.length != 2) {
post("Incorrect usage of nano command. Usage: nano [scriptname]"); return;