|
Martyl Newbie
Joined: 30 May 2007 Posts: 7
|
Posted: Wed May 30, 2007 8:50 pm
Turning off a trigger based on input |
I'm pretty new to triggers, so forgive me if this is listed somewhere else.
Is there an easy way to turn a trigger OFF based on what someone says in the room?
Ie : Zugg tells you 'Autogold OFF'
And you turn off the Autogold trigger ?
thanks,
Martyl |
|
|
|
Progonoi Magician
Joined: 28 Jan 2007 Posts: 430
|
Posted: Wed May 30, 2007 9:27 pm |
Code: |
#trigger {^(%w) tells you 'Autogold (%w)'$} {#if (%1="Zugg" and %2="off") {#t- Autogold} {#say Not correct line given}}
|
Sees the line when someone tells you something about autogold. then it checks if the person saying it is Zugg. Then it also checks if the autogold is told to put off. If both conditions match, it turns off the trigger called autogold, if it doesn't match those conditions, it will send #say with Not correct line given.
Prog |
|
|
|
Tech GURU
Joined: 18 Oct 2000 Posts: 2733 Location: Atlanta, USA
|
Posted: Wed May 30, 2007 9:32 pm |
Sure...
Try this..
Code: |
#TRIGGER {(*) tells you 'AutoGold ({ON|OFF})'} {#IF (%2 == 'OFF') {#T- AutoGold}} |
That will give you the basic, but you probably want to add some security and make it more generic.
Code: |
#TRIGGER {(*) tells you '(*) ({ON|OFF})'} {#IF (%ismember(%trim(%1),@Friends)) {#IF (%3 == 'OFF') {#T- %2 } {#T+ %2}} } |
It checks against a Friends list so not every one can tell you what to do. The code's not tested but you should get the general idea. |
|
|
|
Fang Xianfu GURU
Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Wed May 30, 2007 10:22 pm |
If you're using Tech's example, though, you might want to add the ^ back onto the start to stop someone malicious doing
say Zugg tells you 'AutoGold off'
Just having the $ at the end might not be sufficient protection. If you're multiplaying between two characters of your own, or if the person you're giving access to is a friend, you might want to store a long (10 hex digits or so) string in a variable and add that to the trigger:
#TRIGGER {(*) tells you 'AutoGold ({ON|OFF}) @TriggerKey'} {#IF (%2 == 'OFF') {#T- AutoGold}}
and then update the code every so often, only giving it to that friend through IMs or something. |
|
|
|
Martyl Newbie
Joined: 30 May 2007 Posts: 7
|
Posted: Thu May 31, 2007 1:00 pm |
Thanks. Since I'm just a simple trigger guy, I ended up making two triggers :
#TRIGGER {Friend tells you 'AutoGold OFF'}{#T- AutoGold}
#TRIGGER {Friend tells you 'AutoGold ON'}{#T+ AutoGold}
Since there was only one person who I wanted to be able to turn it on, and off, this seemed to work fine.
I tried Tech's first example, but it didn't work for me, so I just made it simpler (above) until it works fine now.
thanks so much! You guys ROCK!
Martyl |
|
|
|
Fang Xianfu GURU
Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Thu May 31, 2007 3:34 pm |
You need to be VERY careful using triggers like that one, though. Without anchoring the pattern either at the start or the end with ^ or $, it's possible, like I said in my previous post, for someone to do
say Friend tells you 'Autogold OFF'
and set off your trigger. |
|
|
|
|
|