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


Joined: 27 Feb 2003
Posts: 69
Location: Australia

PostPosted: Tue Jun 01, 2004 6:47 am   

Triggering multiple times in a line
 
Is there a way to get a trigger to fire multiple times on the same line, wherever the trigger pattern appears?

i.e. I want a trigger, when fired, to remain active and not wait till the EOL before becoming active again.

Any ideas?

Thanks,
Reply with quote
Serentus
Apprentice


Joined: 28 Sep 2001
Posts: 103
Location: USA

PostPosted: Tue Jun 01, 2004 11:15 am   
 
You may be able to use a reparse state trigger.
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4769
Location: Pensacola, FL, USA

PostPosted: Tue Jun 01, 2004 11:55 am   
 
have you tried #TR {pattern} {#LOOP 5 {do stuff}}
Reply with quote
Cbisazza
Wanderer


Joined: 27 Feb 2003
Posts: 69
Location: Australia

PostPosted: Tue Jun 01, 2004 12:57 pm   
 
no, reparse triggers don't work that way.

Reparse triggers will always match the first occurrence of the string in a line as they perform a 'standard' match each time they parse - just like other triggers. They are useful if you want to extract several items of information from a single line, some of which may or may not be present.

To use a simple example, Given a line from the MUD like:

You see a treasure chest, a treasure chest and a treasure chest.

I would like a trigger that matches all three instances of "Treasure chest" in the line.
Reply with quote
Cbisazza
Wanderer


Joined: 27 Feb 2003
Posts: 69
Location: Australia

PostPosted: Tue Jun 01, 2004 2:21 pm   
 
The Loop pattern trigger works for #CW, which got me all interested - It will set the color of strings for as many times as they appear.

It does not work for anything else, however. I cannot set a variable or match any part of the line (as I would like to be able to do). This will just work for the first match, as with any normal trigger.

Following further investigation, I believe that the effect noticed with the #CW is an attribute of #CW rather than an indication of the trigger having matched several times.
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Tue Jun 01, 2004 5:03 pm   
 
With a few exceptions, triggers only fire once per line/block.

To the best of my knowledge, those exceptions are
#CW
#SUBSTITUTE
Reply with quote
Cbisazza
Wanderer


Joined: 27 Feb 2003
Posts: 69
Location: Australia

PostPosted: Wed Jun 02, 2004 2:18 pm   
 
Yup, That's my impression too.

However, given that the matching now uses a PERL pattern matching core I'm kinda hoping that there is some option to simply keep on matching.

I guess not.
Reply with quote
Insomniac
Wanderer


Joined: 25 Mar 2004
Posts: 78
Location: United Kingdom

PostPosted: Fri Jun 04, 2004 5:14 am   
 
What exactly are you trying to achieve Cbisazza?

Might be able to come up with a workaround!
Reply with quote
user0101
Apprentice


Joined: 01 Aug 2003
Posts: 100
Location: USA

PostPosted: Fri Jun 04, 2004 5:35 am   
 
quote:
You see a treasure chest, a treasure chest and a treasure chest.

Use multiple named triggers with similar patterns if you want to fire off that string.
Reply with quote
Cbisazza
Wanderer


Joined: 27 Feb 2003
Posts: 69
Location: Australia

PostPosted: Fri Jun 04, 2004 11:08 am   
 
Insomniac,

What I'm trying to do is actually a bit broader than this, but triggering multiple times on a line was a requirement for anything to work.

I was trying to figure out an easy way to sort the output of the 'health' command in DR for processing. This command outputs stats for all body parts in one line. There are a number of different severity levels, but you can essentially have the same severity level repeated on a number of different body parts. An example of this would be:

You have severe scarring and chunks of flesh missing from the right arm, an occasional twitching in the left arm, some tiny scars across the right leg, a few nearly invisible scars along the left leg, severe scarring and chunks of flesh missing from the right hand, an occasional twitching in the left hand, an occasional twitching in the chest area, an occasional twitching in the abdomen, some tiny scratches to the back.

I was hoping to use a trigger like:

#TRIGGER {({@{Wound_severity}}) ({@{Body_part}})} {..processing..}

