Mapper Woes 2: Electric Boogaloo (Xterm colours in triggers)

Posted by Xolorion on Tue 20 Jul 2021 07:40 AM — 4 posts, 18,035 views.

#0
I have been using the mapper plugin written for TI:Legacy in this thread: https://www.gammon.com.au/forum/bbshowpost.php?id=14139

It's wonderful and writing it for us was a great kindness. It works great right up until you enable xterm colours ingame. I quite enjoy xterm colours, so I took it upon myself to try to update the plugin to be compatible.

I've worked out that the problem lies with the "got_room_name" trigger not being triggered due to the text_colour flag. The trigger fires fine when text_colour is removed - unfortunately, its colour is the only identifying factor available to me when it comes to room names.


<trigger
   enabled="y"
   match="^([^[].*)$"
   match_text_colour="y"
   script="got_room_name"
   text_colour="9"
   keep_evaluating="y"
   sequence="90"
   regexp="y"
   name="room_name"
  >
  </trigger>


So is it possible to match triggers to colours with xterm enabled? I'm having trouble finding documentation on the topic.
USA Global Moderator #1
Unless MUSHclient is changed to accept values higher than 15 for the match color, you may have to instead have it match any color and then do the color check in the got_room_name function on the incoming styles table.
Amended on Tue 20 Jul 2021 05:58 PM by Fiendish
Australia Forum Administrator #2
Exactly. Something like:


function got_room_name (name, line, wildcards, styles)
  
  if styles [1].textcolour ~= ColourNameToRGB ("#ff0000") then
    return
  end -- if not the right colour

  -- usual processing here

end -- got_room_name


And then don't match on the colour in the trigger itself.

Of course you need to work out the RGB code for the xterm colour of the room name, but that should be easy enough.

Select an example room name (the first part, which is the colour you are testing on) and then go to Display Menu -> Text Attributes.

In the middle of that dialog box is the exact HTML colour code you need to copy/paste into the script.
#3
Special thanks!

I was able to make the changes as you outlined. It seems to work regardless of whether xterm is enabled ingame or not. In case anyone else has the same curiosity or is trying to find this version of the plugin, my code is on pastebin at https://pastebin.com/0LKM6D9a