Storyboard problem or is it my error?

I am playing with Corona SDK trying to do a simple app with storyboards. I just updated to the latest build and now I am having an issue with gotoScene()

Here is the code line it is failing on, with a static scene name of “main_scene” which is correct. I can see it, and the filename is correct. What is CSDK trying to contcatenate onto the scene name?

storyboard.gotoScene(“main_scene”)

Lua Glider reported this error:

?:0: attempt to concatenate global ‘sceneName’ (a nil value)
message
stack traceback:
[C]: ?
?: in function ‘gotoScene’
…ren\documents\netbeansprojects\storyboard 2\main.lua:83: in main chunk

Here is what the simulator window shows:

Windows simulator build date: Feb 27 2013 @ 18:48:22

Copyright © 2009-2013 C o r o n a L a b s I n c .
Version: 2.0.0
Build: 2013.1038
Runtime error: ?:0: attempt to concatenate global ‘sceneName’ (a nil value)
stack traceback:
[C]: ?
?: in function ‘gotoScene’
…ren\documents\netbeansprojects\storyboard 2\main.lua:83: in main chunk

Copyright © 2009-2013 C o r o n a L a b s I n c .
Version: 2.0.0
Build: 2013.1038
Runtime error: ?:0: attempt to concatenate global ‘sceneName’ (a nil value) stack traceback:
[C]: ?
?: in function ‘gotoScene’
…ren\documents\netbeansprojects\storyboard 2\main.lua:83: in main chunk

Has anyone else had this problem or is it something I’ve done to anger the gods?

Thanks!
Stu
[import]uid: 99429 topic_id: 36523 reply_id: 336523[/import]

The most common reason for that error message is that it can’t find the scene itself, which is different than the filename. The target file (ie: main_scene) MUST have storyboard setup inside of it as well so that the scene object exists there too, otherwise it doesn’t exist for storyboard purposes. [import]uid: 41884 topic_id: 36523 reply_id: 144799[/import]

I wish it was that simple…

I see it on the lua glider folder list, I see it on windows explorer directory list.

I’ve tried it under the explorer, outside of lua glider on the simulator and same effect.

I’ve changed the name to a local variable and called it again, same effect.

I have changed the name to the name of another scene, scene1.lua and same effect.

I think I’ll back up to a last known good CSDK and try it again.

Thanks!
Stu [import]uid: 99429 topic_id: 36523 reply_id: 144802[/import]

can you post the code for the scene you are trying to go to? [import]uid: 199310 topic_id: 36523 reply_id: 144807[/import]

No, what I mean is that unless your scene file (the one you are going to!) contains:

[code]-- near the beginning!
local storyboard = require(“storyboard”)
local scene = storyboard.newScene() – this makes the scene

– you probably also want the basics, like scene:createScene() and so on…

– at the very end!
return scene – this sends the scene out to the rest of your app[/code]

It will not work. Just having a lua file doesn’t mean anything because without the scene code it will just appear to be a nil file. The fact that you’ve changed the filename and keep getting the same result pretty strongly points to either part of that code being missing, or some code error within the main_scene.lua file that is preventing return scene from operating. [import]uid: 41884 topic_id: 36523 reply_id: 144810[/import]

here is the code:

main.lua

  
local storyboard = require("storyboard") -- Support storyboards  
  
display.setStatusBar ( display.HiddenStatusBar ) -- hide top status bar  
  
local splash = display.newImage("L2T.png",0,0,true) -- put up splash screen image  
splash. alpha = 0  
  
transition.to(splash,{time=4000, alpha = 1}) -- fade in splash screen -- fade in splash screen  
  
storyboard.gotoScene("main\_scene1",{effect = "fade", time = 200,})  
  

and main_scene1

local storyboard = require( "storyboard" )  
local scene = storyboard.newScene() -- create scene object  
  
