Managing a library of game objects

My game features a number of PNG images that the user can drag around. Each image has some meta data associated with it. For example, if you place Image A, 10 points are deducted. If you place Image B, 20 points are deducted.

I tried to set up an array, but Corona debug barks at me (something about processing a numeric change to a string).
[lua]local objects = {
“redBall” = {
“filename” => “redball.png”
“points” => 20
}
“greenBall” = {
“filename” => “greenball.png”
“points” => 10
}
}[/lua]

Questions: what’s wrong with my array structure? Is there a simple way to cycle through this type of structure, if I had a screen that showed them all the available objects?

Thank you! [import]uid: 85686 topic_id: 14277 reply_id: 314277[/import]

I don’t know if this will work for you but I’m using something similar to this:

local points = 0;  
local object = {};  
local currentObject = 1;  
   
object[1] = display.newimage( "redball.png" );  
object[1].myName "redball"  
object[1].points = 20;   
object[1].isVisible = false;   
  
object[2] = display.newimage( "greenball.png" );  
object[2].myName "greenball"  
object[2].points = 10;   
object[2].isVisible = false;   
  
local function cycleObjects()  
 object[currentObject].isVisible = false;  
 currentObject = (currentObject + 1);  
 level[currentObject].isVisible = true;  
end  
  

Haven’t tested this so might be a few errors. [import]uid: 68741 topic_id: 14277 reply_id: 52685[/import]

Unfortunately, that code doesn’t work… I tried just the actual array object and my app crashes. Anyone have ideas? [import]uid: 85686 topic_id: 14277 reply_id: 52765[/import]

it may be because you are trying to compare a numeric value with a string. look at the error message one more time and see whether you can find something… if you suspect any code just try using tonumber(value) for the value u suspect is a string.
[import]uid: 71210 topic_id: 14277 reply_id: 52802[/import]