function one()
while true do
print("one")
sleep(1)
print("two")
sleep(1)
end
end
function two()
while true do
print("three")
sleep(1)
print("four")
sleep(1)
end
end
o = coroutine.create(one)
co = coroutine.create(two)
while true do
coroutine.resume(o)
coroutine.resume(co)
end
--print(coroutine.status(co))
print("\nThe end.")
[Solved] Trying to understand coroutine
Started by darkrising, May 11 2013 10:22 AM
2 replies to this topic
#1
Posted 11 May 2013 - 10:22 AM
I've been trying to learn how coroutine work, but with not much success. Below is my testing code, what have I done wrong?
#2
Posted 11 May 2013 - 11:13 AM
The thing is the infinite loop. You cannot resume a coroutine wich is dead. If you dont know the term coroutine and death together, you should read this tutorial by Bubba.
#3
Posted 11 May 2013 - 12:19 PM
Thank you for passing me that, it has helped immensely!
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users











