Highlighting values in a table with addxml.

Posted by ReallyCurious on Mon 21 May 2007 06:23 PM — 3 posts, 26,575 views.

USA #0
I have different tables for different things and sometimes I want those values to be colored, sometimes I don't.

Example:

clanA = {"Warrior", "Cleric", "Paladin", "Warlock", "Magician"} -- This table would be in my script file and would have over 200 names in some cases.

<aliases>
<alias
match="Updateit *"
enabled="y"
expand_variables="y"
send_to="12"
sequence="100"
>
<send>for i,v in ipairs(clanA) do
if IsTrigger("v") ~= 0 then -- checks to see if trigger exists already.
require "addxml"
addxml.trigger { match = v,
regexp = true,
['repeat'] = true, -- repeat is lua kw
send = "",
sequence = 100,
name = v,
enabled = true,
custom_colour = %1, -- adds color I specified
keep_evaluating = true,
group = "clanA Highlights",
}
end -- if
end -- for
ColourNote("white", "red", "clanA highlights updated")</send>
</alias>
</aliases>

So, now I can change colors of any clan I want as long as I got their names inside a table. And EnableTriggerGroup can toggle them on/off if I want to.

Originally, I had a question about how to prevent this alias from creating multiple triggers with the same label(it was doing that), if I hit the alias twice for example. But it looks like doing a check with IsTrigger works it out.

The downside, though, is like my previous mud client I'm going to have many many triggers for highlights(if that's really a problem - i don't know.)
Australia Forum Administrator #1
Quote:

if IsTrigger("v") ~= 0 then


This line is wrong. It checks to see if (literally) "v" is a trigger.

You mean:


if IsTrigger(v) ~= 0 then 
USA #2
yea... I just deleted the IsTrigger part from the alias and tested it again, it's not giving 2 labels with the same name now. But, really though, something I did was creating 2 triggers with the same label. :/ Now everyone's gonna think I'm crazy if I don't duplicate what I was talking about.


Also, It's better to delete the IsTrigger part since there are no duplicate triggers so then I can change the trigger colours as I want.