r4m0n

Coroutine Test

Oct 3rd, 2012
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.41 KB | None | 0 0
  1. function co()
  2.   for i = 1, 3 do
  3.     print("co: ", i)
  4.     coroutine.yield(i)
  5.   end
  6. end
  7.  
  8. function coTester()
  9.     c = coroutine.create(co)
  10.     coroutine.resume(c)
  11.     wait(function() return coroutine.status(c) == "suspended" end )
  12.     coroutine.resume(c)
  13.     wait(function() return coroutine.status(c) == "suspended" end )
  14.     coroutine.resume(c)
  15. end
  16.  
  17. ct = coroutine.create(coTester)
  18. coroutine.resume(ct)
Advertisement
Add Comment
Please, Sign In to add comment