How do I use the return value of a function?

Get help using Construct 2

Post » Thu Feb 19, 2015 10:49 pm

Hi,

can anyone help me to understand, how to use "set return value" and then "if function return value is"?

I don't exactly get, how that works. is it like a waiting state? I imagined, you can call a function, an then use the return value in the following code, (like await signal or as a variable) but that does not seem work the way I thought at least. I also don't understand, how the code knows, which functions return value I mean and so on... I'm quite sure it is easy, but sometimes your mind takes a wrong twist.

I could not find any lecture on that, please give me a link or some advice or an example.


Thanks in advance!
B
8
S
3
Posts: 197
Reputation: 1,207

Post » Fri Feb 20, 2015 1:35 am

So say you have a function like this:

On Function "isXEqual1" (X): -- A function called 'isXEqual1' which takes a parameter of X
if X = 1:
set return value: true
else
set return value: false

now you can call this function using Function.Call("isXEqual1", X) which will return true if X = 1 or false if not.
Nothing goes unanswered!
B
22
S
5
G
1
Posts: 430
Reputation: 3,383

Post » Fri Feb 20, 2015 8:39 am

@briggybros: Thanks, that part was clear though. Now I tried to make a demo of my actual problem (USING the return value), and figured out, it does work just fine the way I thought... I might have had a mistake somewhere, when I originally intended to use this mechanism.

Thanks a lot for your support, your reply was very constructive, as it made me rethink the whole issue.

Untwisted! ;)
B
8
S
3
Posts: 197
Reputation: 1,207


Return to How do I....?

Who is online

Users browsing this forum: Laurent and 2 guests