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
Rolly
Wanderer


Joined: 16 Oct 2006
Posts: 62

PostPosted: Fri Jan 26, 2007 12:31 am   

Capturing possible followers
 
Hi, here is a really simple one, I hope. I need the syntax to capture a name that may or may not be there. I built a trigger that will check every so often using the Entourage command for anyone following me in Achaea. Here is the trigger:

#Trigger {The following adventurers are in your entourage: (%w)}

{#SHOW "%1"
#Var Follower "%1"
#WAIT 60000
ent}

The trigger does not work because there is usually no name to capture.
I'm sure there is something that will work in place of (%w) so that if there is now one in my entourage it will still trigger the last two statements but i do not know what it is. Can someone please help? Thanks in advance.
Reply with quote
Fang Xianfu
GURU


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

PostPosted: Fri Jan 26, 2007 1:34 am   
 
One way of doing it would be with a reparse state:

#trig {The following adventurers are in your entourage:} {blah blah}
#cond {The following adventurers are in your entourage: (%w)} {blah blah} {reparse}

But since all you want it to do is check every minute and using #wait, especially for something like this, is a very bad idea, I suggest the alarm command.

#alarm **:**:00 {ent}
or
#alarm 60 {ent}

which is entirely separate to the trigger, which would be

#trig The following adventurers are in your entourage: (%w)} {blah blah}
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
gamma_ray
Magician


Joined: 17 Apr 2005
Posts: 496

PostPosted: Fri Jan 26, 2007 2:30 am   
 
The problem with that method is that if there are no followers, then the variable will -not- be set to empty, i.e. the variable will still think there are followers.

You can do a reparse in which the first state clears the variable and the second state sets it if there -are- followers.

Alterntively, you can use * instead of %w. %w matches any number of letter characters (i.e. a-z) so it wouldn't work completely correctly if you had several followers. * will catch anything, including "nothing", so it should always function in a reliable manner (for one line or less). Of course you take a performance hit but it's probably not -that- bad.

You might want to look at the Pattern Matching page in the ZMud help files, too, in your free time as it outlines all of the different pattern options. (Or just come join me on the dark side of RegEx...)
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