Error problem

This is giving me an Error in 82

main.lua:82: ERROR: table expected. If this is a function call, you might have used ‘.’ instead of ‘:’

Stack traceback:

  [C]: in function ‘addBody’

  main.lua:82: in function ‘loadAsteroid’

  main.lua:165: in function ‘_listener’

  ?: in function <?:167>

  ?:in function <?:221>

 Any Ideas?

 

local function loadAsteroid() numAsteroids= numAsteroids +1 asteroidsTable[numAsteroids] = display.newImage("asteroids1-1a.png") (82) physics.addBody(asteroidsTable[numAsteroids], {density=1,friction=0.4,bounce=1}) local whereFrom = math.random(3) asteroidsTable[numAsteroids].myName="asteroid" --Spawns if(whereFrom==1) then asteroidsTable[numAsteroids].x = -50 asteroidsTable[numAsteroids].y = (math.random( display.contentHeight \*.75)) transition.to(asteroidsTable[numAsteroids], {x= (display.contentWidth +100), y=(math.random( display.contentHeight)), time =(math.random( 5000, 10000))}) elseif(whereFrom==2) then asteroidsTable[numAsteroids].x = (math.random( display.contentWidth)) asteroidsTable[numAsteroids].y = -30 transition.to(asteroidsTable[numAsteroids], {x= (math.random(display.contentWidth)), y=(display.contentHeight + 100), time =(math.random(5000, 10000))}) elseif(whereFrom==3) then asteroidsTable[numAsteroids].x = display.contentWidth+50 asteroidsTable[numAsteroids].y = (math.random( display.contentHeight \*.75)) transition.to(asteroidsTable[numAsteroids], {x= -100, y=(math.random(display.contentHeight)), time =(math.random(5000, 10000))}) end end local function gameLoop() updateText() (165) loadAsteroid() --remove old shots fired so they don't stack for i = 1, table.getn(shotTable) do if (shotTable[i].myName ~= nil and shotTable[i].age \< maxShotAge) then shotTable[i].age = shotTable[i].age + tick elseif (shotTable[i].myName ~= nil) then shotTable[i]:removeSelf() shotTable[i].myName=nil end end end

It doesn’t look like your code goes to 165 or even 82 lines.

Re-post the full main.lua code and format it with line numbers so we can see better.

Are there additional messages in the device’s (or simulator’s) console log, like a warning that it couldn’t find asteroids1-1a.png?

That error likely means that asteroidsTable[numAsteroids] isn’t a valid display object.

Rob

It doesn’t look like your code goes to 165 or even 82 lines.

Re-post the full main.lua code and format it with line numbers so we can see better.

Are there additional messages in the device’s (or simulator’s) console log, like a warning that it couldn’t find asteroids1-1a.png?

That error likely means that asteroidsTable[numAsteroids] isn’t a valid display object.

Rob