Scripting through triggers? - Newbie Question.

Posted by Mick on Mon 29 Mar 2010 09:00 AM — 8 posts, 33,951 views.

#0
Being totally newb, I'd like a simple way of enabling and disabling triggers.

I have a trigger that functions upon npc death (label is deathtrig) and works. I have a second trigger that can proc upon low hp (label is bleeding). I would like to disable deathtrig upon bleeding proc.

Could this be achieved by adding

EnableTrigger("deathtrig", false)

to the trigger "send" box under send to 'script' or am I totally off base?

Cheers in advance.
Australia Forum Administrator #1
Yes that's the way to do it. Try it and see anyway, no harm will come of it.
#2
Nick Gammon said:

Yes that's the way to do it. Try it and see anyway, no harm will come of it.


[string "Trigger: deathtrig"]:1: unexpected symbol near '<'

Made a script file (blank), scripting enabled. The ctrl+shift+8 trigger box doesn't like -

<triggers>
<trigger
enabled="y"
expand_variables="y"
keep_evaluating="y"
match="^(.*?)the nearby scrap\!$"
name="deathtrig"
regexp="y"
sequence="100"
>
<send>k junk</send>
</trigger>
</triggers>

- put in its box. Also have other errors relating to missing functions and subroutines.

[string "Trigger: deathtrig"]:1: '=' expected near 'junk'

I did play around with it before asking here :(
Australia Forum Administrator #3
Huh? Read this:

Template:pasting
For advice on how to copy the above, and paste it into MUSHclient, please see Pasting XML.
#4
As a side question to this, is it possible to use a method similar to this that disable triggers by their group name?
#5
AaronM86 said:

As a side question to this, is it possible to use a method similar to this that disable triggers by their group name?


http://www.gammon.com.au/scripts/function.php?name=EnableGroup

Lua example:
EnableGroup ("groupname", true) -- enable the group
#6
Is it possible to put a trigger inside a Lua script file and have it fire or call a function as if I were Clicking Add and making a trigger through world configuration. Like if I put this into my script file:

<triggers>
<trigger
enabled="y"
group="Channels"
match="* shouts '*'"
omit_from_output="y"
script="redirect"
sequence="100"
>
</trigger>
</triggers>

Is this doable? I tried it but my methods seem to keep giving me errors... I load and re-load trigger files alot, but wanted to ALWAYS have my channels logged, I used to use a plugin but was having too much hassle with it, so I put everything back into triggers in the trigger tab of world configuration. I was wondering if I could do the similar thing I used to have with plugins, but put it in a script file instead. Now that I have it stopping the double send with this current method at least lol.
#7
Well, I'm too tired to tinker anymore. I've decided what I'm going to do is just put ALL my triggers into one trigger file and organize them all by group name and set up alias commands for a toggle on/off feature, by disabling entire group names at a time. ie. disable crafting, disable combat. Toggling will be so I don't have trigger conflictions, it'll be nice to be able to enable and disable by group name and finally stop loading separate trigger files for each different thing I wanted to do without having conflicting triggers. Thank you, Mick and Nick for helping me again tonight. Learned plenty more from reading/tinkering and taking your advice.