StyleRuns and Trigger match colors

Posted by WillFa on Fri 29 Aug 2008 11:51 PM — 4 posts, 10,864 views.

USA #0
How can you get the trigger option color codes from a style run?

i.e.

For white on blue, a stylerun has:
1:
"backcolour"=8388608
"length"=7
"style"=0
"text"="example"
"textcolour"=12632256

Trigger has:
<triggers>
<trigger
back_colour="12"
match="*"
match_back_colour="y"
match_text_colour="y"
send_to="12"
sequence="100"
text_colour="15"
>
<send>print("Critter!")</send>
</trigger>
</triggers>

How can I turn 8388608 into 12, etc?
Amended on Sat 30 Aug 2008 12:03 AM by WillFa
USA #1

If I had to guess, 8-15 are NormalColour 1-8, and 0-7 are BoldColour 1-8?

If So,

TriggerOptionColours ={}
for i = 1,8 do
  colour1,colour2 = GetNormalColour(i), GetBoldColour(i)
  TriggerOptionColours[colour1],TriggerOptionColours[colour2] = i+7, i-1
end

and what I want to do is

SetTriggerOption("CritterCatcher", "back_colour", TriggerOptionColours[AsetVars[look_monster].backcolour])
SetTriggerOption("CritterCatcher", "text_colour", TriggerOptionColours[AsetVars[look_monster].textcolour])
--additional code to go thru the XORing of the style bits to "match_bold", etc.

Should work?
(The AsetVars table has been built previously from captured style runs.)
Is there an easier way?
Australia Forum Administrator #2
Er yes, something like that. For example, I had a table like this to convert Aardwolf colour codes into RGB colours (like: "@c(Hum)@w") for drawing in a miniwindow:


local BLACK = 1
local RED = 2
local GREEN = 3  
local YELLOW = 4 
local BLUE = 5 
local MAGENTA = 6 
local CYAN = 7 
local WHITE = 8

-- how each colour is to appear (black is not supported on Aardwolf)

local colour_conversion = {
   r = GetNormalColour (RED)     ,
   g = GetNormalColour (GREEN)   ,
   y = GetNormalColour (YELLOW)  ,
   b = GetNormalColour (BLUE)    ,
   m = GetNormalColour (MAGENTA) ,
   c = GetNormalColour (CYAN)    ,
   w = GetNormalColour (WHITE)   ,
   R = GetBoldColour   (RED)     ,
   G = GetBoldColour   (GREEN)   ,
   Y = GetBoldColour   (YELLOW)  ,
   B = GetBoldColour   (BLUE)    ,
   M = GetBoldColour   (MAGENTA) ,
   C = GetBoldColour   (CYAN)    ,
   W = GetBoldColour   (WHITE)   ,
  }  -- end conversion table
  


Given that table, here is how I am drawing text with codes imbedded in it:


string.gsub (Text, "@(%a)([^@]+)", function (c, t)
      x = x + WindowText (win, FontId, t, x, Top, Right, Bottom, colour_conversion [c])
      end )


USA #3
I'm trying to set a Trigger's colour options.
I haven't found any documentation on the XML attributes.


If I have style information (the long), what should I put into

SetTriggerOption("trigger", "back_colour", ???????)

A sample white on blue trigger has back_colour = 12. Where does 12 come from?



(and why does your conversion table have no love for 'k'/'K'? :))