Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ MUSHclient ➜ Plugins ➜ Aardwolf health bar plugin

Aardwolf health bar plugin

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


Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Sun 13 Jul 2008 01:45 AM (UTC)
Message
The plugin below shows a nice health bar under your command window, so you can see at a glance your health, compared to the mob you are fighting.


To use it, download the code below and save as Aardwolf_Health_Bar.xml in the Aardwolf subdirectory below your Plugins directory. If you haven't used any Aardwolf plugins before you may need to make the Aardwolf directory.

Alternatively, RH click the link below and choose "Save Link As" (or "Save Linked File As") to save the linked file.

http://www.gammon.com.au/mushclient/plugins/Aardwolf/Aardwolf_Health_Bar.xml

This plugin also uses the "stats detector" plugin, so you also need this file:

http://www.gammon.com.au/mushclient/plugins/Aardwolf/Stats_Detector.xml

The "Stats detector" plugin uses telnet negotation, so you also need this file:

http://www.gammon.com.au/mushclient/plugins/Aardwolf/telnet_options.lua

In a standard MUSHclient installation these three files should to into this directory:


C:\Program Files\MUSHclient\worlds\plugins\Aardwolf\


<?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"
   save_state="y"
   >
<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>

<!--  Script  -->


<script>
<![CDATA[

require "checkplugin"

function capitalize (s)
  return string.sub (s, 1, 1):upper () .. string.sub (s, 2):lower ()
end -- capitalize 

function DoGauge (sPrompt, iPercent, sGoodColour, sBadColour)
local count = 0

  iPercent = (tonumber (iPercent) or 0) / 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 draw_bar ()

  InfoClear ()
  
   -- item 7 is our HP
  DoGauge ("  HP: ",   stats.hp_percent, "darkgreen", "maroon")

  -- item 13 is enemy HP and item 12 is what we are doing, which should be "... fighting (enemy)"
  if stats.enemy_percent ~= "9999" then
    DoGauge ("  " .. stats.enemy .. ": ", stats.enemy_percent, "darkred", "red")
  end -- if fighting 

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

end -- draw_bar

function OnPluginBroadcast (msg, id, name, text)
  if msg == 1 and id == "8a710e0783b431c06d61a54c" then
  
   -- get all variables
   stats = GetPluginVariableList("8a710e0783b431c06d61a54c")
     
   draw_bar ()
   
  end -- stats changed
end

function OnPluginInstall ()

  if GetVariable ("enabled") == "false" then
    ColourNote ("yellow", "", "Warning: Plugin " .. GetPluginName ().. " is currently disabled.")
    check (EnablePlugin(GetPluginID (), false))
    return
  end -- they didn't enable us last time
  
  OnPluginEnable ()  -- do initialization stuff
  
end -- OnPluginInstall

function OnPluginEnable ()

  checkplugin ("8a710e0783b431c06d61a54c", "Stats_Detector.xml")
  
  ShowInfoBar (true)

end -- OnPluginEnable

function OnPluginSaveState ()
  SetVariable ("enabled", tostring (GetPluginInfo (GetPluginID (), 17)))
end -- OnPluginSaveState


]]>
</script>

</muclient>

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #1 on Sun 13 Jul 2008 01:50 AM (UTC)
Message

Example of plugin in operation:


- Nick Gammon

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


10,026 views.

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

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.