How do I make events run in order?

  • 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.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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.

  • 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'.

  • 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

  • This fixes the picking issue. You'll have to fix the math still for Zindex.

  • 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)

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

    [attachment=0:38b700bu][/attachment:38b700bu]

    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...

  • 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...

  • 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

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)