How do I configure order of this event sheet?

0 favourites
  • 5 posts
From the Asset Store
Very simple code without excess options (15 events for server and 11 events for client)
  • Hi there.

    I have an issue with order of events.

    I have this:

    So basically on block destroyed event runs -> it spawns new block at new location.

    Then once spawned all blocks in certain range changes variable to +1.

    All works fine besides the fact that this dont work on newly created objects.

    Since multiple objects are destroyed at once - I want this to run every destroyed block.

    Instead it seems it runs just once and newly created objects are not picked by the event sheet.

    I am really puzzled, am I missing something?

  • Newly created objects can't be picked until the next top level event. So the object you just spawned is not picked in event 18 by the "pick all" condition. The new object is picked right after creation though, so you could do something like this:

    16|Block : on detroyed            | System: set blockY2 to Block.y1
      |System: move=0                 | System: set blockX2 to Block.x1
      |                               | System: set Move to 1
      +-------------------------------+
       17|System : for each block     | Spawner: Spawn Block on layer 2 (image point 0)
         |Spawner: Position=block.x1  | Block  : Set x1 to Spawner.Position
         |System : move=1             |
         +----------------------------+
          18|System: Pick all block   | Block : Add 1 to y1
            |Block : y1<blockY2       |
            |Block : x1<blockX2       |
            +-------------------------+
          19|Block : y1<blockY2       | Block : Add 1 to y1
            |Block : x1<blockX2       | System: set Move to 0
            +-------------------------+
    [/code:32dhaeow]
    You can simplify it further. The "move" variable events can be removed since it starts and ends as 0. Also the "for each" can be removed since "on destroyed" is run once for each destroyed object.
    [code:32dhaeow]
    16|Block : on detroyed            | System: set blockY2 to Block.y1
      |                               | System: set blockX2 to Block.x1
      +-------------------------------+
       17|Spawner: Position=block.x1  | Spawner: Spawn Block on layer 2 (image point 0)
         |                            | Block  : Set x1 to Spawner.Position
         +----------------------------+
          18|System: Pick all block   | Block : Add 1 to y1
            |Block : y1<blockY2       |
            |Block : x1<blockX2       |
            +-------------------------+
          19|Block : y1<blockY2       | Block : Add 1 to y1
            |Block : x1<blockX2       |
            +-------------------------+
    [/code:32dhaeow]
    
    One final observation, since you create a block for each destroyed block couldn't you instead just move the block instead of destroying it?
  • I had no idea you couldn't pick objects that where just created when you wanted to pick them in a subevent of the creating event =O

    This clarifies some things.

    R0J0hound you've thought me so much over the years =P

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Sargas

    It is picked by default in sub-events, hence event 19 is working with the new object. It's the "pick all" that won't be able to pick it since the new objects aren't in the object list yet.

    This topic explains the reason:

  • R0J0hound - thanks! I actually completely missed the idea of moving object instead of creating new one. I think when you sit to long on simple problem you cant see bigger picture that clear :/

    This solved all my issues nicely. Thanks a lot! Much appreciated

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