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

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » zMUD General Discussion
Buba
Newbie


Joined: 01 May 2002
Posts: 0

PostPosted: 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.
Reply with quote
Humpton
Apprentice


Joined: 10 Oct 2000
Posts: 158
Location: Chicago, IL

PostPosted: 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.
Reply with quote
Buba
Newbie


Joined: 01 May 2002
Posts: 0

PostPosted: 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?
Reply with quote
Buba
Newbie


Joined: 01 May 2002
Posts: 0

PostPosted: Fri Mar 29, 2002 8:58 pm   
 
Nevermind FIgured it all out
Reply with quote
Castaway
GURU


Joined: 10 Oct 2000
Posts: 793
Location: Swindon, England

PostPosted: Fri Mar 29, 2002 8:58 pm   
 
%numitems(), for example
Reply with quote
Troubadour
GURU


Joined: 14 Oct 2000
Posts: 556
Location: USA

PostPosted: 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
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: 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
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » zMUD 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