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
chris123zugg
Apprentice


Joined: 23 Aug 2013
Posts: 175

PostPosted: Sat Jul 25, 2020 7:24 pm   

making a trigger
 
HP: 1971/1671 SP: 642/642 STS: 0/63% (V) (B) (P:A) Enemy: 93%

HP: 1971/1671 SP: 642/642 STS: 0/63% (V) (B) (P:A) (STS) Enemy: 93%

HP: 1971/1671 SP: 642/642 STS: 0/63% Enemy: 93%

Is there a way to make 1 trigger for all 3 of these? The (V) (B) (STS) show up as the skill; is used, so it disapears and i've had to make 3 different triggers to make sure i have variables going for hp's etc...
Reply with quote
shalimar
GURU


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

PostPosted: Sat Jul 25, 2020 9:07 pm   
 
Anonymous variables with a null member are your friend:

#TR {HP: (%d)/(%d) SP: (%d)/(%d) STS: (%d)/(%d)% ({~(V~) |})({~(B~) |})({~(P:A~) |})({~(STS~) |}) Enemy: (%d)%} {stuff}
_________________
Discord: Shalimarwildcat
Reply with quote
chris123zugg
Apprentice


Joined: 23 Aug 2013
Posts: 175

PostPosted: Sun Jul 26, 2020 12:17 pm   
 
It didn't work, not sure why, i do see what you mean by anonymous variables however...

({blah|blah|blah|blah})
Reply with quote
chris123zugg
Apprentice


Joined: 23 Aug 2013
Posts: 175

PostPosted: Sun Jul 26, 2020 5:39 pm   
 
Also: how would i create a trigger (multi-state?) to capture sequential instances of same pattern, and record them seperately?

CS: Vr: 3043 Tl: 1891

CS~:%s~[~[(*)~]~]

(multi-state)---> within lines

(%w)~:%s(%d) <---- but it only captures the first one in the capture, and i need to capture all instances, and then record them seperatly

vr: 3043 AND Tl: 1891 so i can call them up as they reach a certain point....


i sort of got this to work with clicking the within line portion in trigger, however "loop lines" is picking up stuff from other lines i dont want....isn't there a way to set #cond for it to expand to state 1 etc and then close? i dont remember all this
Reply with quote
hpoonis2010
Adept


Joined: 18 Jun 2019
Posts: 279

PostPosted: Sun Jul 26, 2020 8:07 pm   
 
As with the documentation, you are supposed to be able to use a temporary trigger. However, I have had nothing but trouble with temporary triggers from day one.

In theory, the primary trigger should have a #TEMP {pattern} {commands;#STATE <state>}, and the condition would reset the state upon firing.

But all I seem to get is that the temporary trigger makes a permanent version of the pattern and commands...for as many times as it fires. Shalimar suggested naming TEMP triggers but that has had mixed results for me. Only 10 mins ago I had to delete 20 triggers that were made by a temp one, even though it was named.
Reply with quote
chris123zugg
Apprentice


Joined: 23 Aug 2013
Posts: 175

PostPosted: Sun Jul 26, 2020 8:44 pm   
 
yup, im having the same issues.... it will endlessly produce the "state" as a new multi-state each time it finds that pattern... i just need a way to as many times as i need to find that pattern AFTER the original pattern is seen, then stop looking for it. i guess i could use several triggers to #T+ and #T- but that would absurd as i need the variables to update each round..:|
Reply with quote
shalimar
GURU


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

PostPosted: Mon Jul 27, 2020 6:04 pm   
 
#TEMP triggers are rarely #STATE based triggers.
Do not conflate the two.

#TR {pattern one} {do stuff} //this is #STATE 0
#COND {pattern two} {do more stuff} //this is #STATE 1
#COND {pattern three} {etcetera} //this is #STATE 2

The #STATE command is used within a #TRIGGER, to change which #STATE is currently active and waiting to fire.
Triggers usually only progress in a state when it fires, though trigger options can change this behavior.

Here is an example I use to get rid of server-side word-wrapping in my tells:

Code:
#TR {^%w {tell|ask}{s|} %w{ |}:} {#CAP Tells}
#COND {^    %s    (*)} {
  #EXECWIN Tells {#SAYADD { %trim(%1)}}
  #STATE 1
  } {within|param=1}


The within option tells CMUD that this trigger state is only active for x amount of lines, where x=param


Also going back to anonymous variables:
You left out the null member:

