Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » zMUD General Discussion
Martyl
Newbie


Joined: 30 May 2007
Posts: 7

PostPosted: 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
Reply with quote
Progonoi
Magician


Joined: 28 Jan 2007
Posts: 430

PostPosted: 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
Reply with quote
Tech
GURU


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

PostPosted: 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.
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: 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.
Reply with quote
Martyl
Newbie


Joined: 30 May 2007
Posts: 7

PostPosted: 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
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: 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.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » zMUD 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