tostring issue

What am i doing wrong here?:

[lua]currentLevel = 1

local level1 = display.newRect(0,0,50,50);

local function move()
levToMove = tostring(“level”…currentLevel)
print(levToMove) -------------------- transition.to(levToMove,{x=50, time=0})
end[/lua]

I want to move the object, but it’s not working. I am trying to do it this way so when the “currentLevel” increases the function will work with the next level too. [import]uid: 7850 topic_id: 8544 reply_id: 308544[/import]

because levToMove is a string not a reference to your object. there is no eval in lua. your print statement did not print properly it should have printed the table address of your rectangle object.

[lua]currentLevel = 1

local levels = {}
levels[1] = display.newRect(0,0,50,50);

local function move()
levToMove = levels[currentLevel]
– this prints the actual object table address now
print(levToMove)
transition.to(levToMove,{x=50, time=0})
end[/lua] [import]uid: 6645 topic_id: 8544 reply_id: 30662[/import]