WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   General Authoring Discussion (https://www.wowinterface.com/forums/forumdisplay.php?f=20)
-   -   pausing a mod (https://www.wowinterface.com/forums/showthread.php?t=9037)

Porrohman 03-14-07 09:40 PM

pausing a mod
 
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

Shirik 03-31-07 01:38 PM

Quote:

Originally Posted by Porrohman
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

You could:

(1) Go into a while loop, checking when 5 seconds have passed with time(), and then continue.

Pros: Very easy to do
Cons: Locks up the game for 5 seconds :p

(2) Use OnUpdate to calculate when 5 seconds have passed, and then continue by calling a function which does the rest of what you need to do.

Pros: Doesn't lock up the game; the "preferred" way to do it
Cons: Not the easiest thing to understand for newer programmers

http://www.wowwiki.com/HOWTO:_Use_OnUpdate_Correctly

ravagernl 03-31-07 02:02 PM

http://www.wowinterface.com/download...7-Cadence.html looks what you want.

Treader 05-09-08 01:08 PM

Quote:

Originally Posted by Porrohman (Post 48563)
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)



All times are GMT -6. The time now is 05:25 AM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI