I'm not that familiar with kgPanels, but presumably you're registering for events in an OnLoad script for the panel:
Code:
self:RegisterEvent("WHATEVER_THE_EVENT_MAY_BE")
In the same place, make sure your panel is hidden, if you're not already:
Code:
self:Hide()
self:RegisterEvent("WHATEVER_THE_EVENT_MAY_BE")
And set up a counter for keeping track of the time:
Code:
self.counter = 0
self:Hide()
self:RegisterEvent("WHATEVER_THE_EVENT_MAY_BE")
Then set an OnUpdate script for the panel. OnUpdate scripts are run every time a new video frame is drawn (10-100 or more times per second, depending on your hardware capability and video settings),
but only when the frame they are set on is shown on the screen. So, setting the frame to hidden immediately makes sure the script won't be running.
In this case, we want the OnUpdate script to count to 10 seconds, and then hide the frame. Assuming kgPanels uses the standard argument names, your OnUpdate script will receive an argument named
elapsed, which contains the amount of time that has elapsed since the last OnUpdate run. You'll use the counter we set up earlier to keep a running total of all these tiny increments of time.
Code:
-- Make sure you have kgPanels r403 or higher; this is required
-- because of a variable naming issue in older versions.
self.counter = self.counter + elapsed
if self.counter >= 10 then
-- 10 seconds have passed!
self:Hide()
end
Now, you'll need to modify your OnEvent script a little bit to use the counter:
Code:
if event == "WHATEVER_THE_EVENT_MAY_BE" then
-- First, reset the counter:
self.counter = 0
-- Then, show the frame:
self:Show()
end
It's important to reset the counter first. Otherwise, it will still be at 10 when you show the panel, so it will immediately get hidden again.
I chose to reset the counter in the OnEvent script, instead of in the OnUpdate script (eg. right after you hide the frame) so that if the event fires again before the 10 seconds are up, it resets the counter and keeps the panel visible for 10 seconds after the last event, not the first one. This may not be relevant for your event (eg. PLAYER_LEVEL_UP) but even if it's not, it doesn't hurt anything to do it this way.