can I use Tables and Forloops for object paramaters

I need to access both wall and wall1 so I only have to type the x position or anyother parameter once

it breaks on line 48 and 49 because I am trying to access a string value. Is there a way to extract the names from the string and assign it to a different variable? Thanks for any feedback!

 wall = display.newImageRect(walls,"redWall.png",W1\*1,H1\*2.2) wall1 = display.newImageRect(walls,"redWall.png",W1\*1,H1\*2.2) function wussup() obs = {"wall","wall1"} for cycle=1,2 do object = (obs[cycle]) print(object) 48 object.x = W1\*0.5 49 object.y = H1\*0.75 end end wussup()

Why not do this:

    wall = display.newImageRect(walls,"redWall.png",W1\*1,H1\*2.2)     wall1 = display.newImageRect(walls,"redWall.png",W1\*1,H1\*2.2)     function wussup()     obs = { wall, wall1 }      for cycle=1,2 do      object = (obs[cycle]) print(object)      object.x = W1\*0.5  object.y = H1\*0.75 end     end          wussup()

Instead of trying to reference them by a string, just assign the object itself directly to the array.  Better yet this:

    obs = {}     obs[1] = display.newImageRect(walls,"redWall.png",W1\*1,H1\*2.2)     obs[2] = display.newImageRect(walls,"redWall.png",W1\*1,H1\*2.2)     function wussup()      for cycle=1,2 do      object = (obs[cycle]) print(object)      object.x = W1\*0.5  object.y = H1\*0.75 end     end          wussup()

Thanks, works great!

Why not do this:

    wall = display.newImageRect(walls,"redWall.png",W1\*1,H1\*2.2)     wall1 = display.newImageRect(walls,"redWall.png",W1\*1,H1\*2.2)     function wussup()     obs = { wall, wall1 }      for cycle=1,2 do      object = (obs[cycle]) print(object)      object.x = W1\*0.5  object.y = H1\*0.75 end     end          wussup()

Instead of trying to reference them by a string, just assign the object itself directly to the array.  Better yet this:

    obs = {}     obs[1] = display.newImageRect(walls,"redWall.png",W1\*1,H1\*2.2)     obs[2] = display.newImageRect(walls,"redWall.png",W1\*1,H1\*2.2)     function wussup()      for cycle=1,2 do      object = (obs[cycle]) print(object)      object.x = W1\*0.5  object.y = H1\*0.75 end     end          wussup()

Thanks, works great!