Trouble with Set/GetTriggerOption

Posted by Larkin on Thu 11 Jun 2009 07:01 PM — 8 posts, 36,090 views.

#0
I'm trying to change the color a trigger matches on, but SetTriggerOption is having no effect. When I tried to use GetTriggerOption to see the current value, I got a nil return, and so now I have no idea what I'm doing wrong...

Here's the trigger, for reference, of course:
<triggers>
  <trigger
   back_colour="8"
   enabled="y"
   keep_evaluating="y"
   match="^(?:In the trees above |Flying above |On the rooftops over |In a pit at |In the mountains above |In a nest above )?(.+?)(?: \((?:road|path)\.\))?$"
   match_back_colour="y"
   match_bold="y"
   match_text_colour="y"
   name="mapper_title__"
   omit_from_output="y"
   regexp="y"
   script="mapper_title"
   sequence="10000"
   text_colour="11"
  >
  </trigger>
</triggers>


When I do something like SetTriggerOption("mapper_title__", "text_colour", 9), it doesn't change to red. Help, please?
USA #1
Hmm. I played with it and I keep getting an error saying the trigger option doesn't exist. I get it for back_colour, text_colour, name, match_text_colour, and match_back_colour. All of the others I tested it worked with. It didn't matter what trigger I was using, either.
#2
Yeah, I think the documentation is wrong on this one. Seems like these options just didn't get implemented in MUSHclient or something. I looked at the TriggerOptionsTable in methods.cpp, and it doesn't have these listed!
USA #3
I ran through the source for MUSHclient and found the table of trigger options. None of those are on it, but 'match_style' is, and after testing it, it works. I'm not sure how to come up with a specific style, but I use GetTriggerOption and got a style of 6320 on your trigger. I changed the trigger style to 0 and it went back to default, changed it back to 6320 and it went back to what it was originally.
Amended on Thu 11 Jun 2009 09:08 PM by Fadedparadox
#4
Actually, that does help. It'll be a little trickier, but now I can manipulate the attributes. For example, to get the current text color, I would do this:
text_color = bit.band(bit.shr(GetTriggerOption("mapper_title__", "match_style"), 4), 15)
USA #5
Nick goes through Match_style in this thread:

http://www.gammon.com.au/forum/bbshowpost.php?bbsubject_id=4873

Australia Forum Administrator #6
The documentation is indeed incorrect. I have amended it for the next version.

What happened here was I copied and pasted from the section for ImportXML (which is correct, and which is why you saw stuff like "match_back_colour" in the trigger you pasted). However the part of the program that implements GetTriggerOption handles the bits in the match_style field differently, and hence the explanation of their function that Willfa found at http://www.gammon.com.au/forum/?id=4873.

You may find it easier to use ImportXML rather than SetTriggerOption. The documentation for that has recently been amended to make clear that doing ImportXML on an existing trigger/alias/timer replaces it.

See http://www.gammon.com.au/forum/?id=7123 for the ways the various options work with ImportXML.
Amended on Fri 12 Jun 2009 12:44 AM by Nick Gammon
#7
Aha!

The post that WillFa referred me to actually did help, and I was able to set the style very easily once I understood the flags more clearly.

I use ImportXml in other places, and I thought about it for this, but I think the SetTriggerOption solution is simpler in this case.

Thanks again.