[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]  Question about custom_colour
Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

Question about custom_colour

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


Posted by Blixel   (54 posts)  [Biography] bio
Date Tue 20 Sep 2011 02:48 PM (UTC)
Message
I have a trigger set up to give me a visual cue when I take damage. It's real basic. It works like this:

<triggers>
  <trigger
   group="Status Check"
   match="^\&gt;?You have (.*?)\/(.*?) hitpoints.*?$"
   name="HealthCheck"
   regexp="y"
   send_to="12"
   sequence="100"
  >
  <send>EnableTrigger("HealthCheck", false)
if (%1 &lt; (%2 * .20)) then
  EnableTrigger("FlaskEmergency", true)
  Send ("drink flask")
elseif (%1 &lt; (%2 * .35)) then
  ColourNote ("black", "red", "Health is %1")
elseif (%1 &lt; (%2 * .45)) then
  ColourNote ("black", "orange", "Health is %1")
end</send>
  </trigger>
</triggers>


I noticed MUSHclient can replace the color of text. So I was wondering if instead of using these ColourNotes - which add more text to the screen - if I could instead use custom_colour to do the same thing?

When I tried to replace ColourNote with custom_colour in this trigger, I got compile errors. Is it the case that you can only use the custom_colour that is defined in the trigger header? Can you not set the custom_colour inside of the trigger? Something like this:

<triggers>
  <trigger
   enabled="y"
   group="Tests"
   keep_evaluating="y"
   match="^\&gt;?You have (.*?)\/(.*?) hitpoints.*?$"
   name="colour_test"
   regexp="y"
   send_to="12"
   sequence="100"
  >
  <send>if (%1 &lt; (%2 * .85)) then
  custom_colour="7"
elseif (%1 &lt; (%2 * .90)) then
  custom_colour="11"
elseif (%1 &lt; (%2 * .95)) then
  custom_colour="3"
end</send>
  </trigger>
</triggers>


[Go to top] top

Posted by Ada   (20 posts)  [Biography] bio
Date Reply #1 on Tue 20 Sep 2011 04:37 PM (UTC)
Message
Select 'Omit from output' in the trigger to remove the original trigger text, after that use ColourNote("black", "red", "%0") etc. to rewrite the same line but now with colour. %0 holds the entire match text by the way.
[Go to top] top

Posted by Blixel   (54 posts)  [Biography] bio
Date Reply #2 on Tue 20 Sep 2011 04:59 PM (UTC)
Message
Ada said:
Select 'Omit from output' in the trigger to remove the original trigger text, after that use ColourNote("black", "red", "%0") etc. to rewrite the same line but now with colour. %0 holds the entire match text by the way.


Hmm... that sounds good, but it doesn't seem to have the desired effect. The output color is ordinary white/gray text on black.

Screenshot: http://i.imgur.com/MDxLn.png

Is my trigger missing anything?

<triggers>
  <trigger
   enabled="y"
   group="Status Check"
   keep_evaluating="y"
   match="^\&gt;?You have (.*?)\/(.*?) hitpoints.*?$"
   name="HealthCheck"
   omit_from_output="y"
   send_to="12"
   sequence="100"
  >
  <send>EnableTrigger("HealthCheck", false)
if (%1 &lt; (%2 * .25)) then
  EnableTrigger("FlaskEmergency", true)
  Send ("drink flask")
  ColourNote("black", "red", "%0")
elseif (%1 &lt; (%2 * .35)) then
  --ColourNote ("black", "orange", "Health is %1")
  ColourNote("black", "orange", "%0")
elseif (%1 &lt; (%2 * .45)) then
  --ColourNote ("black", "orange", "Health is %1")
  ColourNote("black", "yellow", "%0")
elseif (%1 &lt; (%2 * .7)) then
  ColourNote ("black", "green", "%0")
else
  ColourNote ("black", "blue", "%0")
end</send>
  </trigger>
</triggers>
[Go to top] top

Posted by Ada   (20 posts)  [Biography] bio
Date Reply #3 on Tue 20 Sep 2011 05:35 PM (UTC)
Message
You forgot to select 'Regular expression' checkbox.
[Go to top] top

Posted by Blixel   (54 posts)  [Biography] bio
Date Reply #4 on Tue 20 Sep 2011 05:46 PM (UTC)
Message
Ada said:
You forgot to select 'Regular expression' checkbox.


... and now it works. (I'm a moron.)

Thanks. This is going to be very useful.
[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,680 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]