How do I prevent unwanted triggering of event?

Get help using Construct 2

Post » Thu Jun 11, 2015 8:52 pm

Hello everybody!
This is my pseudo code:

system every int(random(1,3)) seconds > set position to int(random(0,2))
- position = 0 > create object from family at some coordinates
- position = 1 > create object from family at some coordinates
- position = 2 > create object from family at some coordinates

It all works great except on start of layout it is all triggered at once and 3 objects are created instead of only one. Afterwards it works as intended.
Can someone help? What am I missing?

Thank you!
B
8
S
1
Posts: 34
Reputation: 439

Post » Fri Jun 12, 2015 6:42 am

Anyone?
B
8
S
1
Posts: 34
Reputation: 439

Post » Fri Jun 12, 2015 7:20 am

I can not confirm, works well for me.
With this code I have an other problem, its nearly impossible that position is 2!
I need to do set position to int(random(0,3)), because if not:
0 - 0,999999 is 0
1 - 1,9999999 is 1
2 - 2 is 2
Or is this intended?

------------------------------------------------------------------------------------------------

You have already added some to layout in editor?
Seems to be the only possibility...
Or thats not all code.
Sorry for my bad english, but I really do my best! And use and check with Google Translator.
B
10
S
4
G
1
Posts: 158
Reputation: 1,303

Post » Fri Jun 12, 2015 8:08 am

Thanks, I'll try and let you know if it works.
This is only a small portion of code, the part that doesn't work as planned.
As I said, it works great except it creates 3 objects the first time.
B
8
S
1
Posts: 34
Reputation: 439

Post » Fri Jun 12, 2015 9:34 am

If you only want to generate four random numbers you could also use the choose expression. It's exactly like random.

Example:

choose(0,1,2,3)
B
54
S
23
G
13
Posts: 750
Reputation: 12,416

Post » Fri Jun 12, 2015 10:48 am

Nice, I didn't know that. I'll definitely try it.
B
8
S
1
Posts: 34
Reputation: 439

Post » Fri Jun 12, 2015 2:26 pm

Message: Kresho can only post plain text URLS until they have 500 rep. 1 URLS modified. Why?
I still can't figure it out.
I created the example so you can see the problem: https://www.dropbox.com/s/wxf921vulxlgw1k/example.capx?dl=0
B
8
S
1
Posts: 34
Reputation: 439

Post » Fri Jun 12, 2015 3:05 pm

Those are the three objects you have in the layout. You should destroy them 'On start of layout', or put them in a separate Misc layout.
ImageImageImage
B
71
S
21
G
232
Posts: 3,696
Reputation: 129,868

Post » Fri Jun 12, 2015 7:40 pm

blackhornet wrote:Those are the three objects you have in the layout. You should destroy them 'On start of layout', or put them in a separate Misc layout.

YES!
Thanks a lot!
B
8
S
1
Posts: 34
Reputation: 439

Post » Fri Jun 12, 2015 8:03 pm

:? I asked for this in first post.
Sorry for my bad english, but I really do my best! And use and check with Google Translator.
B
10
S
4
G
1
Posts: 158
Reputation: 1,303

Next

Return to How do I....?

Who is online

Users browsing this forum: cb130felix, Kermad, Lancifer, Matei511, mongoose665, piddlyPoo, yiuyiu6666 and 3 guests