Comparing value vs array - can't get middle values

0 favourites
  • 4 posts
From the Asset Store
Array Editor
$1 USD
80% off
Supports 1D, 2D, 3D arrays. Import and export arrays in JSON format
  • I have two arrays, one small one big.

    The user picks a Name from the big array. The system compares that name against the Names in the small array. If the Name is in the small array it returns a value of 1, if its not it returns a value of 2.

    Or at least its supposed to...

    I have set this up two different ways.

    #1 using an Array loop

    #2 using a System.For loop.

    Setup #1 will return a value of 1 only on the -last- X item from the small array. All other items that match do not return a proper value. I've tried both with and without the TriggerOnce sub shown in the image.

    <img src="https://dl.dropboxusercontent.com/u/39000273/First%20Way.png" border="0" />

    Setup #2 will return a value of 1 only on the -first- item from the small array. All other items that match do not return a proper value.

    <img src="https://dl.dropboxusercontent.com/u/39000273/Second%20Way.png" border="0" />

    Example:

    ListA:

    Crazy

    Silly

    Sassy

    ListB:

    Crazy

    Funny

    Silly

    Sassy

    Manly

    Scared

    User selects from ListB:

    Manly - return value 2

    Silly - return value 1

    Scared - return value 2

    Sassy - return value 1

    Currently I can get a value of 1 on Sassy or Crazy but not Silly... any cell between the first and last I can't get a proper value returned!

  • Setup #1 won't work because Stop loop is a System action, not an Array action. It won't actually stop.

    Setup #2 won't work because you need to index the array with loopindex, not CurValue/CurX.

  • blackhornet Setup 1 is actually built off a CAPX you helped me with! I had some other help and realized about the Stop Loop but the CAPX you made worked... I'm assuming because it only searched out one value and I have need of multiple. Either way you've saved my day both times!! This is the main thing that's been stopping me from finishing tonight :D That definitely worked by the way. I'm getting proper values all the time now!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Simpler way to do this might be using IndexOf expression. No need to iterate through arrays. :)

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