|
Buba Newbie
Joined: 01 May 2002 Posts: 0
|
Posted: Fri Mar 29, 2002 8:40 pm
FORALL command |
Ive got a simple Forall command like:
#forall @targets {
cp @commod %proper( %i)
}
My problem is After this has run, which depending on Lag and how many targets you have set could take from 1 to 15 seconds...
After its completely done i want it to set off another alias...the problem is theres NO way to trigger the end of the FORALL command by the output of the MUD, and if you just put in the Alias after the forall command in the value, it triggers the alias as soon as it starts the FORALL command, Any way to combat this at ALL? Any help is appreciated. |
|
|
|
Humpton Apprentice
Joined: 10 Oct 2000 Posts: 158 Location: Chicago, IL
|
Posted: Fri Mar 29, 2002 8:43 pm |
I don't have the time to figure out the real answer, but how about...
In the #FORALL, have a counter that increments with each loop.
After the counter, have an #IF. If the counter is equal to the number of elements in @variable, do your next thing, if not don't do anything - and this will only fire once, and at the end of the #FORALL.
Good luck!
Stay JOLLY!
H
___
Humpton lives like he types.... fast, and full of mistakes!
Core 2651: For those who prefer the future to the past. |
|
|
|
Buba Newbie
Joined: 01 May 2002 Posts: 0
|
Posted: Fri Mar 29, 2002 8:49 pm |
this sounds like a decent method, adding 1 to a variable each time it goes thru the forall is not a big deal but how can i write something that finds out exactly how many elements there are in the @targets variable so that i can compare it to the incremented variable?
|
|
|
|
Buba Newbie
Joined: 01 May 2002 Posts: 0
|
Posted: Fri Mar 29, 2002 8:58 pm |
Nevermind FIgured it all out
|
|
|
|
Castaway GURU
Joined: 10 Oct 2000 Posts: 793 Location: Swindon, England
|
Posted: Fri Mar 29, 2002 8:58 pm |
%numitems(), for example
|
|
|
|
Troubadour GURU
Joined: 14 Oct 2000 Posts: 556 Location: USA
|
Posted: Fri Mar 29, 2002 9:04 pm |
The %numitems() function will return the number of items in a string list.
Does the command cp @commod %proper(%i) have an output that can be used in a pattern? If so, try something like this:
#AL cpall {
#VAR targnum 1
cp @commod %proper(%item(@targets, @targnum))
}
#TR {Pattern resulting from cp command.} {
#ADD targnum 1
#IF (@targnum <= %numitems(@targets)) {cp @commod %proper(%item(@targets, @targnum))} {Alias to be run when all done}
}
Troubadour |
|
|
|
LightBulb MASTER
Joined: 28 Nov 2000 Posts: 4817 Location: USA
|
Posted: Fri Mar 29, 2002 11:48 pm |
One possible method is to add a bogus command at the end, then trigger off the "Huh?" that most MUD's use for commands they don't recognize.
LightBulb
All scripts untested unless otherwise noted |
|
|
|
|
|