Error help

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

What is line 82?

The fourth line is line 82.

My guess would be that on line 83 “asteroids1-1a.png” is wrong. Maybe the image is saved as “asteroid1-1a.png” or something different instead?

We don’t know what the name of the image file is, you tell us :slight_smile:

And is the image file located in the same directory as main.lua?

I think you’ve mistaken me for OP. :smiley:

Ah yes I did!  I guess you wouldn’t know then!  It’s too early in the morning for me to try to help others!

If there is a problem with file name, there will be a warning in the console log. My advice to anyone getting a run time error like this. Look in the console log.

What is line 82?

The fourth line is line 82.

My guess would be that on line 83 “asteroids1-1a.png” is wrong. Maybe the image is saved as “asteroid1-1a.png” or something different instead?

We don’t know what the name of the image file is, you tell us :slight_smile:

And is the image file located in the same directory as main.lua?

I think you’ve mistaken me for OP. :smiley:

Ah yes I did!  I guess you wouldn’t know then!  It’s too early in the morning for me to try to help others!

If there is a problem with file name, there will be a warning in the console log. My advice to anyone getting a run time error like this. Look in the console log.