Posted by
| Nick Gammon
Australia (23,072 posts) Bio
Forum Administrator |
Message
| After a bit of mucking around I got a timer to do it, like Flannel suggested. I did it in Lua, so either switch your scripting to Lua, or make a plugin out of it. If you have trouble doing that let me know and I'll do one.
I decided it was easier to hard-code the names of each bar rather than trying to interpret the STAT and GAUGE MXP elements, which MUSHclient doesn't currently support.
<timers>
<timer enabled="y" second="5" send_to="12"
>
<send>do
t = t or {}
local old_t = {}
-- make copy of current values
for k, v in t do
old_t [k] = t [k]
end
t.mud_hp = GetEntity ("mud_hp")
t.mud_maxhp = GetEntity ("mud_maxhp")
t.mud_sp = GetEntity ("mud_sp")
t.mud_maxsp = GetEntity ("mud_maxsp")
t.mud_ep = GetEntity ("mud_ep")
t.mud_maxep = GetEntity ("mud_maxep")
t.mud_monster_name = GetEntity ("mud_monster_name")
t.mud_monster_health = GetEntity ("mud_monster_health")
t.mud_max_mon_health = GetEntity ("mud_max_mon_health")
-- see if changed
local changed = false
for k, v in t do
if old_t [k] ~= t [k] then
changed = true
end -- if
end
-- exit if nothing changed
if not changed then
return
end -- if
-- function to send UDP packets with magic keyword and port number
local function udp (msg)
UdpSend ("127.0.0.1", 4111, "magic," .. msg)
end -- function udp
-- function to calculate percent, with guard against divide by zero
local function percent (amount, max)
amount = tonumber (amount)
max = tonumber (max)
if not (amount and max) then
return 0
end -- if no values supplied
if max <= 0 then
return 0
end -- if too low
if amount > max then
return 100
end -- if too high
return math.floor (amount / max * 100)
end -- function percent
-- title, colours, bar sizes, labels
udp ("title,Status")
udp ("textcolour,0")
udp ("backcolour,14804223")
udp ("config,10,5,100,15,70,320,20")
udp ("labels,HP,SP,EP,Monster")
-- bar "foreground" colours
udp ("colours," ..
ColourNameToRGB ("darkgreen") .. "," ..
ColourNameToRGB ("darkblue") .. "," ..
ColourNameToRGB ("saddlebrown") .. "," ..
ColourNameToRGB ("dimgray"))
-- bar "background" colours
udp ("fillcolours," ..
ColourNameToRGB ("lightgreen") .. "," ..
ColourNameToRGB ("lightblue") .. "," ..
ColourNameToRGB ("tan") .. "," ..
ColourNameToRGB ("gainsboro"))
-- percentages
udp ("values," ..
percent (t.mud_hp, t.mud_maxhp) .. "," ..
percent (t.mud_sp, t.mud_maxsp) .. "," ..
percent (t.mud_ep, t.mud_maxep) .. "," ..
percent (t.mud_monster_health, t.mud_max_mon_health)
)
-- monster name
udp ("text,5,95," .. t.mud_monster_name)
end -- do</send>
</timer>
</timers>
What this does is, every 5 seconds, check the entity values, and if they have changed, send an update to the status window. You need to download the status bar window as mentioned above and start it up (ie. execute the .exe) manually.
What you should see 5 seconds later is the status bar with the 4 bars drawn, and then as the updates arrive from the MUD the length of the bars will update. You can see the names of the colours for each bar in the timer above, you can customise that to your choice.
Just drag the window around to a convenient location on the screen. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|