How do I find my corresponding array entry?

0 favourites
  • 5 posts
From the Asset Store
Supports 1D, 2D, 3D arrays. Import and export arrays in JSON format
  • Hi,

    I have a 2D array that contains a list of UIDs in row 1 and a flag in row2

    I pick a random line, do stuff with the UID and delete the line

    and then I want to find that other line that has the same flag to remove it as well

    could look something like this:

    UID Flag

    41 0

    45 0

    50 1 <- randomizer might pick this line for example

    53 1

    59 2

    62 2

    how do i find and remove the other ones that are flagged the same?

  • my approach was to go:

    array>for each X element

    compare: value at (loopindex,1) = pickedFlag

    action: delete row (loopindex) from X axis

    but I doesn't seem to work

  • Try

    System: For "" from Array.Width - 1 to 0

    Array: Value at (loopindex, 1) = pickedFlag ---> Array: Delete index loopindex from X axis

    edit: I rarely use Array: For Each. Maybe it's just personal preference.

    Also I'm not sure what you meant by "action : delete row (loopindex)". You never wanted to delete a row, just a column. Remember C2 debugger shows the axes switched 90 degrees, so rows look like columns and vice-versa. I'm going backwards in the above code because if you modify the array you're currently iterating, you'll skip a column when the array gets shorter by 1 column.

  • guess we're talking about the same thing, what i want to delete is the line with the picked UID and its flag.

    thanks for elaborating, wasn't sure you meant what i thought you meant seems to be working now, thanks!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • guess we're talking about the same thing, what i want to delete is the line with the picked UID and its flag.

    thanks for elaborating, wasn't sure you meant what i thought you meant seems to be working now, thanks!

    Glad it helped. I was just trying to say that you're deleting columns, not rows (lines)

    Your array actually looks like this:

    41, 45, 50, 53, 59, 62
    0,  0,  1,  1,  2,  2[/code:10gegxz7]
Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)