Thread: To Gello
View Single Post
08-06-05, 11:07 AM   #3
wow4me
A Deviate Faerie Dragon
Join Date: Aug 2005
Posts: 11
Thanks again.

I thought about changing the time the addon updates itself to when something happens to the targets health. this way i thought it wouldnt fire each second but rather when my targets hpmoves.

the lua i made is as follows:
function MHealth_OnLoad ()
this:RegisterEvent("UNIT_HEALTH");
this:RegisterEvent("UNIT_HEALTHMAX");
-- this:RegisterEvent("VARIABLES_LOADED");
this:RegisterEvent("PLAYER_TARGET_CHANGED");
message ("Loaded");
end


function MHealth_OnEvent (event)
if (event == "UNIT_HEALTH" or event == "UNIT_HEALTHMAX" or event == "PLAYER_TARGET_CHANGED") then
MHealth_UpdateTargetHealth();
return;
end
end

function MHealth_UpdateTargetHealth ()
local c_hp = MobHealth_GetTargetCurHP();
local m_hp = MobHealth_GetTargetMaxHP();

if UnitExists("target") then
MHealthText:SetText(string.format("%d / %d",c_hp,m_hp));
else
MHealthText:SetText("None")
end
end

----------

The addon would load. also when i targetted a pig outside of org the health managed to appear on the bar

but whenever i click anything this error comes out
[string
"Interface\AddOns\mhealth\MHealth.lua"]:22:bad argument #2 to `format'
(number expected, got nil)

any idea?

the code you put up kept getting errors around the settext area, i think it was getting confused with all the ))) hehheh....so i did a workaround by assigning them to local variables.
  Reply With Quote