Of course, such a trigger would have to fire SEVERAL times on the same line.

The next best scenario would utilize around 48 triggers to do the same thing (4 triggers per body part) - hence the motivation to be able to do this in one trigger.
Reply with quote
mr_kent
Enchanter


Joined: 10 Oct 2000
Posts: 698

PostPosted: Fri Jun 04, 2004 2:56 pm   
 
Store that whole mess in a variable and parse it out to what you need.

You should only need one trigger per body part...
#TRIGGER {&Left_Arm_Wound_severity left arm} ... unless body parts appear twice.

Something like that... Can't test syntax atm.
Reply with quote
nexela
Wizard


Joined: 15 Jan 2002
Posts: 1644
Location: USA

PostPosted: Fri Jun 04, 2004 3:32 pm   
 
Here might be something to get you started basicly just throws it all in a string list If I got time I will work on it somemore ang get it to more like you need it. but if the output has all the same bodyparts shown all the time the easisest way would be something like what mr_kent is saying

#TRIGGER {^You Have (*).} {#loop %numwords("%1",", ") {#ADDI wounds %word("%1",%i,", ")}}
Reply with quote
Insomniac
Wanderer


Joined: 25 Mar 2004
Posts: 78
Location: United Kingdom

PostPosted: Fri Jun 04, 2004 8:29 pm   
 
As usual, Nexela came up with a great way to extract what you needed.

I'm not sure how it works at all in DR (DragonRealms?) but I'm assuming you want to 'heal' the wounds somehow? Perhaps you play a healer style character, or simply just use herbs/salves/potions to heal your character.

What I'm trying to say is, explain what you are trying to achieve fully and maybe we can tell you the best method as well as figure out the triggers and what not for you :)
Reply with quote
Cbisazza
Wanderer


Joined: 27 Feb 2003
Posts: 69
Location: Australia

PostPosted: Sat Jun 05, 2004 4:13 pm   
 
Yes, it is possible to create a string list with all the information. Personally, I generally use %replace() on the string to change ", " to "|".

The problem is that once I end up with a string list, processing it becomes difficult. with zMUD I cannot extract information from string lists with the ease with which I can using triggers. I know it's possible - it's just not that flexible.

At the same time, I can create the triggers I need with 3 lines of code ... so it's really not that bad. I'm just not really comfortable with it because it's not elegant - which is why I was trying to find another way of doing it.

To answer the other questions:-

Mr Kent - you need 4 triggers per body part - the max number of times the same part can appear in a line.

Insomniac - As I stated in the last mail, I'm trying to extract wound/body part pairs for processing. When I have that info, I can prioritize the wounds and do whatever is necessary to heal myself. The problem is just the extraction of information, where I want to reduce the number of active triggers (not that it makes any real difference ... but I prefer it that way).
Reply with quote
nexela
Wizard


Joined: 15 Jan 2002
Posts: 1644
Location: USA

PostPosted: Sun Jun 06, 2004 7:29 am   
 
quote:
Yes, it is possible to create a string list with all the information. Personally, I generally use %replace() on the string to change ", " to "|".

*Whap* %replace completely slipped my mind :P
Reply with quote
Insomniac
Wanderer


Joined: 25 Mar 2004
Posts: 78
Location: United Kingdom

PostPosted: Sun Jun 06, 2004 1:01 pm   
 
quote:
Originally posted by CbisazzaInsomniac - As I stated in the last mail, I'm trying to extract wound/body part pairs for processing. When I have that info, I can prioritize the wounds and do whatever is necessary to heal myself. The problem is just the extraction of information, where I want to reduce the number of active triggers (not that it makes any real difference ... but I prefer it that way).



Thanks for that, totally understand now.
Reply with quote
Cbisazza
Wanderer


Joined: 27 Feb 2003
Posts: 69
Location: Australia

PostPosted: Sun Jun 06, 2004 2:10 pm   
 
Glad we're in sync.

Thanks for your help, and sorry for not having been clear enough from the start.
Reply with quote
davidnmilby
Newbie


Joined: 09 Jan 2003
Posts: 1
Location: USA

PostPosted: Mon Jun 07, 2004 9:57 pm   
 
