Error

I keep getting an error that says

[lua]Runtime error
/Users/Mazensalih/Desktop/penguin/director.lua:615: attempt to index field ‘?’ (a boolean value)
stack traceback:
[C]: ?
/Users/Mazensalih/Desktop/penguin/director.lua:615: in function ‘loadScene’
/Users/Mazensalih/Desktop/penguin/director.lua:842: in function ‘loadNextScene’
/Users/Mazensalih/Desktop/penguin/director.lua:1017: in function ‘changeScene’
/Users/Mazensalih/Desktop/penguin/menu.lua:36: in function
?: in function <?:215>
My menu.lua codes are

[lua]module(…, package.seeall)

new = function ( params )


– Imports

local ui = require ( “ui” )


– Groups

local localGroup = display.newGroup()


– Display Objects

local background = display.newImage( “penguinbg.png” )
local title = display.newText( “Penguin Control”, 0, 0, native.systemFontBold, 32 )


– Image

local btParameters = display.newImage( “start.png” )


– Listener

local btParameterst = function ( event )
if event.phase == “ended” then
director:changeScene(“level1”)
end
end

local initVars = function ()


– Inserts

localGroup:insert( background )
localGroup:insert( title )


– Positions

title.x = 160
title.y = 20

btParameters.x = 240
btParameters.y = 250


– Colors

title:setTextColor( 255,255,255 )


– Listeners

btParameters:addEventListener ( “touch” , btParameterst )

end


– Initiate variables

initVars()


– MUST return a display.newGroup()

return localGroup

end
[import]uid: 132369 topic_id: 24251 reply_id: 324251[/import]

What version of Director are you using?

Usually this type of message is due to an error in the module that is being loaded (level1.lua).

Director 1.4 has nicer error messages, but you have to make sure to click away their dialog box and then look at the console.

[import]uid: 19626 topic_id: 24251 reply_id: 98023[/import]

I’m using director 1.4 , do you want to see my level1.lua ? [import]uid: 132369 topic_id: 24251 reply_id: 98030[/import]

That would be helpful.

[import]uid: 19626 topic_id: 24251 reply_id: 98039[/import]

[lua]local director = require( “director” )

– include Corona’s “physics” library
local physics = require “physics”
physics.start()

– forward declarations and other locals
local screenW, screenH, halfW = display.contentWidth, display.contentHeight, display.contentWidth*0.5

_W = display.contentWidth;
_H = display.contentHeight;

local physics = require “physics”
physics.start()
physics.setGravity(0, 2)

–Status Bar
display.setStatusBar(display.HiddenStatusBar)

local sky = display.newImage( “sky.png” )

local spawnTrue = true;
–physics.setDrawMode ( “hybrid” )
physics.setDrawMode ( “hybrid” )

local function spawnOrb()
if( spawnTrue == true )then
local randomPos = math.random ( 0, 480 )
orb = display.newImage( “orb.png” )
orb.x = randomPos
orb.y = -100
orb.myName = “orb”
physics.addBody(orb , “dynamic”, {isSensor = true, radius = 15})
end

end

timer.performWithDelay( 1500, spawnOrb, 500 )

local function onCollideObject(event)
if ( event.phase == “began” ) then
if event.object1.myName == “orb” and event.object2.myName == “penguin” then

event.object2:removeSelf()
event.object2 = nil

end
end
end

Runtime:addEventListener( “collision”, onCollideObject)

–Penguin

–Define wall graphics (rectangles)
local leftWall = display.newRect( 0, 0, 1, display.contentHeight )
local rightWall = display.newRect( display.contentWidth, 0, 1, display.contentHeight )

–Turn wall graphics into physical bodies
physics.addBody(leftWall, “static”, { bounce = 0.1} )
physics.addBody(rightWall, “static”, { bounce = 0.1} )

