Changing color with if/then trigger

Posted by Themindkiller on Tue 09 Dec 2025 04:26 AM — 3 posts, 3,164 views.

#0
Might be overthinking how to do this. Probably a simpler way. This seems to work (as in, the right triggers are being enabled at the right times), but the colors aren't changing and I don't know why:

The goal is for the line that looks like "** HP: 202/202" in MUD to change color based on how much HP I have.


<triggers>
  <trigger
   enabled="y"
   group="HP Colors"
   match="^(.*?)\*\* HP\: (.*?)\/202$"
   name="hp_color_start"
   regexp="y"
   send_to="12"
   sequence="50"
  >
  <send>if %2 &gt; 165 then

&#9;
EnableTrigger ("hp_color_green", true)
EnableTrigger ("hp_color_red", false)
EnableTrigger ("hp_color_orange", false)
EnableTrigger ("hp_color_yellow", false)

elseif %2 &gt; 130 and %2 &lt; 166 then

EnableTrigger ("hp_color_yellow", true)
EnableTrigger ("hp_color_green", false)
EnableTrigger ("hp_color_red", false)
EnableTrigger ("hp_color_orange", false)

elseif %2 &gt; 90 and %2 &lt; 131 then

EnableTrigger ("hp_color_orange", true)
EnableTrigger ("hp_color_green", false)
EnableTrigger ("hp_color_yellow", false)
EnableTrigger ("hp_color_red", false)

elseif %2 &lt; 91 then

EnableTrigger ("hp_color_red", true)
EnableTrigger ("hp_color_orange", false)
EnableTrigger ("hp_color_green", false)
EnableTrigger ("hp_color_yellow", false)

end</send>
  </trigger>
  <trigger
   custom_colour="7"
   group="HP Colors"
   match="^(.*?)\*\* HP\: (.*?)\/202$"
   name="hp_color_red"
   regexp="y"
   sequence="100"
  >
  </trigger>
  <trigger
   custom_colour="2"
   group="HP Colors"
   match="^(.*?)\*\* HP\: (.*?)\/202$"
   name="hp_color_yellow"
   regexp="y"
   sequence="100"
  >
  </trigger>
  <trigger
   custom_colour="11"
   group="HP Colors"
   match="^(.*?)\*\* HP\: (.*?)\/202$"
   name="hp_color_orange"
   regexp="y"
   sequence="100"
  >
  </trigger>
  <trigger
   custom_colour="3"
   enabled="y"
   group="HP Colors"
   match="^(.*?)\*\* HP\: (.*?)\/202*$"
   name="hp_color_green"
   regexp="y"
   sequence="100"
  >
  </trigger>
</triggers>
Amended on Tue 09 Dec 2025 04:29 AM by Themindkiller
USA Global Moderator #1
When a trigger matches MUSHclient does not evaluate any further triggers unless "Keep Evaluating" is set on the trigger. But I'm not sure that an activated trigger will fire on the line that triggered its activation anyway. If not, I would probably omit the line from output and print it fresh in whatever color I wanted.
Amended on Tue 09 Dec 2025 05:50 AM by Fiendish
#2
Oh gosh, yah, needed Keep Evaluating on the initial trigger for it to work. Silly mistake. But works fine now, thanks.