Issues with indexing

I am spawning 4 tiles randomly in my game with code below. It works fine, what I am trying to do is the following:

Tile 1 - 4 I want to assign a value too. For example. number_1_tile[1] = 1, number_1_tile[2] = 2, etc… How do I do that?

When I test collision with number_1_tile[n], it only check it with I’m guessing the first tile spawned while the other 3 has no effect. How do I make sure if I drag anyone of the spawned tiles between 1 and 4 that they all check for collision. It’s only on one tile. Like a master tile or something.

Maybe the question i need to ask is: How do I access all the elements in an index “local number_1_tile = {}”?

Any help is appreciated. Thanks

[code]


local number_1_tile = {}
local n = 0
local function number_1_T ()
for i = 1, 4 do
n = n + 1
number_1_tile[n] = display.newImage(“images/number_1_tile.png”, true)
number_1_tile[n].x = math.random(80, 680)
number_1_tile[n].y = math.random(80, 980)
physics.addBody(number_1_tile[n], tilePhysics)
number_1_tile[n]:addEventListener(“touch”, dragBody)

tileGroups:insert(number_1_tile[n])
number_1_tile[n].name = “number_1_tile”
number_1_tile[1].alpha = .2

end
end

number_1_T()

[/code] [import]uid: 53149 topic_id: 13018 reply_id: 313018[/import]