Message
| The plugin below shows a stats window, which shows various stats, like your strength, intelligence, hit points, who you are fighting, and so on. The original was written by Onoitsu2, and it has since been modified by Lasher from Aardwolf, and myself.
To use it, download the code below and save as Aardwolf_Stats.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_stats.xml
This plugin also uses the "stats detector" and "create a world" plugins, so you also need these files:
http://www.gammon.com.au/mushclient/plugins/Aardwolf/Stats_Detector.xml
http://www.gammon.com.au/mushclient/plugins/Aardwolf/Create_World_File.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\
An easy way of installing all the required plugins is to install the "plugin installer" described below, and then let it load everything else for you:
http://www.gammon.com.au/forum/?id=8767
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>
<!-- Saved on Sunday, October 15, 2006, 5:29 AM -->
<!-- MuClient version 3.74 -->
<muclient>
<plugin
name="Aardwolf_Stats"
author="Onoitsu2/Lasher"
id="0778870a4855be6de2e34b6d"
language="Lua"
purpose="Displays the Stats on Aardwolf within another window"
date_written="2006-10-15 05:27:29"
requires="4.33"
version="1.1"
save_state="y"
>
<description trim="n">
<![CDATA[
Aardwolf_Stat_SeparaterLUA Help File
This Plugin is used to redirect stats displayed on Aardwolf
into another window (Open World File). The default window is
"Stats". If you change that, you will need to modify
the world name variable.
To turn the stat capture on/off, use 'Aardstat on|off'
]]>
</description>
</plugin>
<script>
<![CDATA[
line_count = nil
require "getworld"
require "checkplugin"
worldname = "Stats"
folder = "Aardwolf"
function OnPluginBroadcast (msg, id, name, text)
if msg == 1 and id == "8a710e0783b431c06d61a54c" then
Stat_Start ()
end -- stats changed
end
function Stat_Start(sName,sLine,wildcards)
local statwin = get_a_world(worldname, folder)
local stats = GetPluginVariableList ("8a710e0783b431c06d61a54c")
local statcol = "#eeeeee";
local labelcol= "#00d6d6";
local goldlcol="#d6d600";
if not statwin then
ColourNote("white", "red", "AardStat 'Send To' Window (" .. worldname .. ") NOT Open!")
EnablePlugin (GetPluginID (), false) -- disable ourselves
return
end -- if we have a stat window
--- Clear existing input.
statwin:DeleteOutput()
--- Just a blank line, better way? no
statwin:Note ("")
formatStat (statcol, statwin, stats.str, stats.base_str,
"Strength : ", false);
statwin:Tell (" ");
formatPool (statwin, stats.hp, stats.max_hp,
"Health : ", true);
formatStat (statcol, statwin, stats.int, stats.base_int,
"Intelligence : ", false);
statwin:Tell (" ");
formatPool (statwin, stats.mana, stats.max_mana,
"Mana : ", true);
formatStat (statcol, statwin, stats.wis, stats.base_wis,
"Wisdom : ", false);
statwin:Tell (" ");
formatPool (statwin, stats.moves, stats.max_moves,
"Moves : ", true);
formatStat (statcol, statwin, stats.dex, stats.base_dex,
"Dexterity : ", true);
formatStat (statcol, statwin, stats.con, stats.base_con,
"Constitution : ", false);
statwin:Tell (" ");
formatSingle (statcol, statwin, stats.hitroll,
"Hitroll : ", true);
formatStat (statcol, statwin, stats.luck, stats.base_luck,
"Luck : ", false);
statwin:Tell (" ");
formatSingle (statcol, statwin, stats.damroll,
"Damroll : ", true);
statwin:Note ("")
statwin:ColourNote (
labelcol, "", "Exp to Level : ",
statcol, "", string.format ("%5d ", stats.to_level),
labelcol, "", "Level : ",
"#00ee00", "", string.format ("%5d", stats.level));
statwin:ColourNote (
labelcol, "", "Alignment : ",
statcol, "", string.format ("%5d ", stats.align),
labelcol, "", "Gold : ",
"#eeee00","", string.format ("%5d", stats.gold));
statwin:Note ("")
colorBar ("Health", stats.hp_percent, statwin);
colorBar ("Mana", stats.mana_percent, statwin);
colorBar ("Moves ", stats.moves_percent, statwin);
statwin:Note ("")
statwin:ColourNote ("#eeeeee", "", stats.doing);
--- Enemy percent 9999 is hax for 'no enemy' :)
if (stats.enemy_percent ~= "9999") then
colorBar ("Enemy", stats.enemy_percent, statwin);
end
end -- Stat_Start
---
--- Format display of a stat/base
---
function formatStat(statcol, w, current, base, label, cr)
sepcol = "#00d6d6";
str = {
sepcol, "", label,
statcol, "", string.format("%3d",current),
sepcol, "", "/",
statcol, "", string.format("%-3d",base)
};
if cr then
w:ColourNote (unpack(str));
else
w:ColourTell (unpack(str));
end
end
---
--- Format display of a 5d stat, probably a better way to combine these two
---
function formatPool(w,current,base,label,cr)
statcol= "#eeeeee";
sepcol = "#00d6d6";
str = {
sepcol, "", label,
statcol, "", string.format("%5d",current),
sepcol, "", "/",
statcol, "", string.format("%-5d",base)};
if cr then
w:ColourNote (unpack(str));
else
w:ColourTell (unpack(str));
end
end
---
--- Format display of a single stat.
---
function formatSingle(statcol, world,current,label,cr)
sepcol = "#00d6d6";
str = {sepcol,"black",label,statcol,"black",string.format("%5d",current)};
if cr then
world:ColourNote(unpack(str));
else
world:ColourNote(unpack(str));
end
end
--
-- Draw colored bars based on percentage input.
---
function colorBar (label, pct, world)
-- show at most 7 x #
local function show_blocks (color, number)
world:ColourTell (color, "", string.rep ("#", math.min (number, 7)))
return number - 7
end -- function
local blocks = pct / 3
world:ColourTell ("#eeeeee", "",
string.format ("%-7s: (%3i%%) ", label, pct))
local colors = { "#880000", -- red
"#d6d600", -- yellow
"#d2d2d2", -- gray
"#ffffff", -- white
"#00d600" } -- green
for i = 1, #colors do
if blocks <= 0 then
break -- all done
end
blocks = show_blocks (colors [i], blocks)
end -- for
world:Note "" -- wrap up line
end -- function colourBar
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()
-- ensure world file exists
CallPlugin ("35dfdbf3afc8cbf60c91277c", "CreateWorldFile", folder .. "," .. worldname)
local w = get_a_world (worldname, folder)
if w then
w:DeleteOutput ()
w:Note "Stats will appear here."
w:SetOption ("do_not_show_outstanding_lines", 1)
w:SetCommandWindowHeight (0) -- no command window
w:SetWorldWindowStatus (3) -- restore it
end -- no world
-- check our stats detector is there
checkplugin ("8a710e0783b431c06d61a54c", "Stats_Detector.xml")
end -- OnPluginEnable
function OnPluginDisable()
local w = get_a_world (worldname, folder)
if w then
w:SetWorldWindowStatus (2) -- minimize it on disable
end -- if
end -- OnPluginDisable
function OnPluginSaveState ()
SetVariable ("enabled", tostring (GetPluginInfo (GetPluginID (), 17)))
end -- OnPluginSaveState
]]>
</script>
</muclient>
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|