Page 2 of 2 FirstFirst 12
Results 11 to 13 of 13

Thread: Is there a Sleep function available in LUA

  1. #11
    Join Date
    Jun 2004
    Location
    Las Vegas
    Posts
    466

    Default

    I'd take the timer approach as well.

    The following code (copied from part of the last script I posted on the TV grid thread) will allow you to trigger a second event x seconds after starting the grid...
    Code:
    -- first trigger the grid event
    -- please double check this event string, I'm not at my development computer so the name might be wrong
    gir.TriggerEvent("TV_GRID",18)  
    
    -- set a timer for 10 seconds to give the grid time to draw
    xmlTimer = {} 
    timer_round = 0 
    timer_seconds = 10
    
    --XML_TimerKill is used to destroy the timer 
    function xmlTimer.XML_TimerKill () 
       XML_Timer:Cancel() 
       XML_Timer = nil 
    end 
    
    -- TimerMonitor repeatedly calls the TimerHandler function every interval until it is destroyed
    function xmlTimer.XML_TimerMonitor (interval) 
       XML_Timer = gir.CreateTimer("","xmlTimer.XML_TimerHandler()","",1) 
       XML_Timer:Arm (interval) 
    end 
    
    -- TimerHandler function is the second part of the TimerMonitor function 
    -- This does the actual check for the appropriate time. 
    -- This will trigger your second event after [timer_seconds] seconds then the timer is destroyed. 
    function xmlTimer.XML_TimerHandler () 
       timer_round = timer_round + 1 
       if timer_round == timer_seconds then 
          gir.TriggerEvent("MOVE_TO_CHANNEL",18,position) -- replace with your second event 
          position = nil 
          timer_round = nil 
          timer_seconds = nil
          xmlTimer.XML_TimerKill () 
       end 
    end 
    
    xmlTimer.XML_TimerMonitor (1000)

  2. #12
    Join Date
    Jun 2004
    Location
    Las Vegas
    Posts
    466

    Default

    Or an even more elegant approach, you could use the above timer to check for one of the cell id's on the grid to be created. To do that just replace
    Code:
       if timer_round == timer_seconds then
    with
    Code:
       if ie99.Document:getElementById("0,0,0") then
    This would repeat the timer until that cell is defined, regardless if that takes 2 seconds or 10 seconds.

    Chris

  3. #13

    Default

    Quote Originally Posted by VaioUserChris
    Or an even more elegant approach, you could use the above timer to check for one of the cell id's on the grid to be created. To do that just replace
    Code:
       if timer_round == timer_seconds then
    with
    Code:
       if ie99.Document:getElementById("0,0,0") then
    This would repeat the timer until that cell is defined, regardless if that takes 2 seconds or 10 seconds.

    Chris
    Thanks thats is super

Page 2 of 2 FirstFirst 12

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •