After reading a lot of arrays posts and tutorials then i tried to make myself an example of what i understand.

What i want?? well i have 4 figures ( triangle, circle, square, rectangle ) , every 5 seconds i spawn new figures, i want to pickup the figures and save the number of pickups for each figure ( example i picked up a triangle 2 times, array must save number 2, if i pickup again another triangle array must add +1 ( total saved: 3 ) ).

I used families because i want to use a lot of different sprite objects, This is my logic:

Yes, i was bad in mathematics at the school, i tried to use my noob logic here.

1. on start of layout-> ok i used the ArrayCreator tool, i understand that i need this event each time that i want to use an array.

3. - For each player ( i think this is bad because i have only 1 player object on screen, maybe must be replaced for each figure object.)

- Player is overlapping figures -> Add 1 to collected (yes i know this is wrong because when figures are destroyed then the variable collected will be destroyed too) , why i don't used a global variable? because i want to save the number of collected figures for each figure (triangle, circle, square, rectangle), i don't understand what to do here.

4. For each XY element, contains value figures.whatIam ( i saved the name of each figure in WhatIam variable in each figure object so the array will know which figure you are picking ) --> set value at (Array.Curvalue, 1) to figures.collected ( here i tried to add the value of number of pickups to the array ) but the problem its that the variable collected its destroyed with the figures.

I used Y1 row: because in Y0 row i have the name of the figures, using the array creator tool i can see that under Y0 Row i have the Y1 row, my question is, the array read the data under Y0 Automatic? example like an excel spreadsheet, because i was thinking in 2D arrays like an excel spreedsheet, example i put in X0, Y1 the number 5 then the array will know that number 5 its the number of triangles because triangle word its in X0,Y0 position, then too the array will know that all values under X0 in all Y positions are secondary values of the Y0 cell?.

3. you can delete the "for each player" condition, the other is enough

4. at first, I don't understand why your array is 4*4*1, an array of 4*2*1 is enough if you need only to store the name and the number of pickups. But it's not a big deal...

The variable "collected" is useless, you should put a variable "num_id" instead, to store the column corresponding in the array (0 for triangle, 1 for circle...).

Instead of "for each XY element", you should put :

for each X element :

Array : Value.at(Array.CurX , 0) = figures.whatlam ==> Array : set Value.at(Array.CurX , figures.num_id) to Array.at(Array.CurX , num_id) + 1

blue is condition, red is action

I hope you understood, I can't upload a capx. Tell me if you have questions or if it's not working

[edit] you shouldn't bump your topic to fast, personally, I answer at first to topics that haven't any answers.

Thank you for helping me, the array didn't save the triangle and save in the wrong Y position, my array is 4,4,1 because i want to store other different data.

Thank so much for helping me, works perfectly, maybe this is a stupid question but i am curious why you cant use X = 0 instead of Array.CurX? cur is for current position right? since a lot of days i am reading several times the manual ( https://www.scirra.com/manual/108/array ) to understand the arrays.

i am trying to understand your solution:

For each X element

- Array.CurX,0 = figures.whatIam// ( the array will find the variable whatIam values in the current X position "X0??", Y0, if i want to find a value in X1 then i don't need use CurX? because CurX everytime its the X0 position? why you dont use curY? )

--> action: set value at X: Array.CurX, Y: 1 , value = Array.At(Array.CurX,1) + 1 ( at its for retrieve the value of CurX, Y1 ) now i understand this.

in the manual says:

CurX

CurY

CurZ

The current zero-based index for each dimension in a For each element loop.

then CurX = X0 , CurY = Y0 ? maybe i am wrong and Cur isn't means current position, its just the 0 value of X,Y and Z, index its each cell.

Arrays are indexed by numbers. CurX is just whatever the current number is in the For loop, for the X dimension.

So if we have a single dimension array, for the moment, your array would be:

CurX=0 -> Array(0) -> "triangle"

CurX=1 -> Array(1) -> "circle"

CurX=2 -> Array(2) -> "square"

CurX=3 -> Array(3) -> "rectangle"

"For each X element" is just setting the value of CurX to those numbers for you. If we introduce two dimensions, then we need to start adding the Y index to get at the appropriate data. Y=0 is our name.

CurX=0 -> Array(0,0) -> "triangle"

CurX=1 -> Array(1,0) -> "circle"

CurX=2 -> Array(2,0) -> "square"

CurX=3 -> Array(3,0) -> "rectangle"

Y=1 is our count (assuming some random values for the moment).

Arrays are indexed by numbers. CurX is just whatever the current number is in the For loop, for the X dimension.

So if we have a single dimension array, for the moment, your array would be:

CurX=0 -> Array(0) -> "triangle"

CurX=1 -> Array(1) -> "circle"

CurX=2 -> Array(2) -> "square"

CurX=3 -> Array(3) -> "rectangle"

"For each X element" is just setting the value of CurX to those numbers for you. If we introduce two dimensions, then we need to start adding the Y index to get at the appropriate data. Y=0 is our name.

CurX=0 -> Array(0,0) -> "triangle"

CurX=1 -> Array(1,0) -> "circle"

CurX=2 -> Array(2,0) -> "square"

CurX=3 -> Array(3,0) -> "rectangle"

Y=1 is our count (assuming some random values for the moment).

CurX=0 -> Array(0,1) -> 3

CurX=1 -> Array(1,1) -> 7

CurX=2 -> Array(2,1) -> 4

CurX=3 -> Array(3,1) -> 0

Does that help any?

Then CurX its to check all X values, you used Y=0 because we only have 1 Y row, if you want to check more Y rows then you need to use CurY, Right? i understand now, thank you!

No. You want to index Y directly, to specify the correct column. Y=0 is your shape name, Y=1 is the count, Y=2 is (I made this up) colour, Y=3 is some other number. If you are trying to search in X for your shape, you only use "For each X element" to generate CurX values. CurY will not be set. CurY would only be set if you use "For each XY element", but that won't help you at all here. You are only searching in X for the name, to get the correct X value. Once you have X (stored in CurX), you can address any of those shape's data columns directly.

No. You want to index Y directly, to specify the correct column. Y=0 is your shape name, Y=1 is the count, Y=2 is (I made this up) colour, Y=3 is some other number. If you are trying to search in X for your shape, you only use "For each X element" to generate CurX values. CurY will not be set. CurY would only be set if you use "For each XY element", but that won't help you at all here. You are only searching in X for the name, to get the correct X value. Once you have X (stored in CurX), you can address any of those shape's data columns directly.

thanks for this good explanation, now i understand even more the arrays!