Problem with function

Discussion and feedback on Construct 2

Post » Wed Jul 26, 2017 4:34 pm

Hi, please, can anyone tell me why the text is not written ?.

Image




If you write the text this indicates that the parameter 0 is 0 but if you do the check, then it does not work.

Image
B
29
S
12
G
20
Posts: 756
Reputation: 13,855

Post » Wed Jul 26, 2017 5:31 pm

From what I can see, you're not adding a parameter when you call the function.

Your first line

System: Every tick -> Function: Call "test" ()

needs the text to passed between those brackets. For example:

System: Every tick -> Function: Call "test" ("The Mnk")
B
20
S
5
G
3
Posts: 66
Reputation: 2,823

Post » Wed Jul 26, 2017 5:55 pm

Yes, I already know, but a function that does not receive any parameters has its parameters to 0 by default, so I'm checking that but it does not work.
However, if I write the text indicating the value of the parameter (in the second image) this indicates that it is 0, as I said at the beginning in this same message.

So.
- A function has the default value 0 in its parameters.
- If you check a parameter when the function does not receive any, the check does not work even though the parameter is 0 by default.
- If you type the text to indicate the default value of a parameter, this indicates that it is 0.

So, if the parameter is 0 by default, why does not the check work ?:
Function.param (0) = 0
B
29
S
12
G
20
Posts: 756
Reputation: 13,855

Post » Wed Jul 26, 2017 6:11 pm

Its zero based, not zero default.
There's no reason to think something that wasn't created should exist.
Image ImageImage
B
168
S
50
G
163
Posts: 8,221
Reputation: 105,061

Post » Thu Jul 27, 2017 1:41 am

Newt is right. Nothing is different than zero. If there's no parameter, it can't have a value.

The function is looking for a parameter, but if it doesn't find one, it doesn't assume 0. It throws an error (check your browser console, it should tell you there).
B
20
S
5
G
3
Posts: 66
Reputation: 2,823

Post » Thu Jul 27, 2017 7:56 am

Ok, I understand, I read the documentation but I have not seen anything about it, thank you.
B
29
S
12
G
20
Posts: 756
Reputation: 13,855


Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 2 guests