diff --git a/src/Alias.js b/src/Alias.js
index da6be05b6..6e5974989 100644
--- a/src/Alias.js
+++ b/src/Alias.js
@@ -62,6 +62,10 @@ function removeAlias(name) {
delete Aliases[name];
return true;
}
+ if (GlobalAliases.hasOwnProperty(name)) {
+ delete GlobalAliases[name];
+ return true;
+ }
return false;
}
diff --git a/src/Constants.js b/src/Constants.js
index c49b30f05..e04e8920b 100644
--- a/src/Constants.js
+++ b/src/Constants.js
@@ -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
' +
+ HelpText: 'alias [-g] [name="value"] Create aliases for Terminal commands, or list existing aliases
' +
"analyze Get statistics and information about current machine
" +
"cat [message] Display a .msg file
" +
"check [script] [args...] Print logs to Terminal for the script with the specified name and arguments
" +
@@ -917,7 +917,11 @@ CONSTANTS = {
"-Studying at a university is now considerably more expensive
" +
"-Significantly increased cost multiplier for purchasing additional Hacknet Nodes
" +
"-Updated Faction descriptions
" +
- "-'top' Terminal command implemented courtesy of Github user LTCNugget
" +
+ "-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.
" +
"v0.24.0
" +
"-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
" +
diff --git a/src/Terminal.js b/src/Terminal.js
index d7cf0ee24..6aa6d2157 100644
--- a/src/Terminal.js
+++ b/src/Terminal.js
@@ -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(""));