-- Import the widget library  
local widget = require( "widget" )  
-- local forward references should go here --  
-- define menu list items  
--  
local Menu = {  
 {  
 title = "Job Instruction",  
 color = {221,233,247,255},  
 purchased = true,  
 scene1 = "JI1.png",  
 scene2 = "JI2.png"  
 },  
 {  
 title = "Job Methods",  
 color = {207,234,179,255},  
 purchased = true,  
 scene1 = "JM1.png",  
 scene2 = "JM2.png"  
 },  
 {  
 title = "Job Relations",  
 color = {255,25,202,255},  
 purchased = true,  
 scene1 = "JR1.png",  
 scene2 = "JR2.png"  
 },  
 {  
 title = "Job Safety",  
 color = {221,233,247,255},  
 purchased = false,  
 scene1 = "JS1.png",  
 scene2 = "JS2.png"  
 },  
 {  
 title = "Job Coaching",  
 color = {221,233,247,255},  
 purchased = false,  
 scene1 = "JS1.png",  
 scene2 = "JS2.png"  
 },  
 {  
 title = "Function X",  
 color = {221,233,247,255},  
 purchased = false  
 },  
 {  
 title = "Function Y",  
 color = {221,233,247,255},  
 purchased = false  
 },  
 {  
 title = "Function Z",  
 color = {221,233,247,255},  
 purchased = false  
 },  
 {  
 title = "Settings",  
 color = {221,233,247,255},  
 purchased = true  
 }  
  
}  
-- Called when the scene's view does not exist:  
function scene:createScene( event )  
 local group = self.view -- create a group for everything in the scene  
  
 local bg1 = display.newImage("BG.png", 0, 0) -- put up background screen image up  
 bg1. alpha = 0  
 transition.to(bg1,{time=2000, alpha = 1}) -- fade in background screen which will remove the text and images from splash screen  
 group:insert(bg1)  
  
 --The gradient used by the title bar  
 local titleGradient = graphics.newGradient(   
 { 255, 255, 255, 255 },   
 { 139, 157, 180, 255 },   
 "down" )  
  
 -- Create toolbar to go at the top of the screen  
 local titleBar = display.newRect( 0, 0, display.contentWidth, 32 )  
 titleBar.y = display.statusBarHeight + ( titleBar.contentHeight \* 0.5 )  
 titleBar:setFillColor( titleGradient )  
 titleBar.y = display.screenOriginY + titleBar.contentHeight \* 0.5  
 group:insert(titleBar)  
  
 -- create embossed text to go on toolbar  
 local titleText = display.newEmbossedText( "Learning 2 Think", 0, 0, native.systemFontBold, 20 )  
 titleText:setReferencePoint( display.CenterReferencePoint )  
 titleText:setTextColor( 255 )  
 titleText.x = 160  
 titleText.y = titleBar.y  
 group:insert(titleText)  
  
 -- Create a tableView  
 list = widget.newTableView   
 {  
 top = 38,  
 width = 320,   
 height = 448,  
 hideBackground = true,  
 maskFile = "mask-320x448.png",  
 onRowRender = onRowRender,  
 onRowTouch = onRowTouch,  
 }  
 group:insert(list)  
  
 -- insert rows into list (tableView widget)  
 for i = 1, #Menu do  
 list:insertRow{  
 height = 50,  
 rowColor = { 255, 255, 255, 0 },  
 onRender = onRowRender,  
 listener = onRowTouch  
 }  
 end  
  
end  
-- Called immediately after scene has moved onscreen:  
function scene:enterScene( event )  
 local group = self.view  
  
 -- INSERT code here (e.g. start timers, load audio, start listeners, etc.)  
  
end  
  

I had the storyboard code after the definition of the menu table but moved the defs to the top

No difference to how it works.

Thanks!
Stu [import]uid: 99429 topic_id: 36523 reply_id: 144819[/import]

There’s no return scene at the very end of the file? Or did your copy/paste just miss that?

EDIT: There’s also no binding calls to add the functions

 scene:addEventListener( "createScene", scene )

[import]uid: 41884 topic_id: 36523 reply_id: 144820[/import]

Thanks for finding my errors! This is my first attempt and in attempting to isolate the problems, only made it worse. The Corona error messages are often misleading (to me).

Thanks again!

Stu [import]uid: 99429 topic_id: 36523 reply_id: 144880[/import]