have you tried using the regex function?

e.g.
(assuming your trigger matches ^You have (.*))

#FORALL %replace("%1",", ","|") {
#NOOP %regex(%i,"^(.*) (?:along|across|to|in|from) the (.*)$",Damage,Part)
#SHOW @Part --> @Damage
}


result:

right arm --> severe scarring and chunks of flesh missing
left arm --> an occasional twitching
right leg --> some tiny scars
left leg --> a few nearly invisible scars
right hand --> severe scarring and chunks of flesh missing
left hand --> an occasional twitching
chest area --> an occasional twitching
abdomen --> an occasional twitching
back --> some tiny scratches
Reply with quote
Cbisazza
Wanderer


Joined: 27 Feb 2003
Posts: 69
Location: Australia

PostPosted: Tue Jun 08, 2004 5:33 am   
 
Never used regex, but it looks simple enough. I'll definately look into it.

Thanks!
Reply with quote
Xphere
Beginner


Joined: 08 Jun 2004
Posts: 26
Location: USA

PostPosted: Tue Jun 08, 2004 6:57 am   
 
also another idea that would possibly work, tho i havent tried it, is to try a loopline in a multi-state.. i dont know if this is going to work cause im really damn tired, but im taking a break from trying to figure out my trigger problems, but hey it at least will give you another angle to look at.

you will need to fill in some blanks, state 2 of the trigger should assign values to the variables for the body parts i dunno like something like, 1-4 for condition. and then you could prbbly have state 2 #GAG them too, so you can reduce spam, and put that info in your status bar or a button or a cppig or something. I realize it has some holes, but hey i cant afford to spend more then 15 mins on it here. I dunno, i could just be smokin something real good, if soo just ignore this all ;)

--------------------------------
#CLASS {ZuggSoft Support}
#VAR severe {You have severe scarring and chunks of flesh missing}
#VAR occasional {You have an occasional twitching}
#VAR tiny {You have some tiny scars}
#VAR few {You have a few nearly invisible scars}
#VAR YourScrewed {}
#VAR PrettyBad {}
#VAR NotTooBad {}
#VAR StopCrying {}
#VAR rightarm {}
#VAR leftarm {}
#VAR rightleg {}
#VAR leftleg {}
#VAR chest {}
#VAR abdomen {}
#VAR righthand {}
#VAR lefthand {}
#VAR back {}
#VAR fewshort {few nearly invisible scars}
#VAR occasionalshort {an occasional twitching}
#VAR severeshort {severe scarring and chunks of flesh missing}
#VAR tinyshort {some tiny scars}
#TRIGGER "healthstatus" {You have} {#IF ((%line =(@severe|@occasional|@tiny|@few))) {#SET healthstatus 2 1} {}}
#COND {} {#IF ((%line =(@severeshort|@tinyshort|@occasionalshort|@fewshort) + " " + ("from the"|"in the"|"to the"|"along the"|"across the") + (%w %w","))) {} {#SET healthstatus 3 1}} {looplines|param=5}
#COND {} {#STATE healthstatus 0} {manual}
#CLASS 0
----------------------------

wow thats kinda a mess.

well back to my dilemma, hope this helps some how,, if all else fails print it and throw it at your computer.
Reply with quote
Xphere
Beginner


Joined: 08 Jun 2004
Posts: 26
Location: USA

PostPosted: Tue Jun 08, 2004 7:09 am   
 
ug just thought of something, you could prbbly slam in a regex to match the body part easier in the second state.. ug, maybe i should go to sleep
Reply with quote
Cbisazza
Wanderer


Joined: 27 Feb 2003
Posts: 69
Location: Australia

PostPosted: Wed Jun 09, 2004 2:28 pm   
 
The LoopLines condition only matches lines that follow the original trigger line.

A simple trigger with regex was the answer. Read davidnmilby's post, it worked really well.
Reply with quote
Xphere
Beginner


Joined: 08 Jun 2004
Posts: 26
Location: USA

PostPosted: Wed Jun 09, 2004 5:06 pm   
 
ah good point... yeah regex does some nifty stuff.. i have to get more used to useing 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