Array Events

This forum is currently in read-only mode.
From the Asset Store
Supports 1D, 2D, 3D arrays. Import and export arrays in JSON format
  • How would I go about making a sheet that checks if ANY variable in the array has a specific value and then does something based on this variable that has this specific value?

  • Suppose you want to perform an action on every element which equals 77.

    Use the conditions:

    + Array: For Each Element

    + (System/Compare values) Array.CurrentValue equal to 77

    : Any actions you want

    For example, to limit all elements in the array to a maximum of 100 when the user presses spacebar:

    + On spacebar pressed

    + For Each Element

    + Array.CurrentValue greater than 100

    : Array: set value at X,Y,Z:




    to 100.

    'For Each Element' repeats the event for every element in the array. Under the 'For each' expressions you'll find Array.CurrentValue (the value of the current element being tested), Array.CurrentX, Array.CurrentY and Array.CurrentZ (the indices of the current element).

    Does this help?

  • Aw, man, you made my day <img src="{SMILIES_PATH}/icon_biggrin.gif" alt=":D" title="Very Happy" />. Construct is a bit hard for me to grasp, but I'm learning! I really really love this tool. Many thanks for the fast respone <img src="{SMILIES_PATH}/icon_smile.gif" alt=":)" title="Smile" />.

  • Hm, now I have another problem. I have:

    + Array: For Each Element

    + (System/Compare values) Array.CurrentValue equal to 1

    : Create Object blahblah...

    Even though the value isn't 1 or any other number, many many instances of this object are created. Help?

  • Well your event is equivalent to:

    + Always

    + Array: For Each Element

    + (System/Compare values) Array.CurrentValue equal to 1

    : Create Object blahblah...

    i.e., 'For Each' on its own runs every frame, not just once.

    To resolve this add another condition above the 'For Each' condition. In my original example, I added a 'On spacebar pressed' condition above the For Each, to avoid this problem: the array is only checked when you press spacebar.

  • This is a another problem I just solved. Bur I mean something different:

    + On Layout Start

    + Array: For Each Element

    + (System/Compare values) Array.CurrentValue equal to 1

    : Create Object at CurrentX*32 and CurrentY*32

    What this should do is find all 1s in the array, multiply the X and Y values with 32 and place the object on a generated grid. But it does not only put objects where a 1 is, it puts objects everywhere on the grid and fills it up. It does not matter what number is in the array... I really apreciate your help <img src="{SMILIES_PATH}/icon_smile.gif" alt=":)" title="Smile" />.

  • Oops, a bug! Something is wrong with For Each Element. I'll try have it fixed for the next build, which should be out today or tomorrow.

  • Thanks, I'll impatiently wait <img src="{SMILIES_PATH}/icon_biggrin.gif" alt=":D" title="Very Happy" />.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I think I've fixed this now, when the next build comes out let me know if it works!

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