How do I run an event after a loop

Get help using Construct 2

Post » Tue Jul 07, 2015 9:36 pm

Hey,

As you can see in the picture below - I want the following to happen;

- Pipe_base is creased and it spawns Pipe_tubing
- Pipe_tubing grows by 2 height 100 times
- Then as the loop ends Pimp_pump spawns on top of the Pipe_tubing (image point 1)

Image

at the moment the Pipe_pump is spawning straight away before the loop has completed. Is there a way of doing this? I've tried using a for loop as well...

Thanks
B
8
S
2
Posts: 59
Reputation: 686

Post » Tue Jul 07, 2015 9:38 pm

you can try with a subevent eg systeme compare two values loopindex=100: action
Image Image
B
26
S
15
G
142
Posts: 881
Reputation: 74,060

Post » Tue Jul 07, 2015 10:01 pm

Hi,

I just tried your suggestion (compare two values [loopindex = 100]) as a sub event of "on created" and also as a sub event of the loop. Neither spawns a Pipe_pump at any time.

Thanks
B
8
S
2
Posts: 59
Reputation: 686

Post » Tue Jul 07, 2015 10:37 pm

just add local variable (eg "Loop")
on event system repeat 100 times, add action: add 1 to "Loop"
add sub event to the loop : compare "Loop" = 100 : spawn pipe....
set "Loop" = 0
Image Image
B
26
S
15
G
142
Posts: 881
Reputation: 74,060

Post » Tue Jul 07, 2015 10:50 pm

The final index will be 99, not 100. Test as a sub-event of Repeat.
Edit: Wait breaks the scoping, so this won't work.
Last edited by blackhornet on Tue Jul 07, 2015 11:35 pm, edited 1 time in total.
ImageImageImage
B
71
S
22
G
258
Posts: 3,791
Reputation: 143,198

Post » Tue Jul 07, 2015 10:52 pm

Quick example here
Image Image
B
26
S
15
G
142
Posts: 881
Reputation: 74,060

Post » Wed Jul 08, 2015 12:52 am

If I were you I would remove the repeat and instead make a new event for the growth and another one for the spawning of the pipe or simply add it in the growth event.

You can do this by adding a variable to the Pipe_tubing called "Length" or something.
Then you make an event like so:

Every 0.1 second
Pipe_tubing.Length < 100
For each Pipe_tubing
----Add 2 to Pipe_tubing.Length
----Set Pipe_tubing.Height = Pipe_tubing.Height + 2
----If (Pipe_tubing.length = 100)
-------- Spawn Pipe_pump
B
44
S
11
G
2
Posts: 1,182
Reputation: 6,848


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 5 guests