Thread: pausing a mod
View Single Post
05-09-08, 01:08 PM   #4
Treader
A Murloc Raider
AddOn Author - Click to view addons
Join Date: Dec 2006
Posts: 5
Originally Posted by Porrohman View Post
is it possible to pause the output of a mod for say 5 seconds

I am trying to output multiple lines of text to the windows & I want to have enough time to read it before the next line overwrites it
Edit: Wow! I didn't even realize how old this thread was. It was still on the first page of the forum listing.

You would need to queue the messages (you probably knew that already). OnUpdate would be the prefered way as using a while true or until false loop would just be stupid and annoying, why Shirik even offered it as an option is beyond me.

Anywho,

Code:
-- assumes the following:
-- f is a local frame or a local reference to a global frame with the following
--   user-defined elements:
--     NextMessage (function) -- you're on your own for writing this.
--     pauseTime (number)
--     lastUpdate (number)
-- f:NextMessage() outputs and removes the next message in the queue. :)
-- f.pauseTime already exists and is set to a number value.
-- f.lastUpdate already exists and is set to 0 (zero) when the
--   frame loads or immediately after it is created.
f:SetScript("OnUpdate", function(self, elapsed)
    self.lastUpdate = self.lastUpdate + elapsed
    -- f:NextMessage() will call every time if f.pauseTime <= 0.
    -- f.lastUpdate will keep getting bigger and bigger if f.pauseTime < 0.
    if self.lastUpdate >= self.pauseTime then
        self:NextMessage()
        self.lastUpdate = self.lastUpdate - self.pauseTime
    end
end)
  Reply With Quote