New trigger color options from scripts:

Posted by Shadowfyr on Tue 06 May 2003 09:18 PM — 3 posts, 9,649 views.

USA #0
I am using the following to color channels and recently tried to add code to handle the new 'other_text_colour' and 'other_back_colour' options, but it fails:

<triggers>
  <trigger
   custom_colour="17"
   enabled="y"
   keep_evaluating="y"
   match="^(\d\d:\d\d\s)?(\[druid\])(.*)"
   name="druid"
   regexp="y"
   script="setcolorgrab"
   sequence="5"
   other_text_colour="#25C29B"
   other_back_colour="black"
  >
  </trigger>

  <trigger
   enabled="y"
   keep_evaluating="y"
   match="^()(\S{1,})(.*)"
   name="General2"
   regexp="y"
   script="setcolorgrab"
   sequence="6"
   other_text_colour="black"
   other_back_colour="black"
  >
  </trigger>

  <trigger
   enabled="y"
   keep_evaluating="y"
   match="^()(\[(gossip|bs|aod|events|healer|bardic|cleric)\])(.*)"
   name="General"
   regexp="y"
   script="setcolorgrab"
   sequence="7"
   other_text_colour="black"
   other_back_colour="black"
  >
  </trigger>
</triggers>

sub setcolorgrab (trigname, output, wildcards)
  dim exptemp, exptemp2
  dim CheckList
  CheckList = "[gossip],[bs],[aod],[events],[druid],[healer],[bardic],[newbie],[sales],[hero]"
  exptemp = "^    ([ ]*)(.*)"
  'exptemp2 = "^\S{1,}(.*)"
  dim temp, temp2, count
  temp = split(CheckList,",")
  temp2 = 1
  if instr(wildcards(2), ":") then
    temp2 = 0
  else
    for count = 0 to ubound(temp)
      if instr(wildcards(2),temp(count)) then
        temp2 = 0
        exit for
      end if
    next
  end if
  if trigname <> "General2" or (trigname = "General2" and temp2) then
1    world.addtrigger "colorcode", exptemp, "", 1065, world.gettriggerinfo(trigname,19), 0, "", ""
2    if gettriggerinfo(trigname,19) = 16 then
3      note gettriggerinfo("colorcode",19)
4      settriggeroption "colorcode", "other_text_colour", gettriggeroption(trigname, "other_text_colour")
5      settriggeroption "colorcode", "other_back_colour", gettriggeroption(trigname, "other_back_colour")
    end if
  end if
  world.enabletrigger "General2", 1
end sub


The 'normal' ones work, but here is what seems to happen with the new 'druid' trigger (numbered lines):

1. Tries to set new trigger to be the same as the 'druid' one.

2. Checks to see if this is a special color.

3. Shows the setting that the 'colorcode' trigger got, which shows -1???

4-5 Do nothing as a result.

The problem gets worse if you set a trigger up to use such a color. gettriggeroption(trigname, "other_text_colour") would return the 'correct' color, but if you set 'other_text_colour' or 'other_back_colour' it always ends up with Black, this is setting it directly like above (which is probably bad anyway), using a color name like "Red" or using HTML like "#FF0000". All color types set it from whatever you wanted to 0. Please tell me I am just doing something wrong here...
Amended on Tue 06 May 2003 09:27 PM by Shadowfyr
Australia Forum Administrator #1
OK, there are a few issues here.

  1. Internally MUSHclient stores the custom colours as zero-relative (0 to 15) because that way it can index into the array of 16 custom colours. However GetTriggerOption (and world load/save) adds 1 (subtracts 1 depending on the direction), so that they become 1-relative in the world file or trigger XML.

    Thus, the first custom colour is:

    /world.SetTriggerOption "druid", "custom_colour", 1

    However if you do a world.GetTriggerInfo (19) you will be returned 0.
  2. The code for "no change" is internally -1 however 0 for SetTriggerOption (again, one less).

    So, if you get -1 as the custom colour in GetTriggerInfo, you know it is "no change".
  3. The code for "use other colour" is 17 (when using SetTriggerOption).
  4. It will only use the other colours if the custom colour is 17 (16 internally).
  5. To set the colour using SetTriggerOption you must convert it from a colour name to a long (RGB colour) otherwise you will probably get black, as you are doing. eg.


    world.SetTriggerOption "druid", "other_text_colour", ColourNametoRGB ("red")

    world.SetTriggerOption "druid", "other_text_colour", ColourNametoRGB ("#FF0000")
Amended on Tue 06 May 2003 11:04 PM by Nick Gammon
USA #2
Oops.. Odd, but when I tried passing it a number it also ended up black. Guess the number was too big. :p