From 1d530a569ec11846e7693bdac5898c1c9cef1f31 Mon Sep 17 00:00:00 2001 From: gilzoide Date: Fri, 28 Jan 2022 08:41:12 -0300 Subject: [PATCH 1/2] Fix GD.yield return (#14) --- src/late_globals.lua | 2 +- src/test/coroutines.lua | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 src/test/coroutines.lua 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 From 7974a5089ce6369873ecaeab5c91b13d1d79dcca Mon Sep 17 00:00:00 2001 From: gilzoide Date: Sun, 27 Feb 2022 12:15:43 -0300 Subject: [PATCH 2/2] Update CHANGELOG with GD.yield fix --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) 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`