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
chamenas
Wizard


Joined: 26 Mar 2008
Posts: 1547

PostPosted: Sat Feb 19, 2011 4:25 pm   

Feature Request: Trigger Timeout Option
 
As I've made scripts, I've run into a lot of situations where I want to turn on a trigger for a short time to capture a line of text. If the line of text doesn't appear, then I want the trigger to shut off. Currently, the only way I've been able to manage this is with two triggers. Trigger 1 captures the pattern I'm looking for, runs what it needs to and then shuts itself off. Trigger 2 is an alarm trigger which is turned on in conjunction with Trigger 1 solely for the purpose of turning off Trigger 1 after a certain amount of time if Trigger 1 doesn't already turn itself off.

What I would like is a way to simple have a "Timeout" option on Triggers which would cause them to turn themselves off after X seconds if they haven't already fired. It's mostly a convenience issue, but also reduces some of the clutter of excess triggers and makes the process a whole lot more elegant than it currently is.

If you really wanted to be fancy, you could include a separate box of scripting or what have you for if a Timeout occurs as opposed to it firing on the pattern, but this might be a bit complicated and I could understand wanting us to simply use two triggers in this scenario. Alternatively, you could even do something like make a predefined %timeout variable which tells you if a timeout has been fired and then have a separate sub-option of the Timeout which would be "Fire Trigger on Timeout" thus users could check to see if a Timeout had fired it (and thus not the pattern) and run a script within the trigger, in the normal pattern box, for the event of it timing out.
_________________
Listen to my Guitar - If you like it, listen to more
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Sat Feb 19, 2011 6:41 pm   
 
Perhaps you are looking for the Duration trigger type? Have your first trigger state fire on whatever text or command you want for activating the potential capture, and have the substate be of type Duration.
Reply with quote
chamenas
Wizard


Joined: 26 Mar 2008
Posts: 1547

PostPosted: Sat Feb 19, 2011 7:10 pm   
 
I never noticed it disable the trigger with the Duration option, how does it effectively operate?
_________________
Listen to my Guitar - If you like it, listen to more
Reply with quote
Moo
Apprentice


Joined: 10 Apr 2009
Posts: 145

PostPosted: Sat Feb 19, 2011 7:44 pm   
 
How about something like.. Make a multistate trigger, the first state does nothing and the second state is your actual trigger. Set the second state as type "duration". Then instead of activating the trigger, use #state to change it to the second state. You'd probably need to use #state to change it back, too, if you only want it to match once.
It seems that a "missing" trigger type is "Within Time"...

[edit] I was beaten to it while writing my post.
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Sat Feb 19, 2011 7:57 pm   
 
A Duration type trigger state will remain active only for the specified amount of time, and then it will automatically go to the next state (or the first state, if the Duration state is the last). It is exactly designed for what you suggested. It is used as a substate. So, you just have your first state to trigger on whatever it is you want to "turn on" the Duration state.
Reply with quote
Tech
GURU


Joined: 18 Oct 2000
Posts: 2733
Location: Atlanta, USA

PostPosted: Sat Feb 19, 2011 8:07 pm   
 
I think you could also just use #WAITFOR in your first trigger state, since that also has a timeout if memory serves correctly.
_________________
Asati di tempari!
Reply with quote
Ralph1971
Wanderer


Joined: 01 Mar 2008
Posts: 64

PostPosted: Sun Feb 20, 2011 3:48 am   
 
so how would that be scripted?
like.. I want to cast a spell, and 1 of three things happen.. 1. successful message, 2. you failed, 3. no message. What I need to happen, is on successful message, cast a spell, on failed message, cast spell, on nothing cast spell
Cast 'unravel defense'
trig - 'your defenses are unraveled' 'cast dispel magic self'
now the trigger..
Cast this on yourself? Okay...
one message is "You wave your hands on your body".. dispel successfully cast,can move on to 'cast unravel defense'..
another message is "You failed".. recast spell or move on..
the kicker message - none.. spell successfully cast, but no message other than an advance to a prompt....
any one of these will happen within 3 lines (or 3 seconds)..
I have this, but it doesn't seem to work right, so obviously, I'm doing something wrong...
Code:
#tr {You wave your hands around your body} {} {adeptspell} (adeptspell is the class for the trigger}
#cond {You failed.} {Cast 'dispel magic' self} {within|param=3} {reparse}
#cond {You wave your hands around your body} {cast 'unravel defense' self} {within|param=3} {reparse}
#cond {} {cast 'unravel defense' self} {within|param=3} {reparse}

pretty much, nothing happens..
Reply with quote
Myrkul
Wanderer


Joined: 21 Aug 2008
Posts: 85

PostPosted: Sun Feb 20, 2011 4:31 am   
 
[edit][/edit]


Last edited by Myrkul on Thu Apr 14, 2011 11:06 pm; edited 1 time in total
Reply with quote
Ralph1971
Wanderer


Joined: 01 Mar 2008
Posts: 64

PostPosted: Sun Feb 20, 2011 2:09 pm   
 
