understanding Tables

I’m fairly new to Corona (and not much of a programmer), but I’ve already been able to outline a couple of cool projects and I’ve used several corona features, but I can’t wrap my mind around the tables. Does anyone know of a good tutorial that gives the user a clear understanding of tables? Arrays have always been difficult for me, but I want to do a project where two items show on the screen (from two different tables) and they are compared to each other. If they are in the same position in each table something happens.

Any resources would be appreciated.

Thanks [import]uid: 48122 topic_id: 8778 reply_id: 308778[/import]

each item can has its properties and you can add the items to a group. (a table, but we use the moniker group for easier reading).
local group1 = newGroup();
local gorup2 = newGroup();

create foo1 to fooN each foo has a name, color, position (xy) each foo is inserted into group1

create goo1 to gooN each goo has a name, color, position (xy) each goo is inserted into group2

traverse foo elements of group1 and traverse goo elements of gorup2

compare element foo from group1 to element goo from group2 if their x, y are in the same pos (or area) go kaBoom

c. [import]uid: 24 topic_id: 8778 reply_id: 32031[/import]

loop for each element in group1 and each element in group2

if group1[i].x eq group2[i].x and group1[i].y eq group2[i].x then do something

note: above is pseudocode.

c

[import]uid: 24 topic_id: 8778 reply_id: 32068[/import]

@supergeekhero

is this what you are after

local table1 = {1,2,3,4,5,6,7,8,9}  
local table2 = {1,3,4,5,2,6,9,8,7,0}  
local i  
  
for i=1,#table1 do  
 if (table1[i] == table2[i]) then  
 print ("Do something special, pull out the champagne for index " .. i)  
 end  
end  

cheers,

?:slight_smile: [import]uid: 3826 topic_id: 8778 reply_id: 32089[/import]

This is it! Thanks Jayantv! Now that I have a clear example of something I want to do I can get a better understanding of tables in general. Thanks for your replies everyone. [import]uid: 48122 topic_id: 8778 reply_id: 32091[/import]

SuperHeroGeek to the rescue… .oh way that was Jayant. [import]uid: 24 topic_id: 8778 reply_id: 32169[/import]

What do you mean by “If they are in the same position in each table something happens”?

– Advanced UI + Graph for Corona® | Website | Forum (https) | See: [import]uid: 11385 topic_id: 8778 reply_id: 32067[/import]