Why does this function not work properly? :(-

Get help using Construct 2

Post » Tue May 20, 2014 8:22 pm

Hi.
This issue is not a big deal, but I'd really like to know where does it come from to prevent further errors.
Here is the function :
Image

I remove the system wait (if the value is equal to 0) a part of the code doesn't seems to work (blue frame), and only if the global variable epoch initial value is set to 0 (then it is set to 1 at the beginning of the function).

The red framed blocks on the screenshot below are hidden only if I put a value > 0 in my "system wait".
Image

Any idea? :/
You do not have the required permissions to view the files attached to this post.
Last edited by Coin-coin le Canapin on Wed May 21, 2014 9:06 pm, edited 1 time in total.
B
12
S
7
G
7
Posts: 450
Reputation: 4,276

Post » Tue May 20, 2014 8:35 pm

Maybe the following post and response from Ashley may answer this. It appears to be a similar issue.

https://www.scirra.com/forum/r138-2-function-wait-and-use-instance-variable_p689459?#p689459
If your vision so exceeds your ability, then look to something closer.
Moderator
B
137
S
31
G
87
Posts: 5,545
Reputation: 60,434

Post » Tue May 20, 2014 8:51 pm

I'll read that , thanks!
B
12
S
7
G
7
Posts: 450
Reputation: 4,276

Post » Tue May 20, 2014 8:52 pm

Be wary of the "else" condition, it resets any picking done in the previous condition. Also, if any picking is done on line 25, the "else" at 26 will never fire. The same also applies for lines 27-28. It might not be the behavior you expected.

En bref, fais attention à toute utilisation de la condition "else" ! Parfois il vaut mieux créer une condition inverse que d'utiliser un "else" ! :P
B
75
S
31
G
27
Posts: 1,014
Reputation: 20,763

Post » Wed May 21, 2014 8:31 pm

Hi again.
zenox98 > This is not the same issue. I'm not using any function parameter after my system wait. The thing is my issue occurs when I'm wait 0 second (or don't wait at all) but not when I'm waiting. I've tried to wait 0.000001 seconds. It seems to work because the change is too fast for the computer to show it, but it still doesn't work if I wait 0 second.
:( I'm still stuck on this.

Magistross > I'm aware of that. :)
B
12
S
7
G
7
Posts: 450
Reputation: 4,276

Post » Thu May 22, 2014 10:27 am

Hi,

I've figured out where is the problem after I made a light version of my project (see attached file) : There is a problem in my events order.

Image

The order should be :
event 4 (function setRestrictions)
event 9 (only when event 4 is finished)
event 10 (only when event 9 is finished)

Question is : how do I know when a function has ended?
Should I use a return value? How can I compare this return value to execute another function?
Or if you have another idea... :)
You do not have the required permissions to view the files attached to this post.
B
12
S
7
G
7
Posts: 450
Reputation: 4,276

Post » Thu May 22, 2014 11:25 pm

It's not clear what you want, but this gets things in order. It may help, even if it's not what you want.
You do not have the required permissions to view the files attached to this post.
ImageImageImage
B
71
S
22
G
257
Posts: 3,789
Reputation: 142,694

Post » Fri May 23, 2014 9:58 am

I made other tests and I'm not where does the issue come from. My issue is kind of hard to explain, and even more as I'm not fluent in english. Thank you very much for your help, I give up this time...
B
12
S
7
G
7
Posts: 450
Reputation: 4,276


Return to How do I....?

Who is online

Users browsing this forum: babymumu and 2 guests