< Scenenodehierarchy | CodeSamples | TimerTask >

---% Code tested with Luxinia 0.95 build Nov 15 2006
---% at 11/16/06 22:48:32
 -- untested script

  -- this function will print out a time every time
  -- it is called
local function timercallback ()
  print("tick: ",os.clock()) -- print milliseconds
   -- that passed since Luxinia started
end


  -- this function will yield ten times and yields
  -- which will pause the timer function execution
  -- once it is finished, the function returns 
  -- and will be called during the next period
local function yieldingtimer ()
  for i=1,10 do 
    print("count ",i)
    coroutine.yield()
  end
  print "finished"
end


  -- register the timercallbackfunction to be called
  -- every 200 milliseconds, and catch up 5 times 
  -- until the script gives up to catch up the 
  -- missed periods
Timer.set("called",timercallback,200,5)

  -- registed the yieldingtimer to be called (resumed)
  -- every 500 milliseconds
Timer.set("yielded",yieldingtimer,500)