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
trigsandstuff
Newbie


Joined: 09 Jul 2010
Posts: 7

PostPosted: Fri Jul 09, 2010 4:42 am   

Turn off triggers within a class
 
Is there a way to turn off all the triggers within a class, without turning off the class itself?

I'll try to clarify.

Class - Bob
Trigger - a
Trigger - b

Button - Turn off Bob triggers

I want a method of turning off all the triggers in Bob class, while leaving the class itself turned on.
This way, I can add any number of triggers to the Bob class, and the button will still disable all of them.
But I want each trigger to be able to be turned on and fired, individually. That would require the class stay turned on at all times.

Is there a method of doing this without adding t-a , t-b, t-c, etc for each new trigger I add to the Bob class?
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Fri Jul 09, 2010 4:59 am   
 
There is not one command that will do all of them at once like if you just turned off the class. You can, however, give them all names and use #T- to turn off each one.
_________________
EDIT: I didn't like my old signature
Reply with quote
shalimar
GURU


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

PostPosted: Fri Jul 09, 2010 6:43 am   
 
Make a subclass for the triggers and turn that off instead.
_________________
Discord: Shalimar#3679
Reply with quote
trigsandstuff
Newbie


Joined: 09 Jul 2010
Posts: 7

PostPosted: Fri Jul 09, 2010 7:58 pm   
 
A subclass doesn't change anything. It just adds another folder.
Reply with quote
trigsandstuff
Newbie


Joined: 09 Jul 2010
Posts: 7

PostPosted: Fri Jul 09, 2010 8:03 pm   
 
Say i have trigger A, B, and C

A is in a class Activate
B and C are in Triggers

A has an if statement that when true, activates trigger B
when false, activates trigger C

I want to be able to turn off B and C with the push of a button, but I want them to still be able to be turned on by A.

Disabling the class would prevent them from turning on. A subclass wouldn't change that situation. I can add a button that says #T- B;#T- C;, but I want to be able to add many more triggers to that class, without having to manually add more #T- for each trigger.
Reply with quote
Arminas
Wizard


Joined: 11 Jul 2002
Posts: 1265
Location: USA

PostPosted: Fri Jul 09, 2010 9:38 pm   
 
About the best way you are going to be able to handle that is to actually name your triggers.

Then make a function that either turns on or off the trigger based on its name. Something like the following.

Code:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<cmud>
  <class name="testRoot" copy="yes">
    <class name="Triggers" copy="yes">
      <trigger name="Trigger1" priority="60" copy="yes">
        <pattern>^Some random event happens.</pattern>
        <value>#cw MXPRed</value>
      </trigger>
      <trigger name="Trigger2" priority="60" copy="yes">
        <pattern>^Some other random event happens.</pattern>
        <value>#cw MXPBlue</value>
      </trigger>
      <trigger name="Trigger3" priority="60" copy="yes">
        <pattern>^A third random event happens.</pattern>
        <value>#cw dodgerblue
#call @tState(Trigger1,1)
#call @tState(Trigger2,0)
#call @tState(Trigger3,0)</value>
      </trigger>
    </class>
    <class name="Buttons" copy="yes">
      <button autosize="false" width="75" height="23" inset="true" textcolor="#FF6600" border="#3366FF" priority="72" copy="yes">
        <caption>Trigger 1 Text</caption>
        <value>#Show {Some random event happens.}</value>
      </button>
      <button autosize="false" width="86" height="23" priority="82" copy="yes">
        <caption>Disable Trigger 1</caption>
        <value>#call @tState(Trigger1,0)</value>
      </button>
      <button autosize="false" width="86" height="23" priority="80" copy="yes">
        <caption>Disable Trigger 2</caption>
        <value>#call @tState(Trigger2,0)</value>
      </button>
      <button autosize="false" width="75" height="23" inset="true" textcolor="#FF6600" border="#3366FF" priority="71" copy="yes">
        <caption>Trigger 2 Text</caption>
        <value>#Show {Some other random event happens.}</value>
      </button>
      <button autosize="false" width="86" height="23" priority="81" copy="yes">
        <caption>Enable Triggers</caption>
        <value>#loopdb @tTriggers {#if (%val==0) {#call @tState(%key,1)}}</value>
      </button>
      <button autosize="false" width="75" height="23" inset="true" textcolor="#FF6600" border="#3366FF" priority="70" copy="yes">
        <caption>Trigger 3 Text</caption>
        <value>#Show {A third random event happens.}</value>
      </button>
    </class>
    <func name="tState" copy="yes">
      <value>#if (%trigger(tTriggers)==-1)
  {
    #var tTriggers "" _nodef testRoot
  }
#if (%trigger(%string($tName))==-1)
  {
    #print {"Trigger not found."}
    #Return
  }
#switch ($tState==1) {
                        #addkey tTriggers $tName 1
                        #T+ %string($tName)
                     }
        ($tState==0) {
                        #addkey tTriggers $tName 0
                        #T- %string($tName)
                     }
        {#return @{%concat($tName,".",$tState)}}</value>
      <arglist>$tName, $tState</arglist>
    </func>
  </class>
</cmud>


I use something a little more complex but this should show you the idea.
_________________
Arminas, The Invisible horseman
Windows 7 Pro 32 bit
AMD 64 X2 2.51 Dual Core, 2 GB of Ram
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