[Home] [Downloads] [Search] [Help/forum]

Gammon Forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  Lua
. . -> [Subject]  Ability to set a specific colour code (RGB/Hex) for match_style on a trigger?
Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

Ability to set a specific colour code (RGB/Hex) for match_style on a trigger?

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page


Posted by Gsmith   (14 posts)  [Biography] bio
Date Sun 23 Oct 2016 03:06 PM (UTC)
Message
While we can set up/add in trigger matches for colours 0-7 (basic black, red, green, yellow, blue, magenta, cyan, white), is there some way, or can some advanced SetTriggerOption equivalent command be added to give scripts a means to, require a trigger to match an exact RGB or Hex colour code?

The MUD I play on lets you set any HEX colour code at all for anything, so for instance a user might set their incoming soul commands to be #C0C0C0. Some souls can look like some combat messages if done right, eg an unarmed attack could include poking somebody in the eyes, but there is also a playful soul command that can generate the same text.

I want to be able to let the plugin user specify (or get my script to automatically work out/scrape for) their current exact combat message colours, and then set all combat-message triggers to only match both text and colour - so the silly non-combat souls/emotes/remotes that happen to be able to share exact texts don't cause false-triggers matches.

Is there any way to do this currently? Can a way be added in future versions to let us, via scripting, set a trigger option to not only match on the regex string but also an exact RGB colour code (and anything that doesn't match both doesn't trigger)?

Note: I don't want to do this WITHIN the trigger-function call (eg checking the styles table) - this is because the triggers in question are ALSO re-colouring the incoming messages based on the type of combat message.

I realise one solution CAN be to force omit all incoming matches, have a function check the styles table, then have it re-output the line either with the original styles intact (eg if it was a false-positive), or with the new re-coloured texts depending on the type of combat message... so I know I'm not without solutions altogether, but it'd be nice to just simply be able to do something like;

SetTriggerOption("<trigger name>", "match_rgb_colour", ColourNameToRGB("<their current combat message colours as sent by the MUD>"))

So, I guess this is just an ease-of-life feature request in the end, if there isn't already anything in to let me do this!

Thanks!
[Go to top] top

Posted by Nick Gammon   Australia  (21,322 posts)  [Biography] bio   Forum Administrator
Date Reply #1 on Sun 23 Oct 2016 11:10 PM (UTC)
Message
There's nothing like that at present, and in any case the colour matching which *is* there is fairly limited in that it only tests the first matching character (after all, a matching line can have multiple colours in it).

I think your simplest option is to do what you were thinking. You can make a separate trigger with a low sequence number, and set "keep evaluating". That way your other triggers can still work in the normal way.

In the new (low sequence) trigger check the style runs for the wanted colours, and if you get a hit do your processing, otherwise ignore it.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Gsmith   (14 posts)  [Biography] bio
Date Reply #2 on Wed 26 Oct 2016 11:11 AM (UTC)
Message
I think your way is going to be the way to do it Nick, I could have a lower priority trigger that matches only on "soul/emote/remote" colours, with keep_evaluating set to no, so that the combat-triggers never get a chance to trigger for those "false-match" type lines.

Now I say that, I'm not even sure if that's really any more difficult than having something like my idea above;
SetTriggerOption("<trigger name>", "match_rgb_colour", ColourNameToRGB("<their current combat message colours as sent by the MUD>"))

Although as a perhaps idle curiosity question - would it be a major piece of work for you if you were to ever try and get the "Match Colour" feature built into triggers to work for any RGB colour rather than just the base ANSI colours, perhaps only settable via scripted SetTriggerOptions if not a simple new XML line like;
match_rgb_colour="115544"

Doesn't really matter either way now, but it might, perhaps, still be a nice extra trigger option to be able to set exact RGB colour matches in a future version, if it wasn't something hugely complex/breaking the nature of the behind-the-scenes ANSI or trigger handling!

Thanks Nick, as always really appreciate your patient dedication to your client, AND your community.
[Go to top] top

Posted by Nick Gammon   Australia  (21,322 posts)  [Biography] bio   Forum Administrator
Date Reply #3 on Wed 26 Oct 2016 09:21 PM (UTC)
Message
It probably can be done easily enough. As I said, that would require that you know which character in the line has to be tested against.

But really, this is something you can do quite easily yourself. In the trigger test the style of the matching line (possibly the first style). If it isn't the first there is a module (GetStyle) that lets you find the style for a certain column:

http://www.gammon.com.au/forum/?id=7818

There is even a function (StopEvaluatingTriggers) that lets you stop trigger evaluation.

Template:function=StopEvaluatingTriggers StopEvaluatingTriggers

The documentation for the StopEvaluatingTriggers script function is available online. It is also in the MUSHclient help file.



That lets you simulate a low-sequence trigger matching and stopping evaluation if some condition (which you test in send-to-script) is met.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Gsmith   (14 posts)  [Biography] bio
Date Reply #4 on Thu 27 Oct 2016 12:29 AM (UTC)
Message
Nick Gammon said:

It probably can be done easily enough. As I said, that would require that you know which character in the line has to be tested against.


Ah it's actually an entire-line colouring, so I wouldn't have needed to dip into the styles table at all, which is why I thought a simple option at trigger level to match on an RGB colour would have been a nice quick/easy way to do it without needing any scripting at all, just a quick "Match rgb=xyz, keep evaluating=no" would have been perfect, but as you've shown there's probably 3 or 4 different ways around it, at the very least!
[Go to top] top

Posted by Gsmith   (14 posts)  [Biography] bio
Date Reply #5 on Wed 02 Nov 2016 11:58 PM (UTC)
Message
Nick Gammon said:

There is even a function (StopEvaluatingTriggers) that lets you stop trigger evaluation.

(function=StopEvaluatingTriggers)

That lets you simulate a low-sequence trigger matching and stopping evaluation if some condition (which you test in send-to-script) is met.


Nick, just wanted to check if I am doing this the best way (or maybe the only way), if you wouldn't mind a quick chime in, please?

I want to be able to say "If a colour is anything EXCEPT this colour, then stop evaluating all further triggers on this line". That colour is yellow (RGB 65535). The style run seems to be #2 (even though the WHOLE line is yellow), and so this is what I've come up with. It seems to work but I just want to see if I have done this in a roundabout way or not, please!


  <trigger
   enabled="y"
   keep_evaluating="y"
   omit_from_output="n"
   match="*"
   regexp="n"
   sequence="10"
   send_to="12"
  >
  <send>
    if (GetStyleInfo(GetLinesInBufferCount(), 2, 14) ~= 65535) then
      StopEvaluatingTriggers(false)
    end
  </send>


Appreciate any feedback on a better/more optimal way of doing this - for example, is there a better way to get "The current line's colour", rather than GetStyleInfo combined with GetLinesInBufferCount? Thank you for all the help!
[Go to top] top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


2,536 views.

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at FutureQuest]