Repeat an action x times within a function? [Solved]

Get help using Construct 2

Post » Wed Sep 07, 2016 8:04 am

Hi all. Sorry to post this as I'm sure it's a simple solution, but I searched for every combo of the words on the forums + manual and still can't figure this out.

Basically I want to repeat an action x times within a function, but nada. I know I can call the function outside x number of times and that would be dandy, but then it became a matter of curiosity as to why this doesn't work.

Can anyone explain? Do functions simply run everything inside just once no matter what?

Image

Thank you in advance!

Jimzip :D
Last edited by Jimzip on Wed Sep 07, 2016 11:39 am, edited 1 time in total.
B
6
S
1
Posts: 28
Reputation: 465

Post » Wed Sep 07, 2016 8:59 am

It repeats 30 times, but this way it repeats 30 times in 1 tick.

I suppose you want to see 'those 30 repeats' happen, then you must give the system the chance to redraw. Redrawing the screen happens on the end of the tick.

To do this, you basecaly use the tick-loop. The events run top down (kinda). 1 top down = 1 tick. And it keeps 'ticking' as long as the game runs.

So you need a variable ... lets say 'counter' ... a number.

When you need to the repeat to happen, set it to 29. On the place where you now do the function call.

Now just ....

New event with condition ...
System compare 2 values ... 'counter' ... > ... zero
Actions ....
Substract 1 from 'counter'
All the other actions. from above.
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Wed Sep 07, 2016 11:38 am

Ah. Cool!

That's awesome. It's working like clockwork now. :) Thanks a heap for the help 99Instances2Go!

Here's how it's looking now:

Image

Jimzip :D
B
6
S
1
Posts: 28
Reputation: 465


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 50 guests