The most common reason for that error message is that it can’t find the scene itself, which is different than the filename. The target file (ie: main_scene) MUST have storyboard setup inside of it as well so that the scene object exists there too, otherwise it doesn’t exist for storyboard purposes. [import]uid: 41884 topic_id: 36523 reply_id: 144799[/import]

I wish it was that simple…

I see it on the lua glider folder list, I see it on windows explorer directory list.

I’ve tried it under the explorer, outside of lua glider on the simulator and same effect.

I’ve changed the name to a local variable and called it again, same effect.

I have changed the name to the name of another scene, scene1.lua and same effect.

I think I’ll back up to a last known good CSDK and try it again.

Thanks!
Stu [import]uid: 99429 topic_id: 36523 reply_id: 144802[/import]

can you post the code for the scene you are trying to go to? [import]uid: 199310 topic_id: 36523 reply_id: 144807[/import]

No, what I mean is that unless your scene file (the one you are going to!) contains:

[code]-- near the beginning!
local storyboard = require(“storyboard”)
local scene = storyboard.newScene() – this makes the scene

– you probably also want the basics, like scene:createScene() and so on…

– at the very end!
return scene – this sends the scene out to the rest of your app[/code]

It will not work. Just having a lua file doesn’t mean anything because without the scene code it will just appear to be a nil file. The fact that you’ve changed the filename and keep getting the same result pretty strongly points to either part of that code being missing, or some code error within the main_scene.lua file that is preventing return scene from operating. [import]uid: 41884 topic_id: 36523 reply_id: 144810[/import]

here is the code:

main.lua

  
local storyboard = require("storyboard") -- Support storyboards  
  
display.setStatusBar ( display.HiddenStatusBar ) -- hide top status bar  
  
local splash = display.newImage("L2T.png",0,0,true) -- put up splash screen image  
splash. alpha = 0  
  
transition.to(splash,{time=4000, alpha = 1}) -- fade in splash screen -- fade in splash screen  
  
storyboard.gotoScene("main\_scene1",{effect = "fade", time = 200,})  
  

and main_scene1

local storyboard = require( "storyboard" )  
local scene = storyboard.newScene() -- create scene object  
  
-- Import the widget library  
local widget = require( "widget" )  
-- local forward references should go here --  
-- define menu list items  
--  
local Menu = {  
 {  
 title = "Job Instruction",  
 color = {221,233,247,255},  
 purchased = true,  
 scene1 = "JI1.png",  
 scene2 = "JI2.png"  
 },  
 {  
 title = "Job Methods",  
 color = {207,234,179,255},  
 purchased = true,  
 scene1 = "JM1.png",  
 scene2 = "JM2.png"  
 },  
 {  
 title = "Job Relations",  
 color = {255,25,202,255},  
 purchased = true,  
 scene1 = "JR1.png",  
 scene2 = "JR2.png"  
 },  
 {  
 title = "Job Safety",  
 color = {221,233,247,255},  
 purchased = false,  
 scene1 = "JS1.png",  
 scene2 = "JS2.png"  
 },  
 {  
 title = "Job Coaching",  
 color = {221,233,247,255},  
 purchased = false,  
 scene1 = "JS1.png",  
 scene2 = "JS2.png"  
 },  
 {  
 title = "Function X",  
 color = {221,233,247,255},  
 purchased = false  
 },  
 {  
 title = "Function Y",  
 color = {221,233,247,255},  
 purchased = false  
 },  
 {  
 title = "Function Z",  
 color = {221,233,247,255},  
 purchased = false  
 },  
 {  
 title = "Settings",  
 color = {221,233,247,255},  
 purchased = true  
 }  
  
}  
-- Called when the scene's view does not exist:  
function scene:createScene( event )  
 local group = self.view -- create a group for everything in the scene  
  
 local bg1 = display.newImage("BG.png", 0, 0) -- put up background screen image up  
 bg1. alpha = 0  
 transition.to(bg1,{time=2000, alpha = 1}) -- fade in background screen which will remove the text and images from splash screen  
 group:insert(bg1)  
  
 --The gradient used by the title bar  
 local titleGradient = graphics.newGradient(   
 { 255, 255, 255, 255 },   
 { 139, 157, 180, 255 },   
 "down" )  
  
 -- Create toolbar to go at the top of the screen  
 local titleBar = display.newRect( 0, 0, display.contentWidth, 32 )  
 titleBar.y = display.statusBarHeight + ( titleBar.contentHeight \* 0.5 )  
 titleBar:setFillColor( titleGradient )  
 titleBar.y = display.screenOriginY + titleBar.contentHeight \* 0.5  
 group:insert(titleBar)  
  
 -- create embossed text to go on toolbar  
 local titleText = display.newEmbossedText( "Learning 2 Think", 0, 0, native.systemFontBold, 20 )  
 titleText:setReferencePoint( display.CenterReferencePoint )  
 titleText:setTextColor( 255 )  
 titleText.x = 160  
 titleText.y = titleBar.y  
 group:insert(titleText)  
  
 -- Create a tableView  
 list = widget.newTableView   
 {  
 top = 38,  
 width = 320,   
 height = 448,  
 hideBackground = true,  
 maskFile = "mask-320x448.png",  
 onRowRender = onRowRender,  
 onRowTouch = onRowTouch,  
 }  
 group:insert(list)  
  
 -- insert rows into list (tableView widget)  
 for i = 1, #Menu do  
 list:insertRow{  
 height = 50,  
 rowColor = { 255, 255, 255, 0 },  
 onRender = onRowRender,  
 listener = onRowTouch  
 }  
 end  
  
