Aardwolf health-bar plugin

Posted by Nick Gammon on Sun 29 Jun 2008 04:52 AM — 2 posts, 8,872 views.

Australia Forum Administrator #0
The plugin below uses the new "statmon" system recently introduced into Aardwolf. It should stand alone from any other plugins, as it just uses the Info bar.

To use it, copy between the lines and save as Aardwolf_Health_Bar.xml in your MUSHclient plugins folder. Then use File menu -> Plugins to install that plugin.

Type "statmon on" into Aardwolf to produce the stats line (which looks like: <stats> lots of numbers </stats>).

You should then see your health, mana, and movement points on the info bar, along with your enemy's name and health if you are fighting.


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE muclient>

<!-- Plugin "Health_Bar" generated by Plugin Wizard -->

<muclient>
<plugin
   name="Aardwolf_Health_Bar"
   author="Nick Gammon"
   id="cfdf0a7e0a13bd77e0d970d7"
   language="Lua"
   purpose="Shows Aardwolf HP, Mana, Movement points in a colour bar"
   date_written="2008-06-28 09:50:05"
   requires="4.00"
   version="1.0"
   >
<description trim="y">
<![CDATA[
Install this plugin to show an info bar with HP, Mana, 
and Movement points shown as a bar (between 0 and 10 blocks).
If you are fighting the enemy's name and health are also displayed.
]]>
</description>

</plugin>


<!--  Triggers  -->

<triggers>
  <trigger
   enabled="y"
   match="&lt;stats&gt;*&lt;/stats&gt;"
   send_to="12"
   sequence="100"
   script="process_prompt"
   omit_from_output="y"
  >
  <send>

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

<!--  Script  -->


<script>
<![CDATA[
function DoGauge (sPrompt, iPercent, sGoodColour, sBadColour)
local count = 0

  iPercent = tonumber (iPercent) / 10
  
--
--  Do prompt in black Arial
--
  InfoColour "black"
--  InfoFont ("Dina", 9, 0)
  InfoFont ("Arial", 9, 0)
  Info (sPrompt)

--
--  Use Webdings for gauge (black square)
--

  InfoFont ("Webdings", 10, 0)


--
--  Below 30% warn by using different colour
--

  if iPercent < 3 then
    InfoColour (sBadColour)
  else
    InfoColour (sGoodColour)
  end -- if

--
--  Draw active part of gauge
--
  while count <= iPercent do
    Info "g"
    count = count + 1
  end -- for

--
--  Draw rest of gauge in grey (ie. unfilled bit)
--

  InfoColour "dimgray"
  while count <= 10 do
    count = count + 1
    Info "g"
  end -- while

end -- function

function process_prompt (name, line, wildcards)

  InfoClear ()
  
  stats = {}
  
  for item in string.gmatch(wildcards [1], "[^,]+") do 
     table.insert (stats, item)
  end

  -- item 7 is our HP
  DoGauge ("  HP: ",   stats [7], "darkgreen", "maroon")

  -- item 13 is enemy HP and item 12 is what we are doing, which should be "... fighting (enemy)"
  if stats [13] ~= "9999" then
    local enemy = string.match (stats [12], "^You are fighting (.+)%.$") or "Enemy"
    DoGauge ("  " .. enemy .. ": ", stats [13], "red", "darkred")
  end -- if fighting 

  -- item 8 is our mana
  DoGauge ("  Mana: ", stats [8], "mediumblue", "mediumblue")
  
  --  item 9 is our movement points
  DoGauge ("  Move: ", stats [9], "gold", "gold")

end -- process_prompt

--
--  Do this once
--

ShowInfoBar (true)


]]>
</script>

</muclient>


Australia Forum Administrator #1

Example of it in operation: