0 votes

This is in some function:
emitsignal("variablechanged", name)

Then, elsewhere, I want to do something like this:
yield(getnode("."), "variablechanged(my_variable)")

I want to yield when that signal is emitted, but only when "my_variable" is passed into the signal. How can I do this?

asked Feb 16, 2017 in Engine by Anne (19 points)

I can't imagine what you're trying to achieve with that kind of program flow. If you want to issue a yield when a signal is fired, that happens inside the function that is connected to the signal. It will only affect the code inside the signal function, but I get the impression you're wanting to yield elsewhere. Signals are processed at a very specific time so they're not going to randomly jump inside of any function.

Yield acts a lot like a return statement, but when resume is called it goes back to where it exited and continues execution.

Can you give a description of what you're trying to do?

1 Answer

+3 votes
Best answer

You could yield in a loop like

while yield(getnode("."), "variablechanged") != "my_variable":
    pass

Better version suggested by Zylann:

while yield(self, "variablechanged") != "my_variable":
    pass
answered Feb 16, 2017 by raymoo (236 points)
selected May 5, 2017 by Anne

get_node(".") is a useless call, you can use self directly

Right, sorry.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.