end  
-- Called immediately after scene has moved onscreen:  
function scene:enterScene( event )  
 local group = self.view  
  
 -- INSERT code here (e.g. start timers, load audio, start listeners, etc.)  
  
end  
  

I had the storyboard code after the definition of the menu table but moved the defs to the top

No difference to how it works.

Thanks!
Stu [import]uid: 99429 topic_id: 36523 reply_id: 144819[/import]

There’s no return scene at the very end of the file? Or did your copy/paste just miss that?

EDIT: There’s also no binding calls to add the functions

 scene:addEventListener( "createScene", scene )

[import]uid: 41884 topic_id: 36523 reply_id: 144820[/import]

Thanks for finding my errors! This is my first attempt and in attempting to isolate the problems, only made it worse. The Corona error messages are often misleading (to me).

Thanks again!

Stu [import]uid: 99429 topic_id: 36523 reply_id: 144880[/import]

The most common reason for that error message is that it can’t find the scene itself, which is different than the filename. The target file (ie: main_scene) MUST have storyboard setup inside of it as well so that the scene object exists there too, otherwise it doesn’t exist for storyboard purposes. [import]uid: 41884 topic_id: 36523 reply_id: 144799[/import]

I wish it was that simple…

I see it on the lua glider folder list, I see it on windows explorer directory list.

I’ve tried it under the explorer, outside of lua glider on the simulator and same effect.

I’ve changed the name to a local variable and called it again, same effect.

I have changed the name to the name of another scene, scene1.lua and same effect.

I think I’ll back up to a last known good CSDK and try it again.

Thanks!
Stu [import]uid: 99429 topic_id: 36523 reply_id: 144802[/import]

can you post the code for the scene you are trying to go to? [import]uid: 199310 topic_id: 36523 reply_id: 144807[/import]

No, what I mean is that unless your scene file (the one you are going to!) contains:

[code]-- near the beginning!
local storyboard = require(“storyboard”)
local scene = storyboard.newScene() – this makes the scene

– you probably also want the basics, like scene:createScene() and so on…

– at the very end!
return scene – this sends the scene out to the rest of your app[/code]

It will not work. Just having a lua file doesn’t mean anything because without the scene code it will just appear to be a nil file. The fact that you’ve changed the filename and keep getting the same result pretty strongly points to either part of that code being missing, or some code error within the main_scene.lua file that is preventing return scene from operating. [import]uid: 41884 topic_id: 36523 reply_id: 144810[/import]

here is the code:

main.lua

  
local storyboard = require("storyboard") -- Support storyboards  
  
display.setStatusBar ( display.HiddenStatusBar ) -- hide top status bar  
  
local splash = display.newImage("L2T.png",0,0,true) -- put up splash screen image  
splash. alpha = 0  
  
