Hello.
Im trying to write a little addon showing the first letter of the cast im currently casting.
So far it looks like this:
Code:
llocal frame = CreateFrame("Frame")
function frame:OnEvent(event, ...)
if event == "UNIT_SPELLCAST_START" then
local spell, _, _, _, _, _ = UnitCastingInfo("player")
if spell then
resultat = string.sub (spell, 1, 1)
local cnc = CreateFrame("Frame", "CNC",UIParent)
cnc:SetFrameStrata(HIGH)
cnc:SetMovable(false)
cnc:SetWidth(220)
cnc:SetHeight(10)
cnc:ClearAllPoints()
cnc:SetPoint("Center", "AzCastBarPluginPlayer")
local font = cnc:CreateFontString(nil,"OVERLAY")
font:SetFont("Fonts\\FRIZQT__.TTF",11, "OUTLINE")
font:SetTextColor(0.07, 0.30, 0.46, 1.0);
font:SetText(resultat)
font:SetPoint("Left",CNC,"Left",-1,0)
end
elseif event == "UNIT_SPELLCAST_STOP" then
CNC:Hide()
elseif event == "UNIT_SPELLCAST_FAILED" then
CNC:Hide()
elseif event == "UNIT_SPELLCAST_SUCCEEDED" then
CNC:Hide()
elseif event == "UNIT_SPELLCAST_FAILED_QUIET" then
CNC:Hide()
end
end
frame:RegisterEvent("UNIT_SPELLCAST_START")
frame:RegisterEvent("UNIT_SPELLCAST_STOP")
frame:RegisterEvent("UNIT_SPELLCAST_SENT")
frame:RegisterEvent("UNIT_SPELLCAST_SUCCEEDED")
frame:RegisterEvent("UNIT_SPELLCAST_FAILED")
frame:RegisterEvent("UNIT_SPELLCAST_FAILED_QUIET")
frame:SetScript("OnEvent", frame.OnEvent)
Now, im no lua expert, im pretty much just using trial and error method so here's my problem:
The Addon does exactly what i want until after my first cast. After that cast, regardless if it fails or not, it just stops hiding the frame showing the first letter :S
I'm pretty clueless what to do so i thought maybe someone over here can help me out^^