View Single Post
12-22-11, 04:52 PM   #6
killerpet1986
A Fallenroot Satyr
 
killerpet1986's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2008
Posts: 22
Originally Posted by Rugguggla View Post
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:
  1. local UpdateTimer = 0; -- make an update timer that will count to 5
  2.  
  3. local UpdateFrame = CreateFrame("Frame"); -- create a frame that will update on a screen refresh
  4. UpdateFrame:Hide(); -- hide the frame, it will not update when hidden
  5. UpdateFrame:SetScript("Onupdate", function(self, update)
  6.      UpdateTimer = UpdateTimer  + update; -- increment the UpdateTimer by the amount of time that has passed since the last update
  7.      if UpdateTimer >= 5 then -- if 5 seconds have passed then
  8.           frame:Hide() -- hide the image
  9.           UpdateFrame:Hide(); -- hide the frame (to stop updating)
  10.      end -- end if
  11. end) -- close setscript
  12.  
  13.  
  14.  
  15. local frame = CreateFrame("Frame", nil, UIParent)
  16.      frame:SetPoint("TOPLEFT", 567, -3)
  17.      frame:SetSize(127, 136)     --this is an alias function to frame:SetWidth(127) and frame:SetHeight(136)
  18. local texture = frame:CreateTexture()
  19.      texture:SetTexture("Interface\\AddOns\\Consuela\\consuela")
  20.      texture:SetAllPoints()     --we'll anchor all of the texture's corners to its parent's, the frame above
  21.      texture:Hide()     --we'll hide this for now until you want it shown
  22.  
  23. local function eventHandler(self, event, ...)
  24.      if event == "PLAYER_REGEN_DISABLED" then
  25.           PlaySoundFile("Interface\\AddOns\\Consuela\\comeget.mp3")
  26.           frame:Show() -- show the image
  27.           UpdateTimer = 0; -- reset the timer
  28.           UpdateFrame:Show(); -- show the frame to start the timer
  29.      else
  30.           PlaySoundFile("Interface\\AddOns\\Consuela\\pledge.mp3")
  31.      end
  32. end
  Reply With Quote