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
Lincon
Newbie


Joined: 24 May 2019
Posts: 5

PostPosted: Fri Oct 04, 2019 7:19 am   

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 holiday postcards printing and mailing

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,


-Lincon
Reply with quote
shalimar
GURU


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

PostPosted: Fri Oct 04, 2019 3:19 pm   
 
minor syntax issue:
%pop is unique in not needing the variable to have the @ symbol attached, in most places you will need it.

This is the format you are looking for:

Code:
#TR {suddenly attacks ({@RescTargs})!} {}
#COND {*} {
  #CALL %match(%line, "bravely steps in front of (%w), shielding %w from harm!", $rescued)
  #IF ($rescued) {
    #IF (%ismember($rescued ,@ToRescue)) {} {ToRescue = %push($rescued, @ToRescue)}
    #if (@AutoRescue = 1) {resc %pop(ToRescue)
    #ECHO RESCING WHOEVER NOW
  }} {within|param=1}
_________________
Discord: Shalimar#3679
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