transition.to(splash,{time=4000, alpha = 1}) -- fade in splash screen -- fade in splash screen  
  
storyboard.gotoScene("main\_scene1",{effect = "fade", time = 200,})  
  

and main_scene1

local storyboard = require( "storyboard" )  
local scene = storyboard.newScene() -- create scene object  
  
-- Import the widget library  
local widget = require( "widget" )  
-- local forward references should go here --  
-- define menu list items  
--  
local Menu = {  
 {  
 title = "Job Instruction",  
 color = {221,233,247,255},  
 purchased = true,  
 scene1 = "JI1.png",  
 scene2 = "JI2.png"  
 },  
 {  
 title = "Job Methods",  
 color = {207,234,179,255},  
 purchased = true,  
 scene1 = "JM1.png",  
 scene2 = "JM2.png"  
 },  
 {  
 title = "Job Relations",  
 color = {255,25,202,255},  
 purchased = true,  
 scene1 = "JR1.png",  
 scene2 = "JR2.png"  
 },  
 {  
 title = "Job Safety",  
 color = {221,233,247,255},  
 purchased = false,  
 scene1 = "JS1.png",  
 scene2 = "JS2.png"  
 },  
 {  
 title = "Job Coaching",  
 color = {221,233,247,255},  
 purchased = false,  
 scene1 = "JS1.png",  
 scene2 = "JS2.png"  
 },  
 {  
 title = "Function X",  
 color = {221,233,247,255},  
 purchased = false  
 },  
 {  
 title = "Function Y",  
 color = {221,233,247,255},  
 purchased = false  
 },  
 {  
 title = "Function Z",  
 color = {221,233,247,255},  
 purchased = false  
 },  
 {  
 title = "Settings",  
 color = {221,233,247,255},  
 purchased = true  
 }  
  
}  
-- Called when the scene's view does not exist:  
function scene:createScene( event )  
 local group = self.view -- create a group for everything in the scene  
  
 local bg1 = display.newImage("BG.png", 0, 0) -- put up background screen image up  
 bg1. alpha = 0  
 transition.to(bg1,{time=2000, alpha = 1}) -- fade in background screen which will remove the text and images from splash screen  
 group:insert(bg1)  
  
 --The gradient used by the title bar  
 local titleGradient = graphics.newGradient(   
 { 255, 255, 255, 255 },   
 { 139, 157, 180, 255 },   
 "down" )  
  
 -- Create toolbar to go at the top of the screen  
 local titleBar = display.newRect( 0, 0, display.contentWidth, 32 )  
 titleBar.y = display.statusBarHeight + ( titleBar.contentHeight \* 0.5 )  
 titleBar:setFillColor( titleGradient )  
 titleBar.y = display.screenOriginY + titleBar.contentHeight \* 0.5  
 group:insert(titleBar)  
  
 -- create embossed text to go on toolbar  
 local titleText = display.newEmbossedText( "Learning 2 Think", 0, 0, native.systemFontBold, 20 )  
 titleText:setReferencePoint( display.CenterReferencePoint )  
 titleText:setTextColor( 255 )  
 titleText.x = 160  
 titleText.y = titleBar.y  
 group:insert(titleText)  
  
 -- Create a tableView  
 list = widget.newTableView   
 {  
 top = 38,  
 width = 320,   
 height = 448,  
 hideBackground = true,  
 maskFile = "mask-320x448.png",  
 onRowRender = onRowRender,  
 onRowTouch = onRowTouch,  
 }  
 group:insert(list)  
  
 -- insert rows into list (tableView widget)  
 for i = 1, #Menu do  
 list:insertRow{  
 height = 50,  
 rowColor = { 255, 255, 255, 0 },  
 onRender = onRowRender,  
 listener = onRowTouch  
 }  
 end  
  
end  
-- Called immediately after scene has moved onscreen:  
function scene:enterScene( event )  
 local group = self.view  
  
 -- INSERT code here (e.g. start timers, load audio, start listeners, etc.)  
  
end  
  

I had the storyboard code after the definition of the menu table but moved the defs to the top

No difference to how it works.

Thanks!
Stu [import]uid: 99429 topic_id: 36523 reply_id: 144819[/import]