|
Yasden Beginner
Joined: 19 Mar 2005 Posts: 17 Location: TorilMUD
|
Posted: Sat Mar 19, 2005 6:37 am
Problem with a variable list! |
Hi all! Newly registered user to this forum. Have been using zMUD for years, but only recently took up scripting.
Not being fluent in programming, the help files are a little sketchy on what I'm trying to accomplish.
I have a rescue script, and am attempting to create the list variable in %proper format.
For example, the output (#say form) reads (after inputting alias):
Rescue List: Target1 target2 target3 etc
I managed to get %proper to work on the first item in the list, but not the rest of the items stored within that variable. I assume there's a %loop function, but not sure how to go about doing such.
I would also like this input alias to allow multiple entries in one shot, instead of having to enter each individual entry. (Like "radd target1 target2 target3" etc instead of "radd target1", "radd target2" etc).
I'm not on my home machine right now so I can't post the alias code on here.
Thanks for the help in advance! |
|
|
|
Vijilante SubAdmin
Joined: 18 Nov 2001 Posts: 5182
|
Posted: Sat Mar 19, 2005 7:06 am |
First lets start with the help. The contents are a good place to go. Since you are looking for a specific command or function you would want to look in the Reference section. If you pop open the Commands List subsection you will see a section name Loop Structures; or you could pop open the Functions List subsection and find a subsection for Lists. Both of which will point you in the right direction. Also you can check out the Command Reference and Function Reference pages to see each one with a description of what it does. While I never reccommend someone new to zMud skipping the Getting Started section, you aren't new. However in the Getting Started section there is a subsection on scripting that provides overviews of the various types of settings. If you haven't read through that yet you should before jumping into the Reference area.
Now to fix the existing list assuming it is stored in the variable "Rescue":
#VARIABLE Rescue2 {}
#FORALL @Rescue {#ADDITEM Rescue2 {%proper(%i)}}
#VARIABLE Rescue {@Rescue2}
#UNVAR Rescue2
and the alias:
#ALIAS radd {#LOOP %numparam {#ADDITEM Rescue {%proper(%param(%i))}};#NOOP} |
|
_________________ The only good questions are the ones we have never answered before.
Search the Forums |
|
|
|
Yasden Beginner
Joined: 19 Mar 2005 Posts: 17 Location: TorilMUD
|
Posted: Sat Mar 19, 2005 9:12 pm |
Thanks a ton for the fast reply! Didn't need the Rescue2 setup, as I have another alias that clears out the contents of the RescueList variable (it changes daily, if not more often).
I've got other things I'd like to add into this script as well, but I don't want to spam the boards with every little detail. Look me up if you're interested in helping out! |
|
|
|
Yasden Beginner
Joined: 19 Mar 2005 Posts: 17 Location: TorilMUD
|
Posted: Sun Mar 20, 2005 2:18 am |
Actually, just came across another problem. Having implemented this new alias, my alias for removing people from the list has been botched. Correctional step taken was to copy the guts of the prior alias, substituting %delitem for %additem. However, on the #say output, it's adding extra text.
Example:
Rescue List: Bob|Jim|Joe
"rrem joe"
Rescue List: Bob|Jim joe
The command is working fine other than that.
#ALIAS rrem {#loop %numparam {#delitem RescueList {%proper(%param(%i))}};#noop;#say Current Rescue List: @RescueList} "Rescue"
Is the alias used. Any suggestions?
Thanks again! |
|
|
|
Vijilante SubAdmin
Joined: 18 Nov 2001 Posts: 5182
|
Posted: Sun Mar 20, 2005 6:42 pm |
The #SAY line just needs to be before the #NOOP line. Look at the help for %numparam.
|
|
_________________ The only good questions are the ones we have never answered before.
Search the Forums |
|
|
|
|
|