How do I make events run in order?

Get help using Construct 2

Post » Sun Aug 03, 2014 10:59 am

Hello, I have created this hexagon generator. But the thing is, I have to use "wait" action in order for it to work...
How can I make events run in order from top to bottom, not executing them all at the same tick?
At the capx file i have bookmarked the place that I need to get fixed.
You do not have the required permissions to view the files attached to this post.
B
6
Posts: 17
Reputation: 276

Post » Sun Aug 03, 2014 1:42 pm

You could use variables as "triggers".

For instance, create variable "firstEvent". Set it to 0 by default.
When the first event is executed, set "firstEvent" to 1.

On the second event, use "firstEvent = 1" as a condition.
And so on.
Set variables to 1 and 0 at will, after each needed event.
B
33
S
9
G
3
Posts: 493
Reputation: 4,042

Post » Sun Aug 03, 2014 2:20 pm

You are hitting a known issue with Construct2 where you can not pick in the same top level event after a create. You have to either move your picking code to the next top-level event OR just use a Wait 0 and it will correct itself. I've cleaned things up a bit. There was no need for any 'Trigger once' events. I deactivate the Generate group after it is finished so the code doesn't get called repeatedly. You could also place it in a Function, and just call it once from 'On start of layout'.
You do not have the required permissions to view the files attached to this post.
ImageImageImage
B
71
S
21
G
220
Posts: 3,648
Reputation: 123,725

Post » Mon Aug 04, 2014 11:17 am

Thanks for that. What I am trying to do is generate Hexagon made out of random number of triangles. Zindex is the size of hexagon, each number represents layer of triangles. The action order I suppose is Pick center>do all the generate stuff>pick next center and repeat. But what happens if i use repeat is it picks all centers and do everything simultaneously... And if i do function ""for each center" it wont work at all
You do not have the required permissions to view the files attached to this post.
B
6
Posts: 17
Reputation: 276

Post » Mon Aug 04, 2014 1:26 pm

This fixes the picking issue. You'll have to fix the math still for Zindex.
You do not have the required permissions to view the files attached to this post.
ImageImageImage
B
71
S
21
G
220
Posts: 3,648
Reputation: 123,725

Post » Tue Aug 05, 2014 3:20 pm

What I'm trying to achieve is to generate every hexagons size randomly. But even if I set value manually it just bugs out... Zindex is basically size of hexagon. Starting value of Zindex is 3, If i change it before all generating stuff to for example 5, The "generate" part will use new variable 5, but "respawn" part will use old variable 3(parts are seperated with comments)
You do not have the required permissions to view the files attached to this post.
B
6
Posts: 17
Reputation: 276

Post » Tue Aug 05, 2014 3:53 pm

Looks like a side-effect of using the wait action. I did a quick test, look at the attached picture.

wait0.PNG


What would you expect to output to be ? Well I sure expected to see 5 followed by 3. But none of that, it actually output 5 twice...
You do not have the required permissions to view the files attached to this post.
B
67
S
28
G
24
Posts: 970
Reputation: 18,675

Post » Tue Aug 05, 2014 6:13 pm

I wanted the output be 5 then 3 according to your picture

Im newbie to construct. I tought if i would change variable to 5 it would stay 5 and use 5 to all actions than involve changed variable.

What I wanted: VariableX = 3, Change VariableX to 5> do event1 with VariableX(5)> do event2 with VariableX(5)

But what i get is VariableX = 3, Change VariableX to 5> do event1 with VariableX(5)> do event2 with VariableX(3)

It works only if i change variable twice like this
VariableX = 3, Change VariableX to 5> do event1 with VariableX(5)>Change VariableX to 5> do event2 with VariableX(5)

so i assumed it must be a bug...
B
6
Posts: 17
Reputation: 276

Post » Thu Aug 07, 2014 8:01 am

Not a bug or a side effect... Found out that you have to change local variable to local static variable or it will just reset every tick to its initial state
B
6
Posts: 17
Reputation: 276


Return to How do I....?

Who is online

Users browsing this forum: Lancifer, MaxxMunnn and 5 guests