Thread: To Gello
View Single Post
08-06-05, 07:30 AM   #2
Gello
A Molten Giant
AddOn Author - Click to view addons
Join Date: Jan 2005
Posts: 521
I don't have the mod installed, but from looking at it, you can get the current/max hp from calling:

current hp = MobHealth_GetTargetCurHP()
max hp = MobHealth_GetTargetMaxHP()

However to display it in realtime you'll want an OnUpdate that continually updates the hp. An easier method if this is just for personal use is to edit MobHealth2. Edit the MobHealth2.lua and MobHealth2.xml and change every "MobHealthFrame" to "MobHealthFrame2" or something that other mods won't try to hide.

But for a simple label that continually updates target hp:

MobHealth3.toc
## Interface: 1600
## Title: MobHealth3
## Notes: Puts MobHealth2-generated current/max hp on TargetFrame hp bar
## Dependencies: MobHealth2
MobHealth3.xml

MobHealth3.xml
<Ui xmlns="http://www.blizzard.com/wow/ui/">
<Script file="MobHealth3.lua"/>
<Frame name="MobHealth3Frame" frameStrata="HIGH" toplevel="true" enableMouse="true" movable="true" parent="TargetFrame">
<Size>
<AbsDimension x="124" y="16"/>
</Size>
<Anchors>
<Anchor point="TOPLEFT" relativeTo="TargetFrame" relativePoint="TOPLEFT">
<Offset>
<AbsDimension x="0" y="-40"/>
</Offset>
</Anchor>
</Anchors>
<Layers>
<Layer level="OVERLAY">
<FontString name="MobHealth3Text" inherits="NumberFontNormal" justifyH="CENTER" wraponspaces="false" text=""/>
</Layer>
</Layers>
<Scripts>
<OnUpdate>
MobHealth3_OnUpdate(arg1);
</OnUpdate>
</Scripts>
</Frame>
</Ui>

MobHealth3.lua
local update_timer = 0 -- time (in seconds) since last update
local update_speed = 1.0 -- time (in seconds) between updates

function MobHealth3_OnUpdate(arg1)

update_timer = update_timer + arg1
if update_timer > update_speed then
update_timer = 0
if UnitExists("target") then
MobHealth3Text:SetText(string.format("%d / %d",MobHealth_GetTargetCurHP(),MobHealth_GetTargetMaxHP()))
else
MobHealth3Text:SetText("")
end
end
end

--

Without MobHealth2 I'm not sure how the above will work. Every second (or however long you set update_speed to) if you have a target it will overlay a "hp/max" over the target's hp bar. You can move it around by setting the anchor offsets. Or put it in another frame and move the frame around, etc. parent="TargetFrame" causes this to hide when your target window hides.
  Reply With Quote