Fixed issues with new aliasing, updating changelog

This commit is contained in:
Daniel Xie 2017-07-05 12:53:51 -05:00
parent 542a32c768
commit a593243b73
3 changed files with 25 additions and 13 deletions

@ -62,6 +62,10 @@ function removeAlias(name) {
delete Aliases[name];
return true;
}
if (GlobalAliases.hasOwnProperty(name)) {
delete GlobalAliases[name];
return true;
}
return false;
}

@ -170,7 +170,7 @@ CONSTANTS = {
CrimeHeist: "pull off the ultimate heist",
//Text that is displayed when the 'help' command is ran in Terminal
HelpText: 'alias [name="value"] Create aliases for Terminal commands, or list existing aliases<br>' +
HelpText: 'alias [-g] [name="value"] Create aliases for Terminal commands, or list existing aliases<br>' +
"analyze Get statistics and information about current machine <br>" +
"cat [message] Display a .msg file<br>" +
"check [script] [args...] Print logs to Terminal for the script with the specified name and arguments<br>" +
@ -917,7 +917,11 @@ CONSTANTS = {
"-Studying at a university is now considerably more expensive<br>" +
"-Significantly increased cost multiplier for purchasing additional Hacknet Nodes<br>" +
"-Updated Faction descriptions<br>" +
"-'top' Terminal command implemented courtesy of Github user LTCNugget<br><br>" +
"-Changed the way alias works. Normal aliases now only work at the start of a Terminal command (they will only " +
"replace the first word in the Terminal command). You can also create global aliases that work on any part of the " +
"command, like before. Declare global aliases by entering the optional -g flag: alias -g alias=Courtesy of Github user MrNuggelz" +
"-'top' Terminal command implemented courtesy of Github user LTCNugget. Currently, the formatting gets screwed up " +
"if your script names are really long.<br><br>" +
"v0.24.0<br>" +
"-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>" +

@ -583,16 +583,19 @@ var Terminal = {
printAliases();
return;
}
if (commandArray.length == 2 ) {
var args = commandArray[1].split(" ");
if (args.length == 1 && parseAliasDeclaration(args[0])){
return;
}
if (args.length == 2 && args[0] == "-g" && parseAliasDeclaration(args[1],true)){
return;
if (commandArray.length == 2) {
if (commandArray[1].startsWith("-g ")) {
var alias = commandArray[1].substring(3);
if (parseAliasDeclaration(alias, true)) {
return;
}
} else {
if (parseAliasDeclaration(commandArray[1])) {
return;
}
}
}
post('Incorrect usage of alias command. Usage: alias [aliasname="value"]');
post('Incorrect usage of alias command. Usage: alias [-g] [aliasname="value"]');
break;
case "analyze":
if (commandArray.length != 1) {
@ -1043,7 +1046,7 @@ var Terminal = {
post("Incorrect usage of top command. Usage: top"); return;
}
post("Script Threads RAM Usage");
post("Script Threads RAM Usage");
var currRunningScripts = Player.getCurrentServer().runningScripts;
//Iterate through scripts on current server
@ -1051,7 +1054,8 @@ var Terminal = {
var script = currRunningScripts[i];
//Calculate name padding
var numSpacesScript = 26 - script.filename.length; //26 -> width of name column
var numSpacesScript = 32 - script.filename.length; //26 -> width of name column
if (numSpacesScript < 0) {numSpacesScript = 0;}
var spacesScript = Array(numSpacesScript+1).join(" ");
//Calculate thread padding
@ -1059,7 +1063,7 @@ var Terminal = {
var spacesThread = Array(numSpacesThread+1).join(" ");
//Calculate and transform RAM usage
ramUsage = (script.scriptRef.ramUsage * script.threads) + "GB";
ramUsage = formatNumber(script.scriptRef.ramUsage * script.threads, 2).toString() + "GB";
var entry = [script.filename, spacesScript, script.threads, spacesThread, ramUsage];
post(entry.join(""));