({blah|blah|blah|blah})

Has 4 members.

({blah|blah|blah|blah|})

Has 5

You need that null member to make parts of your pattern optional.
_________________
Discord: Shalimarwildcat
Reply with quote
chris123zugg
Apprentice


Joined: 23 Aug 2013
Posts: 175

PostPosted: Wed Jul 29, 2020 6:44 pm   
 
Code:
CS: [[ Vr: 2197 Tl: 3679 Bf: 3632 ]]
is an example, and as i stated it can be 1 set of those or up to 7.... this one has 3

this is the script i made... that doesnt work, and am hoping you can help me write so it does work..

Code:
CS~:%s~[~[%s({(%w)%s(%d)|(%w)%s(%d)|(%w)%s(%d)|})%s~]~]
Reply with quote
shalimar
GURU


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

PostPosted: Wed Jul 29, 2020 8:27 pm   
 
It might be easier to just reparse the contents of that double bracket via script:

Code:
#TR {CS: ~[~[(*)~]~]} {
  #LOCAL $vr $tl $bf $etc
  #CALL %match(%1, "Vr: (%d)", $vr)
  #CALL %match(%1, "Tl: (%d)", $tl)
  #CALL %match(%1, "Bf: (%d)", $bf)
  }
_________________
Discord: Shalimarwildcat
Reply with quote
chris123zugg
Apprentice


Joined: 23 Aug 2013
Posts: 175

PostPosted: Wed Jul 29, 2020 10:27 pm   
 
that didnt #call anything up btw, and i tested with #print as well...

#IF %match(%1, "Vr: (%d)") {}

and your example, how do i capture the %d inside the match?!
Reply with quote
shalimar
GURU


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

PostPosted: Wed Jul 29, 2020 11:51 pm   
 
Well you did not fully copy my %match function:

%match(%1, "Vr: (%d)", $vr)

all the #CALL does is evaluate the function, which in turn assigns the value %d to the variable $vr
_________________
Discord: Shalimarwildcat
Reply with quote
chris123zugg
Apprentice


Joined: 23 Aug 2013
Posts: 175

PostPosted: Sun Aug 02, 2020 8:15 pm   
 
shalimar wrote:
#TEMP triggers are rarely #STATE based triggers.
Do not conflate the two.

#TR {pattern one} {do stuff} //this is #STATE 0
#COND {pattern two} {do more stuff} //this is #STATE 1
#COND {pattern three} {etcetera} //this is #STATE 2

The #STATE command is used within a #TRIGGER, to change which #STATE is currently active and waiting to fire.
Triggers usually only progress in a state when it fires, though trigger options can change this behavior.

Here is an example I use to get rid of server-side word-wrapping in my tells:

Code:
#TR {^%w {tell|ask}{s|} %w{ |}:} {#CAP Tells}
#COND {^    %s    (*)} {
  #EXECWIN Tells {#SAYADD { %trim(%1)}}
  #STATE 1
  } {within|param=1}


The within option tells CMUD that this trigger state is only active for x amount of lines, where x=param


Also going back to anonymous variables:
You left out the null member:

({blah|blah|blah|blah})

Has 4 members.

({blah|blah|blah|blah|})

Has 5

You need that null member to make parts of your pattern optional.



Is it possible to just make 1 item "optional"?

CS: <blank space> but can sometimes be CS: Vr: 1234
so could i do this: CS~:({~[~[(*)~]~]|}) so pattern capture will work if its there or not?
Reply with quote
chaossdragon
Apprentice


Joined: 09 Apr 2008
Posts: 167

PostPosted: Sun Aug 02, 2020 9:45 pm   
 
I know you can do that with REGEX but not sure how it's done via zscript

CS: (?:|Vr:\s\d+)

will capture with or without the Vr: 1234 ... but assigning it as a variable if detected would mess with things

You would have to have some method of checking IF (%1 == Vr: %d) THEN {do blah} ELSE {shift %1 to next item and do blah}
Reply with quote
shalimar
GURU


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

PostPosted: Mon Aug 03, 2020 3:12 am   
 
Yes, that should work.
_________________
Discord: Shalimarwildcat
Reply with quote
rockvid
Newbie


Joined: 06 Oct 2021
Posts: 1

PostPosted: Wed Oct 06, 2021 8:17 am   
 
the primary trigger should have a #TEMP {pattern} {commands;#STATE <state>}, and the condition would reset the state upon firing.
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