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: Mon Sep 22, 2008 9:48 pm   

Question With Triggers that Ignore Frequency
 
Alright, so I have a bit of a unique situation in the game I play. It is, however, an excellent opportunity to learn. In brief summary: The game I play made a recent coding change in how it groups items. Unfortunately, this recent change has made it so that certain item grouping is not consistent. Why it does it is not important, but since one of my triggers is based off of the grouping, I need to make an alternate trigger.

Specifically, here is the proper grouping pattern:
You give 18 fir boards to MacAllister MacAllen

To which I have:
pattern: ^You give \d+ (\w+) boards to MacAllister MacAllen
Execute: store %1
(store is an alias that runs)

However, for some items, I get another pattern instead:
You give a hickory board to MacAllister MacAllen.

The problem is not simply with that statement, since the numbers are unimportant I could simply alter my pattern slightly to amend that. The problem is it will fire that statement 18 times.

My solution to this is to make a trigger pattern like so:
pattern: ^You give a \w+ board to MacAllister MacAllen$
Execute: store %1

this would go under a separate trigger. But the trigger needs to be intelligent, it needs to know that any of the same pattern following directly after it should be ignored. How do I go about doing this? I don't want it to ignore everything after it, since the pattern will show up again. I merely want to avoid the ones directly following (each occurring on a new separate line, but without blank lines between them)

Over the course of this post it has occurred to me that I could go through a complex procedure with variables that cause it to refire once an even that occurs after (like entering the vault room again) occurs. But I was wondering if there was a simpler route.
_________________
Listen to my Guitar - If you like it, listen to more
Reply with quote
shalimar
GURU


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

PostPosted: Mon Sep 22, 2008 10:07 pm   
 
you could always turn the trigger off after the first time it fires and make an alarm to turn it back on in say... 10-15 seconds
_________________
Discord: Shalimarwildcat
Reply with quote
mr_kent
Enchanter


Joined: 10 Oct 2000
Posts: 698

PostPosted: Tue Sep 23, 2008 8:11 am   
 
You could also use a second trigger state if there is something to trigger on once all the boards are given.
Reply with quote
chamenas
Wizard


Joined: 26 Mar 2008
Posts: 1547

PostPosted: Tue Sep 23, 2008 11:48 am   
 
shalimar wrote:
you could always turn the trigger off after the first time it fires and make an alarm to turn it back on in say... 10-15 seconds


I suppose that could be easiest. I havent had the best luck with conditions though, and lag can screw up the timing, but I'll play around with it.
_________________
Listen to my Guitar - If you like it, listen to more
Reply with quote
Tarn
GURU


Joined: 10 Oct 2000
Posts: 873
Location: USA

PostPosted: Tue Sep 23, 2008 2:46 pm   
 
chamenas wrote:
shalimar wrote:
you could always turn the trigger off after the first time it fires and make an alarm to turn it back on in say... 10-15 seconds


I suppose that could be easiest. I havent had the best luck with conditions though, and lag can screw up the timing, but I'll play around with it.


How about having the normal state of the trigger being inactive?

You could turn it on as part of sending the command (alias, macro, whatever) and turn itself back off when it fires (or after a timeout in case it fails).

-Tarn
Reply with quote
chamenas
Wizard


Joined: 26 Mar 2008
Posts: 1547

PostPosted: Tue Sep 23, 2008 5:28 pm   
 
So normally it's off and it turns off when the store alias is sent via trigger? What turns it off again before the rest kick in?
_________________
Listen to my Guitar - If you like it, listen to more
Reply with quote
Toxic
Adept


Joined: 27 May 2008
Posts: 299

PostPosted: Wed Sep 24, 2008 3:55 pm   
 
Code:
#REGEX GiveTrig {^You give a (\w+) board to MacAllister MacAllen$} {store %1;#T- GiveTrig}
#COND {^$} {#T+ GiveTrig} {within|param=20}


You may need to adjust the param out further to compensate for lengthier sets... but this should work
Reply with quote
shalimar
GURU


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

PostPosted: Wed Sep 24, 2008 6:47 pm   
 
Well if the alias is gonna turn on the trigger, why not just use a named #TEMP instead? Fires once and is gone.
_________________
Discord: Shalimarwildcat
Reply with quote
Tarn
GURU


Joined: 10 Oct 2000
Posts: 873
Location: USA

PostPosted: Wed Sep 24, 2008 9:45 pm   
 
shalimar wrote:
Well if the alias is gonna turn on the trigger, why not just use a named #TEMP instead? Fires once and is gone.


Yes, that might be neater. In the back of my mind, I was thinking of things like counting the number of times it fired as the next logical step to build up to.

He'll probably still want cleanup code in place (prompt, timeout, whatever) if the text doesn't ever fire (such as if the initial command was issued in error, or something prevented it from working).

chamenas, I'm having trouble understanding "So normally it's off and it turns off when the store alias is sent via trigger? What turns it off again before the rest kick in?"

If you mean "So normally it's off and it turns _ON_ when the..." then: it turns itself off, and shalimar is right that making it a #TEMP trigger created by the store alias is probably clearest.

-Tarn
Reply with quote
chamenas
Wizard


Joined: 26 Mar 2008
Posts: 1547

PostPosted: Sat Sep 27, 2008 1:47 pm   
 
Well, I didn't even realize more had been responded to. I can certainly change it if there's a neater way, but I went with this:

Code:

ID: Store Restock2
Pattern: ^You give a (\w+) board to MacAllister MacAllen.$
#IF (@store_restock=1)
{
 store %1 board
 store_restock=0
}
Regular Expression

ID: Store Restock2 reset
Pattern: ^You get a hickory board from the mystic vault.$
#IF (@store_restock=0)
{
 store_restock=1
 #say Store Restock Reset
}
_________________
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