Coroutines allow collaborative multitasking and are a very interesting aspect of Lua. Keep in mind that coroutines are not threads. Using coroutines will help you save time when you need different workers using the same context, and it also produces code that is easier to read and therefore maintain.
Coroutines
Creating a coroutine
To create a coroutine, use the function coroutine.create. This function only creates the coroutine but is not actually executed:
local nt = coroutine.create(function()
print("w00t!")
end)
Executing a coroutine
To execute a coroutine, use the function coroutine...