Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- timer = function (time)
- local init = os.time()
- local diff=os.difftime(os.time(),init)
- while diff<time do
- coroutine.yield(diff)
- diff=os.difftime(os.time(),init)
- end
- print( 'Timer timed out at '..time..' seconds!')
- end
- co=coroutine.create(timer)
- coroutine.resume(co,30) -- timer starts here!
- while coroutine.status(co)~="dead" do
- print("time passed",select(2,coroutine.resume(co)))
- print('',coroutine.status(co))
- os.sleep(5)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement