WeaselGames / godot_luaAPI

Godot LuaAPI
https://luaapi.weaselgames.info
Other
371 stars 28 forks source link

Feature Request:Improve documentation for LuaCoroutine #108

Closed RadiantUwU closed 1 year ago

RadiantUwU commented 1 year ago

It's not clear whether the thread object that calls .resume() on the coroutine stops for it or not. What happens exactly when .resume() is called?

RadiantUwU commented 1 year ago

It kinda looks like calls to lua_resume will yield the GDScript code.

Trey2k commented 1 year ago

The resume methodnon LuaCoroutine is a blocking call. It will not return until either lua yields and is done executing.

Trey2k commented 1 year ago

If yield_await is called in a GDScript method that's exposed to lua. It will yield thd GDScript method. This is still experimental though.

RadiantUwU commented 1 year ago

If yield_await is called in a GDScript method that's exposed to lua. It will yield thd GDScript method. This is still experimental though.

So basically it turns the running GDScript function into a coroutine?

RadiantUwU commented 1 year ago

The only thing that's needed is to update documentation saying its a blocking call. (for resume())

Trey2k commented 1 year ago

So basically it turns the running GDScript function into a coroutine?

Kind of yeah, its the same as using await anywhere else in GDSCript and having the lua coroutine yield. but when the corutine is resumed it will instead resume where await was called.

There is a code example of how it works here .

The only thing that's needed is to update documentation saying its a blocking call. (for resume())

And yeah that is probably a good idea. There is probably a lot of examples where documentation is not as clear as it should be. I always welcome help with it but I do plan on going through all off it again before the v2 stable release. Which I hope to make happen before godot 4.1 is stable.

Trey2k commented 1 year ago

Fixed in #125