Archive 17/01/2023.

Lua coroutine extension

aster2013

Hi, all

I have add coroutine support in Lua, and provide two extension functions for Lua coroutine.
coroutine.start(func) – create new coroutine and resume it. the function code:

function coroutine.start(func)
    local co = coroutine.create(func)
    return coroutine.resume(co)
end

coroutine.sleep(time) – sleep current coroutine, it will wake up until the time arrived.

I think it is helpful. For more information, please refer the Coroutine.lua sample in LuaScripts.

weitjong

??

Is it possible to make the coroutine yield/resume based on other events and not just based on time step?

aster2013

???

friesencr

with this, debugger support, and code completion is becoming more tempting to give up my static typing. except i have about half of the api i use commonly in my fingers now. on my resource editor branch i have a hacky version of a coroutine built into the update loop. getting the real deal would be much better.

angelcode.com/angelscript/sd … orout.html

aster2013

Two functions will be added:

coroutine.waitevent( event )
coroutine.sendevent( event )

weitjong ???

weitjong

Yes, I think so. With this, the coroutine will be more versatile.

aster2013

coroutine.waitevent( event )
coroutine.sendevent( event )

added, please get it.

weitjong

For a second, I thought I read "add please, (in order to) get it. :laughing:
Thanks Aster. You are the best.