here are the three responses, from prompt to prompt.. (sometimes, the cast line will be next to the brackets, sometimes on the next line.. just luck of the draw depending on

Success full cast with 'pass hands' text recieved..

<505/626hp 221/428m 450/450mv 14,488,572gp 816 S [365wt] 1,806,329tnl New Darkhaven >{||} cast 'dispel magic' self
Cast this on yourself? Okay...
You pass your hands around your body...

<505/626hp 206/428m 450/450mv 14,488,572gp 816 S [365wt] 1,806,329tnl New Darkhaven >{||}

successful cast with no response..
<515/626hp 216/428m 450/450mv 14,488,572gp 816 S [365wt] 1,806,329tnl New Darkhaven >{ } cast 'dispel magic' self
Cast this on yourself? Okay...

<515/626hp 201/428m 450/450mv 14,488,572gp 816 S [365wt] 1,806,329tnl New Darkhaven >{||}

there is always a blank line before the prompt.. more a spacing thing with zmud than a blank line from the mud, I think.. will the ^$ still fire from this?
Reply with quote
chamenas
Wizard


Joined: 26 Mar 2008
Posts: 1547

PostPosted: Sun Feb 20, 2011 5:08 pm   
 
^$ is the syntax used specifically to refer to a blank line, so yes, your situation is ideally suited to a ^$

I'll have to read up on Duration triggers, since the fact that they don't disable when they timeout makes it sort of funky to work with. My expectation was a trigger that turned itself off, not one which looks on but is really off, that's awkward.

Code:

<trigger name="Duration Test" type="Duration" param="10000" priority="1221" id="122">
  <pattern>^This is a test</pattern>
  <value>#PRINT "Fired!"</value>
  <trigger name="Duration Test Off!" type="Manual">
    <value>#PRINT "Duration off!"</value>
  </trigger>
</trigger>


Created this set of triggers. Initially it had been set to 10 milliseconds by accident. Fixed it to be 10000, disabled and reenabled (to reset it) and used '#SHOW "This is a test"' to give it a whirl, but the trigger never fired either pattern. Unfortunately, there doesn't seem to be much explanation as to how Duration triggers work. However, it seems like it will require more than 1 trigger either way (needing a second state trigger to turn it off) which is no better than the trigger + alarm trigger scenario I generally use now.

My suggestion is to create a trigger type that can do it all in one. The duration trigger type is a start on how it would work, but it feels like it could use a little more in the way of options.
_________________
Listen to my Guitar - If you like it, listen to more
Reply with quote
Progonoi
Magician


Joined: 28 Jan 2007
Posts: 430

PostPosted: Sun Feb 20, 2011 7:26 pm   
 
As far as I recall, Duration was a trigger type, hence you can't really make an individual trigger off of it. What you can do is a regular pattern matching with secondary dummy state which is empty but which type is set to duration.

In the value of this trigger state, then, you'll set all the things you'll want to do once 1) pattern is matched, and 2) set interval has passed.

Makes quite a bit sense to me. Otherwise, if time is of paramount importance and you dislike trigger states, just do an alarm.
_________________
The Proud new owner of CMud.

--------------------------------
Intel Core i5-650 3,2GHz
4 DD3 RAM
GTX 460 768MB
Win 7 Home Premium 64x
--------------------------------
Reply with quote
DraxDrax
Apprentice


Joined: 22 Mar 2009
Posts: 149

PostPosted: Sun Feb 20, 2011 7:57 pm   
 
Your second trigger doesn't have any pattern.

Try this:
Code:

  <trigger name="Duration Test" priority="1221">
    <pattern>^This is a test</pattern>
    <value>#PRINT "Fired!"</value>
    <trigger type="Duration" param="10000">
      <pattern>^End test</pattern>
      <value>#SAY Test ended successfully.
#STATE "Duration Test" 0</value>
    </trigger>
  </trigger>


The general state of this trigger, state 0, will fire on the line 'This is a test', at which point it echoes the message 'Fired!' and increments to the next trigger state, state 1. In state 1, the trigger will wait for 10 seconds to see the line 'End test'. If it receives that pattern within those 10 seconds, the trigger echoes 'test ended successfully' and resets to state 0. If it doesn't see the second pattern within 10 seconds, it won't generate an echo but will still reset back to state 0. This is essentially what Moo suggested. You should be able to tweak the general idea to accomplish what you intend.
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Sun Feb 20, 2011 8:24 pm   
 
Chamenas, the point of a Duration trigger is that it is a single trigger _state_. The trigger will be in one of two states--State 0, waiting for the text which causes it to start the Duration state, and State 1, the Duration state itself. While the trigger is in State 0, the Duration state is equivalent to disabled, and become active only when the first state fires. I'm not sure how you think this is very different from using some other trigger to enable it.
Reply with quote
chamenas
Wizard


Joined: 26 Mar 2008
Posts: 1547

PostPosted: Sun Feb 20, 2011 8:36 pm   
 
I never said it was very different, I actually said it was the same which was the problem. I'm not looking for something which works exactly the same way, just something that works more efficiently, with less named objects to do the task. In any case, I suppose the reading I'll have to do is on how trigger states work, as opposed to Duration triggers (since there's not much info there). I've never really played with trigger states before.
_________________
Listen to my Guitar - If you like it, listen to more
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