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
Turbomudder
Beginner


Joined: 25 Jan 2003
Posts: 19

PostPosted: Sat Jan 25, 2003 2:39 am   

trigger on multiple lines of output
 
I am using version 5.55 btw...
I need to have a trigger that can go off even if the first part of the pattern is recieved in one line and the second part in the next. is this possible? how can it be done?
Thank you very much
Turbomudder
Reply with quote
Turbomudder
Beginner


Joined: 25 Jan 2003
Posts: 19

PostPosted: Sat Jan 25, 2003 3:28 am   
 
I appologize, I should have been much more specific...
I'm trying to get a trigger that will capture the herbs that are in this basket...

The herb basket (open) contains: three small green berries, two pink pretty flowers, a strange green plant, two irregular green fruits, three small black roots, and a tiny red berry.

So i want to do a trigger like {a|an|two|three} (*){,|.}
in a class that is turned on by a trigger on "The herb basket (open) contains:"

but very often the {a|an} part comes on one line and the herb{,|.} part comes on the next (or the break might be in between the small and the green in "small green berry"... etc

thanks for any help,
Turbomudder
Reply with quote
Kjata
GURU


Joined: 10 Oct 2000
Posts: 4379
Location: USA

PostPosted: Sat Jan 25, 2003 10:55 pm   
 
I'm going to provide a trigger that works with version 6.40. You should try it out because it really is so much better. However, if for some reason, you are absolutely convinced that you do not want to use 6.40, then there are ways to do it in 5.55 too. The trigger for 6.40 is:
#TRIGGER "grabherbs" {The herb basket*contains: (*)} {#IF (!%ends("%1", ".")) {#STATE grabherbs 1}} "" {manual}
#COND {(*)} {#IF (%ends("%1", ".")) {#STATE grabherbs 0}} {manual}

Just put what you want to do witht the matched text (stored in %1) before the #IF's. You should probably add it all to a variable and then do something with the variable in the part of the #IF in the second state where it executes "#STATE grabherbs 0".

Kjata
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Sat Jan 25, 2003 11:08 pm   
 
The first thing I'd recommend is to make sure you don't just have a long line that zMUD wrapped. This will show you how long the actual line is:
#CW {^The herb basket*contains:*} {blink,red}
If it's all one line, you can just use a one-line trigger. (I'd delete the #CW trigger after a few tests)
#TR {^The herb basket*contains: (*).} {#VAR HerbBasketContents {%1}}

If it's on multiple lines,
#TR {^The herb basket*contains: (*)} {#VAR HerbBasketContents {%1};#IF %ends("%1", ".") {} {#T+ HerbBasket}}
#TR {^(*)$} {#VAR HerbBasketContents {@HerbBasketContents %1};#IF %ends("%1", ".") {#T- HerbBasket}} {HerbBasket}

As Kjata said, there's much to be gained by upgrading.

LightBulb
Senior Member
Reply with quote
Turbomudder
Beginner


Joined: 25 Jan 2003
Posts: 19

PostPosted: Sun Jan 26, 2003 12:11 am   
 
Thanks guys, the ^(*)$ thing is key...
as far as upgrading, there are some things that sound great like state functions. I use the trigger, alias, mapping, variable, programming capabilities of zmud extencively and I really would like to use the better version. the thing is I rely on it so heavily, that i would be devestated if i lost or had to reprogram any of my bots. So thats why I dont switch, im worried that some of the things I already rely on wont work..
thanks again
Turbomudder
Reply with quote
Kjata
GURU


Joined: 10 Oct 2000
Posts: 4379
Location: USA

PostPosted: Sun Jan 26, 2003 12:45 am   
 
That's what backups are for. Back up all of your scripts and then upgrade. If things don't work out, you can revert to the previous version. Also, Zugg has never removed functionality in any upgrade, so all of your scripts should work with no problems.

Kjata
Reply with quote
Turbomudder
Beginner


Joined: 25 Jan 2003
Posts: 19

PostPosted: Sun Jan 26, 2003 1:31 am   
 
Okay now ive got a further delemma with this... it seems a trigger will only fire once per line.
Im trying to get a variable that ends up like this :
"strange green plants|tiny red berries|small green leaves|yellow barks"
so if more than one item comes in on the same line, I need the trigger to fire again. if I could do that id use something like:
{a|an|two|three} (*), and the comma would make it pick up whatever words were between the number and the ,
then I would do like:
#ADDITEM herblist %1

thanks,
turbomudder
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Sun Jan 26, 2003 2:00 am   
 
It's probably easier to put everything into one variable to start with, then parse the variable to get individual items to add.
VAR HerbBasketContents {%replace( {@HerbBasketContents }, " and ", " ")}
VAR HerbBasketContents {%replace( {@HerbBasketContents }, " an ", " ")}
VAR HerbBasketContents {%replace( {@HerbBasketContents }, " a ", " ")}
VAR HerbBasketContents {%replace( {@HerbBasketContents }, " two ", " ")}
VAR HerbBasketContents {%replace( {@HerbBasketContents }, " three ", " ")}
#LOOP 1,%numwords( {@HerbBasketContents}, ", ") {#ADDITEM HerbList {%word( {@HerbBasketContents}, %i, ", ")}}

LightBulb
Senior Member
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