Script Defined Variables as Triggers

Posted by Noredil on Tue 12 Feb 2008 04:50 PM — 2 posts, 15,172 views.

#0
I've been attempting to make a trigger that fires when it sees one of the values stored in an array. I've been able to do this by declaring inline variables in the XML, but have not been able to get it to fire when the variables are defined in the associated .lua file.

For example...

<trigger
enabled="y"
expand_variables="y"
keep_evaluating="y"
repeat="y"
custom_colour="17"
group="colors"
ignore_case="y"
match="\b(@!tester)\b"
regexp="y"
script="fired"
sequence="100"
other_text_colour="maroon"
other_back_colour="white"
>
</trigger>

This trigger will fire when any of the values in this inline declaration are seen (one, two, or three)

<variables>
<variable name="tester">one|two|three</variable>
</variables>

However, this XML file calls a .lua file from the <script> section, in which all my scripts and other variables are handled.

when I create a variable there such as this:
tester = {one, two, three}

This trigger will not fire. What am I missing? I'd prefer to have all the variables in one place, and accessible by my scripts.
#1
MUSHClient variables are not linked to variables you define in a script file - you have to use the scripting functions GetVariable and SetVariable to retrieve MUSHClient variables from a script.

There is a nifty thing you can do with metatables, though, where you define a table that 'contains' all the MUSHClient variables by virtue of using the aforementioned functions to retrieve the value any time you use it's pseudonym and setting the value where ever you assign one.

More details (and cut/paste code) can be found here:
http://www.gammon.com.au/forum/?id=4904