Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are
spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the
password reset link.
Due to spam on this forum, all posts now need moderator approval.
Entire forum
➜ SMAUG
➜ SMAUG coding
➜ Alias Syntax
It is now over 60 days since the last post. This thread is closed.
Refresh page
Posted by
| Leprakon
(28 posts) Bio
|
Date
| Fri 25 Jul 2003 04:29 PM (UTC) |
Message
| 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 | Top |
|
Posted by
| Garaelb
(54 posts) Bio
|
Date
| Reply #1 on Fri 25 Jul 2003 05:12 PM (UTC) |
Message
| 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? | Top |
|
Posted by
| Leprakon
(28 posts) Bio
|
Date
| Reply #2 on Fri 25 Jul 2003 05:22 PM (UTC) |
Message
| 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.. | Top |
|
Posted by
| David Haley
USA (3,881 posts) Bio
|
Date
| Reply #3 on Fri 25 Jul 2003 06:03 PM (UTC) |
Message
| 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. :) |
David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone
http://david.the-haleys.org | Top |
|
Posted by
| Leprakon
(28 posts) Bio
|
Date
| Reply #4 on Fri 25 Jul 2003 08:51 PM (UTC) |
Message
| 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. | Top |
|
Posted by
| Nick Gammon
Australia (23,140 posts) Bio
Forum Administrator |
Date
| Reply #5 on Fri 25 Jul 2003 08:53 PM (UTC) |
Message
| or, MUSHclient. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Garaelb
(54 posts) Bio
|
Date
| Reply #6 on Sat 26 Jul 2003 06:20 AM (UTC) |
Message
| 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? | Top |
|
Posted by
| David Haley
USA (3,881 posts) Bio
|
Date
| Reply #7 on Sat 26 Jul 2003 11:41 AM (UTC) |
Message
| 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. :) |
David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone
http://david.the-haleys.org | Top |
|
Posted by
| Leprakon
(28 posts) Bio
|
Date
| Reply #8 on Sun 27 Jul 2003 12:11 AM (UTC) |
Message
| 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.." | Top |
|
Posted by
| Neves
USA (78 posts) Bio
|
Date
| Reply #9 on Sun 27 Jul 2003 05:32 AM (UTC) |
Message
| 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 | Top |
|
The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).
To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.
26,713 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top