diff --git a/CHANGELOG.md b/CHANGELOG.md index 09eb2aa..d0d8df7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,10 @@ with the passed name. Properties are considered available if they are found in the result of `ClassDB:class_get_property_list`. +### Fixed + +- Return values passed to `lps_coroutine:resume(...)` when calling `GD.yield()`. + ### Changed - **BREAKING CHANGE**: `Array` and `Pool*Array`'s `__index` and `__newindex` diff --git a/src/late_globals.lua b/src/late_globals.lua index bc234ad..3ddf2d4 100644 --- a/src/late_globals.lua +++ b/src/late_globals.lua @@ -129,7 +129,7 @@ function GD.yield(object, signal_name) if object and signal_name then object:connect(signal_name, co_obj, "resume", Array(), Object.CONNECT_ONESHOT) end - coroutine_yield(co_obj) + return coroutine_yield(co_obj) end local Engine = api.godot_global_get_singleton("Engine") diff --git a/src/test/coroutines.lua b/src/test/coroutines.lua new file mode 100644 index 0000000..4bc9349 --- /dev/null +++ b/src/test/coroutines.lua @@ -0,0 +1,17 @@ +local lu = require "luaunit" + +local Test = {} + +function Test:return_yield() + return GD.yield() +end + +function Test:test_yield_results() + local coro = self:call('return_yield') + lu.assert_nil(coro:resume()) + + local coro = self:call('return_yield') + lu.assert_equals(coro:resume(42), 42) +end + +return Test