Alias Syntax

Posted by Leprakon on Fri 25 Jul 2003 04:29 PM — 10 posts, 36,015 views.

#0
I installed the Alias snippet found at alsherok.net, but what is the syntax for it?

The help file says it's:

alias <shortcut> <command> ,

but what if i wanted to do a shortcut for, say, casting magic missile on a mob. Is it possible to put a variable in the alias so you could just type something like "mm goblin" or something like that- instead of having to make an alias for every mob you wanted to cast magic missile on-? or would i have to modify the code substantially? Thanks
#1
Have you considered using MACROS to do this sort of thing?

When I played a different game called MAJOR MUD - I had macro sets for several different areas. Maros are very useful for doing the mundane things like eating, drinking and casting spells that you would do over and over again.

What Client do you use?
#2
I use SimpleMU, and it supports aliases...

but i'm putting Aliases in my MUD for the benefit of the people who want to play but don't have mud clients..
USA #3
A primitive solution would be to do something like the following:

- when a player command is interpreted, check to see if it's an alias.

- take a string, and put the alias's value to the beginning.

- then take the interpreted string, and add whatever "arguments" it has to the end of the string with the alias value.

For instance:
The player types "mm goblin".
The interpreter looks at the first word (the get_argument function would work) finds "mm" and says: "oh! this is an alias!"
It then looks up what this alias corresponds to, and finds "cast magic missile". So, it prints this to a string buffer.

It then goes back to what the player types. It removes the first word, and gets all the rest: in this case, "goblin". It then appends this to the string buffer, and we obtain "cast magic missle goblin".

This is less powerful than a proper alias because it can only append arguments at the end, but at least it works.

Off the top of my head, here is the code you would write once you've determined it's an alias. It is probably not completely correct. This would go somewhere in the interpret function. I'm assuming that "argument" is a char * that is the string being interpreted.


char newCommand[MAX_INPUT_LENGTH];
char command[MAX_INPUT_LENGTH];
char aliasArgs[MAX_INPUT_LENGTH];

// remove the command and store it
argument = one_argument(argument, command);

// store the arguments into aliasArgs
argument = one_argument(argument, aliasArgs);

// create the command buffer
sprintf(newCommand, "%s %s", command, aliasArgs);

// continue evaluating with newCommand
// one way to do this is simply replace argument with newCommand:
// sprintf(argument, "%s %s", command, aliasArgs);
// instead of printing it to newCommand


Now, before that you'd have to look through a table of alias definitions using the first word of the command, to make sure it is indeed an alias. I hope this helps you. :)
#4
yes, that helped a lot, thank you very much for the idea. It'll work for newbs- if they want more advanced aliases they can just use a client like zmud.
Australia Forum Administrator #5
or, MUSHclient.
#6
Have you considered using MACROS to do this sort of thing?

When I played a different game called MAJOR MUD - I had macro sets for several different areas. Maros are very useful for doing the mundane things like eating, drinking and casting spells that you would do over and over again.

What Client do you use?
USA #7
Garaelb, I believe the purpose of the operation was to provide in-game alias support for those who don't have MUD clients, and are connecting through telnet or a Javaweb client. If you read what he wrote carefully, he explains why he cares about programming it into SMAUG. :)
#8
lol yes. as a refresher (and i quote myself) : "but i'm putting Aliases in my MUD for the benefit of the people who want to play but don't have mud clients.."
USA #9
Hey, I rewrote a good bit of an alias snippet I downloaded to allow command stacking as well as make it easier to add and change aliases, if anyone wants the code for it, e-mail me at nevesfirestar2002@yahoo.com

-Nev