Can't load any screens

I am getting an error when I execute main.lua off the bat. The codes are straight from a tutorial so I absolutely have no idea why it wouldn’t work. Using director 1.3 and Corona build 569.

Errors I am getting:

[blockcode]
Runtime error
/Users/admin/Desktop/SHARE/Star/director.lua:440: ERROR: table expected. If this is a function call, you might have used ‘.’ instead of ‘:’
stack traceback:
[C]: ?
[C]: in function ‘insert’
/Users/admin/Desktop/SHARE/Star/director.lua:440: in function ‘_listener’
?: in function <?:446>
?: in function <?:215>


Director ERROR: Failed to execute function: 0x5de130( params ) function on ‘menu’.

[/blockcode]
Here’s main.lua

local director = require("director")  
  
local mainGroup = display.newGroup()  
  
local main = function ()  
 -- add the group from director class  
 mainGroup:insert(director.directorView)  
  
 -- change scene without effects  
 -- open menu.lua file  
 director:changeScene("menu")  
 return true  
end  
  
main()  

Here’s menu.lua

[code]
module(…, package.seeall)

function new()

local localGroup = display.newGroup()

local background = display.newImageRect(“menu-bg.png”, 480, 320)
background.setReferencePoint(display.CenterReferencePoint)
background.x = 240
background.y = 160

local title = display.newImageRect(“title.png”, 300, 52)
title.setReferencePoint(display.CenterReferencePoint)
title.x = 240
title.y = 100

local play_btn = display.newImageRect(“play.png”, 80, 32)
play_btn.setReferencePoint(display.CenterReferencePoint)
play_btn.x = 240
play_btn.y = 150
play_btn.scene = “game”

local credits_btn = display.newImageRect(“credits.png”, 180, 68)
credits_btn.setReferencePoint(display.CenterReferencePoint)
credits_btn.x = 240
credits_btn.y = 200
credits_btn.scene = “credits”

– functions
function changeScene(e)
if(e.phase == “ended”) then
director:changeScene(e.target.scene)
end
end

localGroup:insert(background)
localGroup:insert(title)
localGroup:insert(play_btn)
localGroup:insert(credits_btn)

play_btn:addEventListener(“touch”, changeScene)
credits_btn:addEventListener(“touch”, changeScene)

return localGroup
end
[/code] [import]uid: 39031 topic_id: 12548 reply_id: 312548[/import]

Try changing like this

[lua] function changeScene(e)
if(e.phase == “ended”) then
target = e.target
local scene = target.scene
print("going to "…scene)
director:changeScene(scene)
end
end

play_btn:addEventListener(“touch”, changeScene)
credits_btn:addEventListener(“touch”, changeScene)[/lua] [import]uid: 71210 topic_id: 12548 reply_id: 45852[/import]

Sorry …
i think just the below change will do

[lua] play_btn:addEventListener(“touch”, changeScene)
credits_btn:addEventListener(“touch”, changeScene)[/lua] [import]uid: 71210 topic_id: 12548 reply_id: 45853[/import]

Thanks for the reply.
Actually, that was my mistake. I was playing around with the code and forgot to revert that back. (I updated the original post.)
The codes still don’t work after changing that back.
Same error. [import]uid: 39031 topic_id: 12548 reply_id: 45862[/import]

This is what I used to test your code… changed the buttons to text as I don’t have the images…
Just check whether this works…

[lua]module(…, package.seeall)

function new()
local localGroup = display.newGroup()

– local background = display.newImageRect(“menu-bg.png”, 480, 320)
– background.setReferencePoint(display.CenterReferencePoint)
– background.x = 240
– background.y = 160

– local title = display.newImageRect(“title.png”, 300, 52)
– title.setReferencePoint(display.CenterReferencePoint)
– title.x = 240
– title.y = 100

local play_btn = display.newText(“Play”, 80, 32, nil, 25)
– local play_btn = display.newImageRect(“play.png”, 80, 32)
– play_btn.setReferencePoint(display.CenterReferencePoint)
– play_btn.x = 240
– play_btn.y = 150
play_btn.scene = “game”

local credits_btn = display.newText(“credits”, 180, 68, nil, 25)
– local credits_btn = display.newImageRect(“credits.png”, 180, 68)
– credits_btn.setReferencePoint(display.CenterReferencePoint)
– credits_btn.x = 240
– credits_btn.y = 200
credits_btn.scene = “credits”

– functions
function changeScene(e)
target = e.target
local scene = target.scene
if(e.phase == “ended”) then
print("going to "…scene)
director:changeScene(scene)
end
end

–localGroup:insert(background)
– localGroup:insert(title)
localGroup:insert(play_btn)
localGroup:insert(credits_btn)

play_btn:addEventListener(“touch”, changeScene)
credits_btn:addEventListener(“touch”, changeScene)

return localGroup
end[/lua] [import]uid: 71210 topic_id: 12548 reply_id: 45863[/import]

Hey, technowand!
Your version works.
As soon as I uncomment an image, the error comes back though.
All files are in the same folder and I’ve confirmed all names. [import]uid: 39031 topic_id: 12548 reply_id: 45864[/import]

OK, I narrowed the problem down to this line.

object.setReferencePoint(display.CenterReferencePoint)

Am I not allowed to set custom reference points with director?

In any case, thanks for helping me keep my sanity, technowand :slight_smile: [import]uid: 39031 topic_id: 12548 reply_id: 45865[/import]

Try changing this
[lua]play_btn:setReferencePoint(display.CenterReferencePoint)
credits_btn:setReferencePoint(display.CenterReferencePoint)[/lua]

changed “.” to “:” [import]uid: 71210 topic_id: 12548 reply_id: 45866[/import]

You’re the MAN! (or WOMAN)
That worked. Thanks, technowand! [import]uid: 39031 topic_id: 12548 reply_id: 45867[/import]

:slight_smile:
You are welcome…
[import]uid: 71210 topic_id: 12548 reply_id: 45868[/import]