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
haiku
Wanderer


Joined: 19 Nov 2004
Posts: 70

PostPosted: Sun Sep 09, 2007 6:01 am   

how do you check to see if a trigger exists?
 
Previously, in zmud, i did this:
Code:

@tank tells the group*"pfull"*
#IF @imhungry=1 {eat food & eat corpse} {}
#IF @imthirsty=1 {ccw cup & sip} {}
#SHOW Checking My_Hp_Status


Checking My_Hp_Status triggered to these commands:
Code:

#VAR pfullState 1
#if @hp<@maxhp {#SHOW Sleeping for hit points.} {#SHOW HP is good.}


Sleeping for hit points. triggered to:

Code:

#Temp {You are now at maximum hitpoints.} {#SHow HP is good.}
sle


HP is good. triggered to:
Code:

#IF (@pfullState=1) {#IF @mana<@maxmana {
    #SHOW Sleeping for mana.
    sle
    } {#SHOW Mana is good.}} {sta}

and so on for movement. is there a better way to handle something like this? In cmud, the #TEMP command will make duplicate triggers... sometimes, zones will repop in the middle of a pfull, and you get this:
tells the group*in*"up"* which I have triggered to:

Code:

sta
#VAR pfullState 0


Because of the interuption, I still have a temporary trigger for Mana is good, and next time we pfull (slang for prep full - clerics have to prep spells on this mud), my pfull triggers will execute twice. If I could programatically check to see if a trigger exists, I could prevent this, but I can't help but think there's a better way to handle the temporary trigger problem. should I create them in a different trigger class and delete the class? Can someone show me an example of how to do this?
Reply with quote
haiku
Wanderer


Joined: 19 Nov 2004
Posts: 70

PostPosted: Sun Sep 09, 2007 6:03 am   
 
I also want to point out that this wasn't a problem in zmud... duplicate triggers didn't happen when doing #TEMP.
Reply with quote
nexela
Wizard


Joined: 15 Jan 2002
Posts: 1644
Location: USA

PostPosted: Sun Sep 09, 2007 7:28 am   
 
Give your Temp trigger an ID this should ensure that only one is created

#TEMP "idname" {pattern} {code}
_________________
Zmud Support Library
Zmud Knowledge Base
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Sun Sep 09, 2007 8:06 am   
 
You can also check to see if a trigger exists with the %trigger function, but it will require an ID. Since your problem will likely be cleared up simply by using the IDs you shouldn't need to do that.

I personally wouldn't use the temporary triggers or trigger off stuff my scripts #SHOW. For what your doing I would suggest placing a few triggers in a class and turning the class on and off with #Tą or #CLASS. You can then use the %class function or a variable to determine whether you need to issue a 'stand' when your sleep is interrupted.
_________________
The only good questions are the ones we have never answered before.
Search the Forums
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