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

View File

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

View File

@ -170,7 +170,7 @@ CONSTANTS = {
CrimeHeist: "pull off the ultimate heist", CrimeHeist: "pull off the ultimate heist",
//Text that is displayed when the 'help' command is ran in Terminal //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>" + "analyze Get statistics and information about current machine <br>" +
"cat [message] Display a .msg file<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>" + "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>" + "-Studying at a university is now considerably more expensive<br>" +
"-Significantly increased cost multiplier for purchasing additional Hacknet Nodes<br>" + "-Significantly increased cost multiplier for purchasing additional Hacknet Nodes<br>" +
"-Updated Faction descriptions<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>" + "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>" +

View File

@ -584,15 +584,18 @@ var Terminal = {
return; return;
} }
if (commandArray.length == 2) { if (commandArray.length == 2) {
var args = commandArray[1].split(" "); if (commandArray[1].startsWith("-g ")) {
if (args.length == 1 && parseAliasDeclaration(args[0])){ var alias = commandArray[1].substring(3);
if (parseAliasDeclaration(alias, true)) {
return; return;
} }
if (args.length == 2 && args[0] == "-g" && parseAliasDeclaration(args[1],true)){ } else {
if (parseAliasDeclaration(commandArray[1])) {
return; return;
} }
} }
post('Incorrect usage of alias command. Usage: alias [aliasname="value"]'); }
post('Incorrect usage of alias command. Usage: alias [-g] [aliasname="value"]');
break; break;
case "analyze": case "analyze":
if (commandArray.length != 1) { if (commandArray.length != 1) {
@ -1051,7 +1054,8 @@ var Terminal = {
var script = currRunningScripts[i]; var script = currRunningScripts[i];
//Calculate name padding //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(" "); var spacesScript = Array(numSpacesScript+1).join(" ");
//Calculate thread padding //Calculate thread padding
@ -1059,7 +1063,7 @@ var Terminal = {
var spacesThread = Array(numSpacesThread+1).join(" "); var spacesThread = Array(numSpacesThread+1).join(" ");
//Calculate and transform RAM usage //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]; var entry = [script.filename, spacesScript, script.threads, spacesThread, ramUsage];
post(entry.join("")); post(entry.join(""));