Objects suddenly stopped being objects (attempt to index upvalue)?

Hi all!

So it’s only been yesterday when I posted my first question, sure hope I won’t have to bombard the forum daily. But I’ve got this very weird problem with absolutely zero clue about what went wrong, since this code worked perfectly yesterday, and I only altered it a bit in absolutely different part!

what%2Bthe%2Bhell.jpg

So here I am setting up the UI icons:

local map local tower1ghost local tower2ghost local tower3ghost function scene:create( event ) local sceneGroup = self.view local mapData = json.decodeFile(system.pathForFile("tiles/map1.json", system.ResourceDirectory)) map = tiled.new(mapData, "tiles") local background = display.newImageRect(sceneGroup, "bg\_menu.png", 800, 1400) local tower1icon = display.newImageRect(uiLayer, objectSheet, 1, 40, 40) tower1icon.x = 25 tower1icon.y = 480 tower1ghost = display.newImageRect(uiLayer, objectSheet, 1, 40, 40) tower1ghost.alpha = 0.5 tower1ghost.num = 1 tower1ghost:addEventListener("touch", dragGhost)

And so it goes for every tower icon and ‘ghost’, nothing too complicated. Again, the code worked perfectly yesterday. But today, as I run it, i get:

game.lua:117: attempt to index upvalue 'tower1icon' (a nil value)

Sooo… It’s okay when I slap an image on this object, but I can’t set it’s coordinates? I have zero clue about what’s going on: everything seems to be fine with the scope and the variable has been declared. The only thing I did today is implemented PonyTiled, but even when I comment out it’s code, nothing works anyway! Any ideas or at least clues?

That seems to be telling you the tower1icon doesn’t exist which means there was problem during its creation.

Where do you create objectSheet? Is it in scope? Does it definitely have an image at index = 1? Is uiLayer a display group and in scope?

Hi Nick, thanks for your reply! I’ve figured out what the problem is as I was typing you a reply. All of the appropriate elements were in scope, the problem was that the image with the graphics wasn’t in the folder anymore. It looks like I have accidentally deleted it as I was moving the files around in the folder while installing tile renderers! Thanks a ton for your suggestion, I would’ve never thought of looking for it without your hint!

No problem. Dropbox has often come my rescue when a file gets deleted in between Github commits…

That seems to be telling you the tower1icon doesn’t exist which means there was problem during its creation.

Where do you create objectSheet? Is it in scope? Does it definitely have an image at index = 1? Is uiLayer a display group and in scope?

Hi Nick, thanks for your reply! I’ve figured out what the problem is as I was typing you a reply. All of the appropriate elements were in scope, the problem was that the image with the graphics wasn’t in the folder anymore. It looks like I have accidentally deleted it as I was moving the files around in the folder while installing tile renderers! Thanks a ton for your suggestion, I would’ve never thought of looking for it without your hint!

No problem. Dropbox has often come my rescue when a file gets deleted in between Github commits…