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
Bremen
Novice


Joined: 26 Dec 2002
Posts: 33
Location: USA

PostPosted: Wed Apr 02, 2008 3:40 am   

Tricky (Multistate?) Pattern-Matching Trigger Help
 
I'm aiming to do some fancy multistate text tracking/additions/replacement, but I'm not sure how to go about it. Here's the text from the MUD:

{You lunge at * with *!|You stab at * with *!|You thrust * at *.}
[1] Your backstab * to *! [%d]
[1] Your backstab * to *! [%d]
[1] Your backstab * to *! [%d]
[1] Your backstab * to *! [%d]
[1] Your backstab * to *! [%d]

What I Want:
Based on the number of backstab hits (there will be between 1 and 5 lines as above), to be able to insert messages into that flow, such that if there are 5 hits, it would instead appear as:
NewIntroLine1
NewIntroLine2
[1] Your backstab * to *! [%d]
[1] Your backstab * to *! [%d]
SomeNiftyMessage
[1] Your backstab * to *! [%d]
[1] Your backstab * to *! [%d]
SomeOtherNiftyMessage
[1] Your backstab * to *! [%d]

Problems/trickiness (and why it probably needs to be multi-state):
In the original pattern, there's no guarantee that there will be no intervening lines. There shouldn't be any completely blank lines, but other messages can come between backstab hits, and there's no guarantee of a blank line immediately after all 5 hits (if all 5 occur). The original pattern could wind up like:

{You lunge at * with *!|You stab at * with *!|You thrust * at *.}
[1] Your backstab * to *! [%d]
<Some other random text>
<other crap>
[1] Your backstab * to *! [%d]
<Some other random text>
<other crap>

So I guess what I need is some way to count the number of occurrences of the pattern being matched (up to 5) and then (hopefully?) go back and insert lines of text (or simply gag everything and #say it afterward).

I guess the worst case is just doing it in parts, replace the intro lunge/stab/thrust line with my text, then a loop-pat-2 backstab state followed by text output, etc.
_________________
--Bremen, zMUD 7.21 on Windows 7 x64
Reply with quote
charneus
Wizard


Joined: 19 Jun 2005
Posts: 1876
Location: California

PostPosted: Wed Apr 02, 2008 4:37 am   
 
Why not the following? For the new intro lines, you'll either have to do both separately if you want two separate new intros, or do a condition within 1 param if you want it to be just one line.

By the way, to one of the intro lines, add this text:
bstat=0

As for backstab text, it might be easier to do it this way:

Trigger:
~[1~] Your backstab * ~ [%d~]
Action:
#ADD bstab 1
#IF (@bstab=2) {#SAY blah}
#IF (@bstab=4) {#SAY blah2}

Hope this helps some.

Charneus
Reply with quote
Bremen
Novice


Joined: 26 Dec 2002
Posts: 33
Location: USA

PostPosted: Wed Apr 02, 2008 5:23 am   
 
Yeah, I came up with something nearly-identical with a multi-state trigger instead of a variable, but my original hope was to be able to not output anything if the total # of lines (i.e. @bstab) was <4, including no intro messages. I guess that's not possible or at best would look jerky with a lot of #gag's and then outputting?
_________________
--Bremen, zMUD 7.21 on Windows 7 x64
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