How do I know when Construct will run something sequentially or in parallel?

0 favourites
  • 5 posts
From the Asset Store
Full game Construct 2 and Construct 3 to post on Google Play
  • I am a 'normal' coder who still can't grasp when Construct works sequentially or in parallel.

    True or False?

    [] functions called from main run in parallel. (the action following the function call will be executed before the function returns)

    [] functions called from other functions run in parallel with main function

    [] sub-event blocks run in parallel. (they only run if conditions are met, but if two sub-event blocks have the same conditions, they will run in parallel)

    [] actions in a single sub-event block run sequentially

    [] conditions run sequentially within a single condition block

    thank you!!

  • whitkin

    Construct almost always runs sequentially. The only time anything runs in parallel is when something is farmed out to a worker (like path finding).

    so the answers to your questions are: false, false, false, true, true.

    calling a function is no different than copying and pasting the actions from the function and putting them where the function was called from. (Except that in the function, it doesn't have any objects picked).

    calling a function from a function is no different - actions still run sequentially. Recursively calling the same function works the same way too...

    Events with a trigger can be executed out of order, otherwise an Eventsheet executes sequentially top to bottom - following function calls as necessary.

    One very common area people have trouble with is knowing when things take some time to finish - like creating an object, a new object can only be picked after the next top level event from where it was created (except that it can be picked by its UID before that). "Wait" also gets people in trouble all the time...

    There are lots of other things that take time to finish - AJAX calls, Local Storage reads and writes, Browser resizing, etc.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • OK! I just saw your other post, and looked at you card game...

    you are having trouble because of "Wait" issues.

    Wait ONLY suspends execution of actions and sub-events directly after and under the Wait command. The rest of the eventsheet does not wait. Sub-events at the same level as the one with the Wait command don't wait.

    so in your game, event 2 has two Wait 1 Second actions. Event 4 is at the same level as event 2 so it is not affected by the Waits. As soon as Construct sees the first wait in event 2, it suspends executing actions after that, and immediately moves on to event 4 and continues executing from there...

    Instead of using Wait, use variables to create flags that indicate when something is ready to happen.

  • This appears to be the same question as in this thread. Please only make one thread per topic.

  • FYI, for others with my issue, there is a new feature in the latest (stable) release "Wait for previous actions to complete." Not sure how it interacts with various parallal processes (e.g. tween) but hopeful this is a useful new tool. Looking forward to trying it.

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