local score = display.newText(“Score: 0”, 40, 5)
score:setTextColor(0, 0, 0)
score.rotation = 0
score.size = 28

scoreCtr = 0
local lastGoalTime = 1000

scoreCtr = 0
local lastGoalTime = 1000

local grass = display.newImage( “grass.png” )
grass.y = 480

local penguin = display.newImage(“penguin.png”)
penguin.x = 240
penguin.y = 225
physics.addBody(penguin, “static”,{radius=45})


– ARROWS –

local left = display.newImage (“leftx.png”)
left.x = 30
left.y = 260

local right = display.newImage (“rightx.png”)
right.x = 110
right.y = 260

– Puts in all four movement arrow images and positions them


– MOVE PEACH –

local motionx = 0
local speed = 10
– Speed can be adjusted here to easily change how fast my picture moves. Very convenient!

local function stop (event)
if event.phase ==“ended” then

motionx = 0
end
end

Runtime:addEventListener(“touch”, stop )
– When no arrow is pushed, this will stop me from moving.

local function movepenguin (event)
penguin.x = penguin.x + motionx
end

Runtime:addEventListener(“enterFrame”, movepenguin)
– When an arrow is pushed, this will make me move.

function left:touch()
motionx = -speed
end
left:addEventListener(“touch”,left)

function right:touch()
motionx = speed
end
right:addEventListener(“touch”,right)

– The above four functions are stating the arrows should all listen for touches and defining
– the way I should move based on each touch.
local function wrap (event)

if penguin.x < 50 then
penguin.x = 50
end

if penguin.x > 430 then
penguin.x = 430
end

if speed < 0 then
speed = 0
end
end

Runtime:addEventListener(“enterFrame”, wrap)

score = require (“score”)

local border = 5

local scoreInfo = score.getInfo()

score.init({
x = 160,
y = 130}
)
score.setScore(0)

local function addtoit (event)
score.setScore (score.getScore()+2)
end
timer1 = timer.performWithDelay(1000,addtoit,0)

timer.cancel (timer1)

score.getScore()

score = score.getScore()
print (score)
[import]uid: 132369 topic_id: 24251 reply_id: 98055[/import]

Any luck ? [import]uid: 132369 topic_id: 24251 reply_id: 98297[/import]

i don’t see anything obvious. Are there any other message in the console log before or after the one you posted above?

Make sure to dismiss the error dialog before looking. Director doesn’t write the other error out until after that dialog is gone.
[import]uid: 19626 topic_id: 24251 reply_id: 98302[/import]

Thanks for replying. Well after i click start on my menu, it goes to the game and the terminal says this,
[lua]Runtime error
/Users/Mazensalih/Desktop/penguin/director.lua:615: attempt to index field ‘?’ (a boolean value)
stack traceback:
[C]: ?
/Users/Mazensalih/Desktop/penguin/director.lua:615: in function ‘loadScene’
/Users/Mazensalih/Desktop/penguin/director.lua:842: in function ‘loadNextScene’
/Users/Mazensalih/Desktop/penguin/director.lua:1017: in function ‘changeScene’
/Users/Mazensalih/Desktop/penguin/menu.lua:36: in function
?: in function <?:215>
[import]uid: 132369 topic_id: 24251 reply_id: 98304[/import]

That is the same message as above. Is there nothing above or below it?

Like a warning that it couldn’t find an image or anything like that?
[import]uid: 19626 topic_id: 24251 reply_id: 98324[/import]

No. It works perfectly fine on main.lua without the menu. But I don’t know if it’s something with the codes. How do i dismiss the error dialog like you said before on your previous comment
[import]uid: 132369 topic_id: 24251 reply_id: 98331[/import]

Director errors often occur due to one of two reasons:

  1. Case sensitivity. eg. Orb.png vs orb.png
  2. Missing files. eg. orb.png not being in the same directory as the lua files. [import]uid: 10389 topic_id: 24251 reply_id: 99696[/import]