How do I find my corresponding array entry?

Get help using Construct 2

Post » Sat Dec 27, 2014 10:50 pm

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?
B
13
S
5
Posts: 218
Reputation: 1,721

Post » Sat Dec 27, 2014 10:51 pm

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
B
13
S
5
Posts: 218
Reputation: 1,721

Post » Sat Dec 27, 2014 11:23 pm

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.
Last edited by codah on Sat Dec 27, 2014 11:53 pm, edited 2 times in total.
B
24
S
9
G
4
Posts: 1,646
Reputation: 6,596

Post » Sat Dec 27, 2014 11:48 pm

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 :P seems to be working now, thanks!
B
13
S
5
Posts: 218
Reputation: 1,721

Post » Sat Dec 27, 2014 11:54 pm

facecrime wrote: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 :P 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:

Code: Select all
41, 45, 50, 53, 59, 62
0,  0,  1,  1,  2,  2
B
24
S
9
G
4
Posts: 1,646
Reputation: 6,596


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 13 guests