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: 174

PostPosted: Mon Mar 07, 2016 3:09 pm   

multistate trigger issues
 
#TR {-INGREDIENTS-} {#cond {1 {*}} {#ADDITEM mould %line} {LoopLines|Param=5}

this works as far as catpuring and adding to a string list variable, however it keeps reproducing the condition every time i fire the trigger.
How do i stop this from happened? do i need to add a #state 0 to the end of that condition?

As a further note, the addition of consequtive states makes the trigger add to the string list over and over, so if '1" is seen 3 times each time the trigger fires it will add 3x# of times... very spammmy and wrong.
Reply with quote
shalimar
GURU


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

PostPosted: Mon Mar 07, 2016 6:06 pm   
 
the issue is you but the condition in the script for the first trigger, it should be like this:

#TR {-INGREDIENTS-} {}
#cond {1} {#ADDITEM mould %line} {LoopLines|Param=5}
_________________
Discord: Shalimar#3679
Reply with quote
chris123zugg
Apprentice


Joined: 23 Aug 2013
Posts: 174

PostPosted: Mon Mar 07, 2016 6:25 pm   
 
well the #cond {1} needs to be 1 {*} due to the part after the 1 in the capture...
Reply with quote
shalimar
GURU


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

PostPosted: Mon Mar 07, 2016 6:59 pm   
 
I'm not seeing how that actually changes the pattern other then ensuring the space is needed as well.
{*} in a pattern would be an anonymous variable list with only one member, the wildcard for any number of any type of characters, including 0
_________________
Discord: Shalimar#3679
Reply with quote
chris123zugg
Apprentice


Joined: 23 Aug 2013
Posts: 174

PostPosted: Mon Mar 07, 2016 7:42 pm   
 
pattern -> -INGREDIENTS-

script -> #var mold ""
#cond {1 {*}} {#additem mould %line} {LoopLines|Param=5}


i need this to remain the way it is because the {*} wildcard captures within the 5 lines the items after the 1...
everything works except the aforementioned problem or multistate "states" reproducing and causing spam.


i will use the captured pattern from stringlist to make a auto grabber from a bag
Reply with quote
shalimar
GURU


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

PostPosted: Mon Mar 07, 2016 8:14 pm   
 
Yes, but that stuff doesn't need to be captured is my point.
The way you have it doesn't actually make your pattern more specific, other then the space.
The simpler pattern would do the same thing, especially given that you have no need for the information so captured.

#COND {1 {*}}
#COND {1}
#COND {1 (*)} {#additem mould %1} {LoopLines|Param=5}

All three of those would fire on the same line.
Only the third option would make a substring of %1 you could make use of in the trigger body.
I assume you don't actually need the '1' to appear in your stringlist?
_________________
Discord: Shalimar#3679
Reply with quote
chris123zugg
Apprentice


Joined: 23 Aug 2013
Posts: 174

PostPosted: Mon Mar 07, 2016 9:16 pm   
 
nope and it doesnt only the {*} portion gets captured in the string list, so is that why it keeps repopulating the state in the multistate trigger?
Reply with quote
shalimar
GURU


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

PostPosted: Mon Mar 07, 2016 9:54 pm   
 
because your trigger is issuing the #COND, instead of having a #COND statement immediately after the trigger definition

this is bad:
#TR {blah} {#COND {blah} {}}

This is good:
#TR {blah} {}
#COND {blah} {blah}
_________________
Discord: Shalimar#3679
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Mon Mar 07, 2016 10:44 pm   
 
My standard multi line capture trigger series looks like this:
#ONINPUT "commandCapture" {^SomeCommand$} {}
#COND {something that signifies start of capture} {Variable=%line;#STATE commandCapture 3} {duration|param=1000}
#COND {} {#STATE commandCapture 0;#ECHO SomeCommand failed.}
#COND {} {#IF (%begins(%line,"something that signifies end of capture")) {#STATE commandCapture 4;#SET commandCapture 4 1} { add more to Variable with %concat, #ADDITEM, or something else}} {looplines|param=100}
#COND {} {do some processing on Variable since capture is completed} {manual}

Multi-state triggers are a create once use many system. You should not be trying to create substates during the processing of a state. Feel free to copy the above into the command line and see what it makes then edit it for your needs.
_________________
The only good questions are the ones we have never answered before.
Search the Forums
Reply with quote
Daern
Sorcerer


Joined: 15 Apr 2011
Posts: 809

PostPosted: Tue Mar 08, 2016 12:49 am   
 
To clarify the above a bit: #cond is a command that CREATES a new state. The way you have it set up right now is basically equivalent to having a #trigger command inside another trigger - whenever that trigger fired, it would run the #trigger command and create a new trigger. Like Vijilante said, you really just want to create it once, then you never need to use #cond again. You can create it through the package manager directly (new -> trigger state), or on the command line by leaving the #cond on its own, outside the other trigger, as others have been suggesting.
Reply with quote
chris123zugg
Apprentice


Joined: 23 Aug 2013
Posts: 174

PostPosted: Wed Mar 09, 2016 5:12 pm   
 
Sorry for being dense guys, thank you both for the help i got the trigger to work.
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