expected near error

I’m trying to test out this level but am having trouble getting it to load. I am getting an error ) expected near , in this line of code

local spawnPlayerObject(xPlayerSpawn, yPlayerSpawn, richTurn)

I am trying to use director class for level transitions and such as well. any help would be great. Thank you [import]uid: 94237 topic_id: 17316 reply_id: 317316[/import]

Are you trying to declare a function, then use this syntax:

local function spawnPlayerObject(xPlayerSpawn, yPlayerSpawn, richTurn)
end
Check this article to understand functions:

http://developer.anscamobile.com/content/events-and-listeners#Function_vs_Table_Listeners

Hope this helps. [import]uid: 84539 topic_id: 17316 reply_id: 65480[/import]

Thanks that fixed that part, but now its saying table expected on

localGroup:insert(background)

heres the whole thing

function new()
localGroup = display.newGroup()

local background = display.newImage(‘1_0.png’, true)
localGroup:insert(background)

thanks again [import]uid: 94237 topic_id: 17316 reply_id: 65483[/import]

it seems like its not recognizing the localGroup or something along those lines [import]uid: 94237 topic_id: 17316 reply_id: 65514[/import]

Could you post the complete code… Difficult to make out the issue with posted code snippet

cheers,
Bejoy [import]uid: 84539 topic_id: 17316 reply_id: 65517[/import]

ok sure

module(…, package.seeall)

–local background = display.newImage(“1_0.png”, true)
Sturret = require(“Sturret”)
local Sturret
local spawnLevelEnd
local spawnPlayerObject
–require(“Rich”)
local levelComplete = false
local playerDir = 0
playerSpawnX = 0
playerSpawnY = 0
leveltime = {}
leveltime[1] = 30
dotting = false
local canDraw = true
arrowsLeft = 8
drawnLines = 0
posCount = 1
local fireTime = 0
currentLevel = 1
local playerSpeed = 0
local player
local rich
local richDir = 0
require “sprite”
local richSheet1 = sprite.newSpriteSheet(“richClimb1.png”,216,360)
local localgroup
function new()
localGroup = display.newGroup()

local background = display.newImage(‘1_0.png’, true)
localGroup:insert(background)

–function levelZeroLoad()
–bakground image PLACEHOLDER
–print((_W/320), _H/480)
–background = display.newImage( “1_0.png”, true)
–background.x = 0*_W/320+_W/2
–background.y = 0*_H/480+_H/2
–background:scale(display.contentWidth/320, display.contentHeight/480)
–background:setReferencePoint(display.TopLeftReferencePoint)
–background:toBack()
–localGroup:insert(background)

–spawn Player X and Y coords

local function spawnPlayerObject(xPlayerSpawn, yPlayerSpawn, richTurn)
local richPlayer = sprite.newSpriteSet(richSheet1,1,6)
sprite.add(richPlayer, “rich”, 2,5,500,1)
rich = sprite.newSprite(richPlayer)
rich.x = xPlayerSpawn
rich.y = yPlayerSpawn
rich:scale(_W*0.0009, _W*0.0009) – scale is used to adjust the size of the object.
richDir = richTurn
rich.rotation = richDir
rich:prepare(“rich”)
rich:play()
physics.addBody( rich, { friction=1, radius = 15 } ) – needs a better physics body for collision detection.
localGroup:insert(spawnPlayerObject)
end
–level end location X and Y coords
local function spawnLevelEnd(xEndSpawn, yEndSpawn) – the end of level point code is here. what still needs to be done is the loading of the next level on completion.
endLevel = display.newCircle( xEndSpawn, yEndSpawn, 10 )
physics.addBody( endLevel, “static”, { friction=1 } )

localGroup:insert(endLevel)

endLevel.scene = “1-1”
endLevel:addEventListener(“touch”, changeScene)
end
return localGroup
end

heres all the code in the file

[import]uid: 94237 topic_id: 17316 reply_id: 65518[/import]

Could you also post the error message. I do not see any error with localGroup declaration and insert method… [import]uid: 84539 topic_id: 17316 reply_id: 65523[/import]

it says ERROR:table expecte, if this is a function call you may have used . instead of : [import]uid: 94237 topic_id: 17316 reply_id: 65526[/import]

