Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD General Discussion
Ron Marks
Beginner


Joined: 17 Mar 2007
Posts: 20

PostPosted: 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
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: 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}
Reply with quote
Ron Marks
Beginner


Joined: 17 Mar 2007
Posts: 20

PostPosted: 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.
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: 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.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD General Discussion All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© 2009 Zugg Software. Hosted by Wolfpaw.net