Triggers with Varying Numbers

Posted by Aegoman on Wed 27 Feb 2008 01:27 PM — 3 posts, 18,513 views.

#0
I have a very simple question.

How do I make a trigger that activates when a number gets below a certain point (whether it be a set number or a % of a larger one)?


Every few seconds a number gets refreshed, it starts at 2000 when at 100%. I would like to play a sound when the number drops below 1000 or 50%, which ever I can utilize.


I've searched the Help Files, Googled all I can, and tried to search these forums, but I can't seem to find anything. It's probably such a basic thing that it's not needed to be listed, but my knowledge of these things is pretty poor.

Thank you, in advance.
USA #1
You need to have a script set up for that. It will depend on if you want to have it set off once or every time the number drops below that point.

The following is an example of a script which will spam "HP Low!" after each prompt if your prompt was set up for something ridiculus like "hp: 2000 mp: 500". For anything that would fire once and then have to be reset before firing again, then you would have to disable the trigger or set up a flag to check if it is ok to run the script.

<triggers>
  <trigger
   enabled="y"
   match="hp: *  mp: *"
   send_to="12"
   sequence="100"
  >
  <send>if %1 < 1000 then
  Note("HP Low!")
end
</send>
  </trigger>
</triggers>
Amended on Wed 27 Feb 2008 03:29 PM by Shaun Biggs
Australia Forum Administrator #2
Shaun is right, although his example won't paste correctly because you need to change < to &lt; .



<triggers>
  <trigger
   enabled="y"
   match="hp: * mp: *"
   send_to="12"
   sequence="100"
  >
  <send>

hp = %1
MAX_HP = 2000
old_hp = old_hp or MAX_HP -- first time, assume max

if hp &lt; (MAX_HP / 2) and  -- if too low
   old_hp &gt;= (MAX_HP / 2) then  -- and not warned yet
  Sound ("ding.wav")
end

old_hp = hp  -- remember for next time

</send>
  </trigger>
</triggers>


This general topic is covered in http://www.mushclient.com/scripting. A little way down the page it shows testing for health low, with screen shots and everything.

As Shaun pointed out, one problem you might face is an annoyingly large number of warning sounds if the number drops too low, and stays low for a while, as every time the prompt (or whatever it is) is received it would play the sound.

My more elaborate example above saves the last value, and only plays a sound if it drops below the old value, the first time. Then it remembers the value and doesn't play the sound again, until it rises above 1000, which would trigger it off to play the sound again.

Because of the XML code it is easier to copy the whole thing and paste into MUSHclient, and look at it there, see http://www.mushclient.com/pasting.