The plugin below illustrates using the new miniwindows concept in a plugin.
Miniwindows were released in version 4.34, see here for a copy:
http://www.gammon.com.au/forum/?id=8811
The plugin below shows a nice health bar in the bottom RH corner, 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.
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\
Miniwindows were released in version 4.34, see here for a copy:
http://www.gammon.com.au/forum/?id=8811
The plugin below shows a nice health bar in the bottom RH corner, 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.
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_v2"
author="Nick Gammon"
id="1459b816b5acd49c249f72e7"
language="Lua"
purpose="Shows Aardwolf stats in a mini window"
date_written="2008-07-18"
requires="4.34"
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[
gauge_left = 45
gauge_height = 11
gauge_right = 190
background_colour = 0x808080
box_colour = 0xD3D3D3
require "checkplugin"
function capitalize (s)
return string.sub (s, 1, 1):upper () .. string.sub (s, 2):lower ()
end -- capitalize
function DoGauge (sPrompt, Percent, sGoodColour, sBadColour)
Percent = tonumber (Percent)
local width = WindowTextWidth (win, font_id, sPrompt)
WindowText (win, font_id, sPrompt,
gauge_left - width - 2, vertical - 2, 0, 0, 0x000000)
WindowRectOp (win, 1, -- frame rectangle
gauge_left, vertical,
gauge_right, vertical + gauge_height,
box_colour)
local colour
--
-- Below 30% warn by using different colour
--
if Percent < 30 then
colour = sBadColour
else
colour = sGoodColour
end -- if
local pixels = (gauge_right - gauge_left - 1) * Percent / 100
WindowRectOp (win, 2, -- fill rectangle
gauge_left + 1, vertical + 1,
gauge_left + pixels, vertical + gauge_height - 1,
ColourNameToRGB (colour))
vertical = vertical + font_height
end -- function
function draw_bar ()
check (WindowRectOp (win, 2, 0, 0, 0, 0, background_colour)) -- fill entire box
-- DrawEdge rectangle
check (WindowRectOp (win, 5, 0, 0, 0, 0, 10, 15))
vertical = 8 -- pixel to start at
DoGauge ("HP: ", stats.hp_percent, "darkgreen", "maroon")
if stats.enemy_percent ~= "9999" then
-- enemy name: stats.enemy
DoGauge ("Enemy: ", stats.enemy_percent, "darkred", "red")
end -- if fighting
DoGauge ("Mana: ", stats.mana_percent, "mediumblue", "mediumblue")
DoGauge ("Move: ", stats.moves_percent, "gold", "gold")
WindowShow (win, true)
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 ()
win = GetPluginID ()
font_id = "fn"
font_name = "Sylfaen" -- the actual font
-- make miniwindow so I can grab the font info
check (WindowCreate (win,
0, 0, 200, 65,
8, -- bottom right
0, -- flags
background_colour) )
check (WindowFont (win, font_id, font_name, 8, false, false, false, false, 0, 0)) -- normal
font_height = WindowFontInfo (win, font_id, 1) -- height
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")
end -- OnPluginEnable
function OnPluginDisable ()
WindowShow (win, false)
end -- OnPluginDisable
function OnPluginSaveState ()
SetVariable ("enabled", tostring (GetPluginInfo (GetPluginID (), 17)))
end -- OnPluginSaveState
]]>
</script>
</muclient>