|
trigsandstuff Newbie
Joined: 09 Jul 2010 Posts: 7
|
Posted: 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? |
|
|
|
MattLofton GURU
Joined: 23 Dec 2000 Posts: 4834 Location: USA
|
Posted: 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 |
|
|
|
shalimar GURU
Joined: 04 Aug 2002 Posts: 4701 Location: Pensacola, FL, USA
|
Posted: Fri Jul 09, 2010 6:43 am |
Make a subclass for the triggers and turn that off instead.
|
|
_________________ Discord: Shalimarwildcat |
|
|
|
trigsandstuff Newbie
Joined: 09 Jul 2010 Posts: 7
|
Posted: Fri Jul 09, 2010 7:58 pm |
A subclass doesn't change anything. It just adds another folder.
|
|
|
|
trigsandstuff Newbie
Joined: 09 Jul 2010 Posts: 7
|
Posted: 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. |
|
|
|
Arminas Wizard
Joined: 11 Jul 2002 Posts: 1265 Location: USA
|
Posted: 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 |
|
|
|
albo Apprentice
Joined: 27 Mar 2008 Posts: 106
|
Posted: Thu Feb 03, 2022 5:21 am Re: Turn off triggers within a class |
trigsandstuff wrote: |
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? |
Hey, I know this is coming in late but I needed a similar setup and I thought I would share something that worked for me. I used a function with a forall loop that iterates through a string list and turns off a single trigger each step along the way; there is a variable local to the function for index. The trigger name of the individual mob triggers are the elements of that string list. To maintain this I need to ensure that each time I create a new mob trigger I give it a unique name, and then also place that unique trigger name in the string list.
Example function,
Code: |
@disableMobTriggers() |
Code: |
$index = 1
#FORALL (@stringlistMobTriggers) {#T- %item(@stringlistMobTriggers, $index)
$index = $index + 1} |
Example usage of ensuring all mob triggers are turned off before turning one on,
Code: |
@disableMobTriggers()
#class {aabot-walk} (1)
#class {aabot-look} (1)
#T+ $a trigger |
Notice in this last one that $a is used, which means this example code is from a function itself. The function starts the player character on a path to hunt down and kill a specific mob somewhere out there in the MUD world. The $a is a trigger name being passed around, the same ones that would be in that string list from earlier. To wrap that up, name your triggers with something unique to that trigger and then place those names in a string list; you can then create a function that contains the loop of #t- and extend its reach on-going without coming back to it. |
|
|
|
hpoonis2010 Adept
Joined: 18 Jun 2019 Posts: 279
|
Posted: Thu Feb 03, 2022 7:52 am |
All of this seems a trifle long-winded.
For myself, I use sub-class for separate items. Eg., Quests
Class: QUESTS
Sub-classes: Quest_trigs, Quest_vars, Quest_aliases, etc. Then I can easily on/off a bunch of things without the hassle of looping. |
|
|
|
albo Apprentice
Joined: 27 Mar 2008 Posts: 106
|
Posted: Thu Feb 03, 2022 8:16 am |
My solution is nested within a bot that runs quests, specifically hunt a mob and kill it quests. Having individual triggers for the mobs was to accomplish needing a specific and unique path for each different mob and a way to use the correct keyword to interact with it. Sometimes the bot comes across a non quest mob on the way to the actual quest mob, so I needed to ensure that only the hunted mob would set off a trigger. The bot is designed to turn the triggers on and off by receiving and completing the quest, but there needed to be a fail safe that would turn off every single mob trigger. At first I had it setup just like you, but the bot just runs smoother with the fail safe.
|
|
|
|
|
|
|
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
|
|