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


Register forum user name Search FAQ

Gammon Forum

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  General
. . -> [Subject]  Triggers with Varying Numbers

Triggers with Varying Numbers

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


Posted by Aegoman   (1 post)  [Biography] bio
Date Wed 27 Feb 2008 01:27 PM (UTC)
Message
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.
[Go to top] top

Posted by Shaun Biggs   USA  (644 posts)  [Biography] bio
Date Reply #1 on Wed 27 Feb 2008 03:28 PM (UTC)

Amended on Wed 27 Feb 2008 03:29 PM (UTC) by Shaun Biggs

Message
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>

It is much easier to fight for one's ideals than to live up to them.
[Go to top] top

Posted by Nick Gammon   Australia  (22,975 posts)  [Biography] bio   Forum Administrator
Date Reply #2 on Wed 27 Feb 2008 07:17 PM (UTC)
Message
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.


- Nick Gammon

www.gammon.com.au, www.mushclient.com
[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.


12,679 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 HostDash]