 |
Ron Marks Beginner
Joined: 17 Mar 2007 Posts: 20
|
Posted: Sat Mar 17, 2007 5:06 am
If statements |
I currently use the following alias script in a LP mud environment. I would like to translate it into a CMUD script if possible.
al drt get $arg1:bottle$ from bag;taste $arg1:bottle$;close $arg1:bottle$;put $arg1:bottle$ in bag
Once the alias is entered I can take a drink of potion from a bottle by typing drt. That would get my potion bottle from the bag, drink and replace bottle
If the potion was in a flask I would type drt flask and the same as above would occur.
Can this be done in the CMUD script? Sorry if this is obvious and I missed the applicable material in the help files.
Ron |
|
|
|
 |
Fang Xianfu GURU

Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Sat Mar 17, 2007 5:22 am |
I'm not sure precisely what you want it to do. If you want it to use "bottle" if you don't specify an argument and the argument if you do, you could try one of these:
The simple option:
#alias drt {#if (%1) {get %1 from bag;taste %1;close %1;put %1 in bag} {get bottle from bag;taste bottle;close bottle;put bottle in bag}}
The option where I don't want to type out that list of commands twice:
#alias drt {#local $container;#if (%1) {$container=%1} {$container="bottle"};get $container from bag;taste $container;close $container;put $container in bag} |
|
|
|
 |
Ron Marks Beginner
Joined: 17 Mar 2007 Posts: 20
|
Posted: Sat Mar 17, 2007 6:55 am |
This looks like what i am looking for. Thanks I'll give it a try. And yes I wanted to avoid typing bottle if I did't specify an argument. I'll also try to play with what you gave me to see if I can have a default bag or name one if i want.
|
|
|
|
 |
Fang Xianfu GURU

Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Sat Mar 17, 2007 6:58 am |
It's a lot easier to do with the second one than it is with the first (with the first you'd have to add another #if to both the false and true to check the bag). With the second one you just need to add another variable $bag to the #local declaration and then add another #if for %2 or whatever you want to do.
|
|
|
|
 |
|
|
|