is there a way to get the yield signal's result

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Ramshell

Is there a way of doing something like a maybe monad? Something like this:

yield(function(args), "a_signal", result)
if result:

I think it would be excellent if I can do this since I don’t have to implement a new method for each method I want to trigger based on a specific result.

:bust_in_silhouette: Reply From: Eric Ellingson

I’m pretty sure you can do:

    > SomeNode


signal some_signal

func some_function():
    emit_signal("some_signal", <value>)


func another_function():
    var value = yield($SomeNode, "some_signal")

Of course this configuration is just an example, but the main idea is you can retrieve the values passed to emit_signal(<signal>, <values1>, <value2>, ...). I don’t know offhand how multiple values are passed back - my guess would be an array but you’ll have to do some testing with that.

Thank you. Indeed the values returned by yield are retrieved in a array. The tricky part is that those types are valid when there is more than one param. When we have only one param, we’ll end up having the non wrapped value x.x.

Ramshell | 2019-10-31 11:28