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

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD General Discussion
Klion
Newbie


Joined: 12 Nov 2013
Posts: 2

PostPosted: Tue Nov 12, 2013 11:58 pm   

Waitfor/cond, only backwards
 
Trying to make a trigger which does something UNLESS it sees a (certain) line immediately after it. Right now I am using #waitfor, but the line in question would always be immediately after the trigger's pattern. Initially i tried to do it with condition, but I couldn't find a syntax to make it work for the logic I want. within|param= seemed close, but i could only execute the command if the second pattern was found, I need it to go off if the second pattern is NOT found

Basically

if (pattern 1 is found)
{
if (pattern 2 is right after pattern1)
{nothing}
else {command}

This is how I did it with waitfor, but I do not like using waitfor when its always the next line, and I am certain there is a better way.

<trigger priority="1060" id="106">
<pattern>*suddenly attacks ({@RescTargs})!</pattern>
<value>#Waitfor {(%w) bravely steps in front of (%1), shielding him from harm!}
90 {}
{
#IF (%ismember(%1,ToRescue)) {} {ToRescue = %push(%1,ToRescue)}
#if (@AutoRescue = 1) {resc %pop(ToRescue)
#ECHO RESCING WHOEVER NOW
}

}
</value>
</trigger>

Thanks for any tips,


-Kli
Reply with quote
Daern
Sorcerer


Joined: 15 Apr 2011
Posts: 809

PostPosted: Wed Nov 13, 2013 12:45 am   
 
Use a second state within 1 line like you said, but make the pattern ^(*)$ to capture the next line whatever it is, then check if it matches whatever you want in the code.
Reply with quote
Klion
Newbie


Joined: 12 Nov 2013
Posts: 2

PostPosted: Wed Nov 13, 2013 1:15 am   
 
Hrm, thats a good idea but the next line would be ^(%w) bravely steps in front of (%1), shielding him from harm!$

so I'd have to do a bit of work to break the string down in various ways to see if it matches since the variable portions will change, which i think is kind of a pain. Is there really no simpler method available? :/
Reply with quote
Daern
Sorcerer


Joined: 15 Apr 2011
Posts: 809

PostPosted: Wed Nov 13, 2013 3:30 am   
 
This should do it:

Code:
#if (!%match(%1, %concat("^(%w) bravely steps in front of (", %t1, "), shielding him from harm!$"), $player)) {
  #IF (!%ismember(%t1,ToRescue)) {ToRescue = %push(%t1,ToRescue)}
  #if (@AutoRescue = 1) {
    resc %pop(ToRescue)
    #ECHO RESCING WHOEVER NOW
  }
}
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD 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