first remove line 11 and add local to line 10 [import]uid: 7911 topic_id: 17316 reply_id: 65535[/import]

line ten is commented out right now are you saying i should activate it and add local. I did do that and am now getting an error of syntax error near on the next active line of code [import]uid: 94237 topic_id: 17316 reply_id: 65537[/import]

sorry line numbers don’t line up on iphone

Sturret = require(“Sturret”) — add local here
local Sturret — remove this line
[import]uid: 7911 topic_id: 17316 reply_id: 65540[/import]

ok i did that but i’m still getting the syntax error [import]uid: 94237 topic_id: 17316 reply_id: 65541[/import]

i fixed it but I’m back to getting this error, ERROR:table expecte, if this is a function call you may have used . instead of : [import]uid: 94237 topic_id: 17316 reply_id: 65542[/import]

what line number is the error on [import]uid: 7911 topic_id: 17316 reply_id: 65544[/import]

it’s localGroup:insert which is 36 above
[import]uid: 94237 topic_id: 17316 reply_id: 65546[/import]

still looking at code but
take a look a spritegrabber in code exchange it makes dealing with spritesheets easier [import]uid: 7911 topic_id: 17316 reply_id: 65549[/import]

try moving local localGroup to under function new() [import]uid: 7911 topic_id: 17316 reply_id: 65550[/import]

the same error is appearing with that as well [import]uid: 94237 topic_id: 17316 reply_id: 65552[/import]

easier to read
[blockcode]

module(…, package.seeall)

–local background = display.newImage(“1_0.png”, true)

Sturret = require(“Sturret”)

local Sturret
local spawnLevelEnd
local spawnPlayerObject
–require(“Rich”)
local levelComplete = false
local playerDir = 0
playerSpawnX = 0
playerSpawnY = 0
leveltime = {}
leveltime[1] = 30
dotting = false
local canDraw = true
arrowsLeft = 8
drawnLines = 0
posCount = 1
local fireTime = 0
currentLevel = 1
local playerSpeed = 0
local player
local rich
local richDir = 0
require “sprite”
local richSheet1 = sprite.newSpriteSheet(“richClimb1.png”,216,360)
local localgroup

function new()
localGroup = display.newGroup()

local background = display.newImage(‘1_0.png’, true)
localGroup:insert(background)

–function levelZeroLoad()
–bakground image PLACEHOLDER
–print((_W/320), _H/480)
–background = display.newImage( “1_0.png”, true)
–background.x = 0*_W/320+_W/2
–background.y = 0*_H/480+_H/2
–background:scale(display.contentWidth/320, display.contentHeight/480)
–background:setReferencePoint(display.TopLeftReferencePoint)
–background:toBack()
–localGroup:insert(background)

–spawn Player X and Y coords

local function spawnPlayerObject(xPlayerSpawn, yPlayerSpawn, richTurn)
local richPlayer = sprite.newSpriteSet(richSheet1,1,6)
sprite.add(richPlayer, “rich”, 2,5,500,1)
rich = sprite.newSprite(richPlayer)
rich.x = xPlayerSpawn
rich.y = yPlayerSpawn
rich:scale(_W*0.0009, _W*0.0009) – scale is used to adjust the size of the object.
richDir = richTurn
rich.rotation = richDir
rich:prepare(“rich”)
rich:play()
physics.addBody( rich, { friction=1, radius = 15 } ) – needs a better physics body for collision detection.
localGroup:insert(spawnPlayerObject)
end

–level end location X and Y coords
local function spawnLevelEnd(xEndSpawn, yEndSpawn) – the end of level point code is here. what still needs to be done is the loading of the next level on completion.
endLevel = display.newCircle( xEndSpawn, yEndSpawn, 10 )
physics.addBody( endLevel, “static”, { friction=1 } )

localGroup:insert(endLevel)

endLevel.scene = “1-1”
endLevel:addEventListener(“touch”, changeScene)
end

return localGroup
end

[import]uid: 7911 topic_id: 17316 reply_id: 65532[/import]

in code above
line 30 delete
line 33 add local
line 63
should be localGroup:insert(rich)

[import]uid: 7911 topic_id: 17316 reply_id: 65578[/import]