Originally Posted by Rugguggla
So all i would need is a texture:Show() when i want to display it after each Soundplay?
Any tips on the 5 second stuff before hiding the image again?
I thought Addon Studio would help me get started, but i think ill just use plain editors with markup instead.
|
You could try something like this: (not sure if its the most elegant solution, someone here might have a better one)
lua Code:
local UpdateTimer = 0; -- make an update timer that will count to 5
local UpdateFrame = CreateFrame("Frame"); -- create a frame that will update on a screen refresh
UpdateFrame:Hide(); -- hide the frame, it will not update when hidden
UpdateFrame:SetScript("Onupdate", function(self, update)
UpdateTimer = UpdateTimer + update; -- increment the UpdateTimer by the amount of time that has passed since the last update
if UpdateTimer >= 5 then -- if 5 seconds have passed then
frame:Hide() -- hide the image
UpdateFrame:Hide(); -- hide the frame (to stop updating)
end -- end if
end) -- close setscript
local frame = CreateFrame("Frame", nil, UIParent)
frame:SetPoint("TOPLEFT", 567, -3)
frame:SetSize(127, 136) --this is an alias function to frame:SetWidth(127) and frame:SetHeight(136)
local texture = frame:CreateTexture()
texture:SetTexture("Interface\\AddOns\\Consuela\\consuela")
texture:SetAllPoints() --we'll anchor all of the texture's corners to its parent's, the frame above
texture:Hide() --we'll hide this for now until you want it shown
local function eventHandler(self, event, ...)
if event == "PLAYER_REGEN_DISABLED" then
PlaySoundFile("Interface\\AddOns\\Consuela\\comeget.mp3")
frame:Show() -- show the image
UpdateTimer = 0; -- reset the timer
UpdateFrame:Show(); -- show the frame to start the timer
else
PlaySoundFile("Interface\\AddOns\\Consuela\\pledge.mp3")
end
end