Can anyone tell me what this mean?

file: bad argument #1 to ‘find’ (string expected, got table)

Bad argument #1 to ‘find’ (string expected, got table)

stack traceback:

    [C]: ?

    [C]: in function ‘error’

   ?: in function ‘gotoScene’

/Users/babybeanie98/Desktop/FM2/Scene1.lua:25: in function ‘_onRelease’

    ?: in function ‘?’

    ?: in function <?:1052>

    ?: in function <?:218>

 

I can not see anything wrong with my code. 

 

 

– forward declarations and other locals

local playBtn 

– ‘onRelease’ event listener for playBtn

local function onPlayBtnRelease( Scene2 )

storyboard.gotoScene( Scene2 )

        return true     – indicates successful touch

end

Are you using string.find() somewhere in the code? Seems like it did not like the string you provided the string.find() function. Just a hunch. 

I think you’re right ksan,  you can get that if you do string:find() instead of string.find()

been there, done that! few times too many!  :slight_smile:

Thanks guys but that is not it. I did not use string:find() nowhere. I searched my whole folder.Any other ideas? I had all my code working until they changed and now certain things do not work. 

I’ve been tweeking it now I see this?

File: ?

Attempt to index field ‘labels’ (a nil value)

So in a nut shell when I “Scene2” I get Bad argument #1 to ‘find’ (string expected, got table)

and when I remove that “” I get Attempt to index field ‘labels’ (a nil value) so lost right now. 

The problem is that your function:

local function onPlayBtnRelease( Scene2 )

receives a table as it’s parameter.  You are saying you want to call that table “Scene2”.  By most programmers convention, since that table contains information about the event, they tend to name it “event” or “e” for short.  But like all programming languages you can name your function parameters anything you like.  So you named this Scene2 and it is a table.

The storyboard.gotoScene() functions expects it’s first parameter to be a string, which is the scene name (the name of the scene file with out the .lua on it) and not a table.

storyboard.gotoScene( Scene2 )

Perhaps you should consider re-writing this to do (assuming you’re doing a “tap” event and not a “touch” event)

local function onPlayButtonRelease( event ) &nbsp;&nbsp;&nbsp; -- don't really need to use event in most tap handlers &nbsp;&nbsp;&nbsp; storyboard.gotoScene("Scene2") -- assumes you have a file named "Scene2.lua" and case matters!!!!! &nbsp;&nbsp;&nbsp; return true end

Are you using string.find() somewhere in the code? Seems like it did not like the string you provided the string.find() function. Just a hunch. 

I think you’re right ksan,  you can get that if you do string:find() instead of string.find()

been there, done that! few times too many!  :slight_smile:

Thanks guys but that is not it. I did not use string:find() nowhere. I searched my whole folder.Any other ideas? I had all my code working until they changed and now certain things do not work. 

I’ve been tweeking it now I see this?

File: ?

Attempt to index field ‘labels’ (a nil value)

So in a nut shell when I “Scene2” I get Bad argument #1 to ‘find’ (string expected, got table)

and when I remove that “” I get Attempt to index field ‘labels’ (a nil value) so lost right now. 

The problem is that your function:

local function onPlayBtnRelease( Scene2 )

receives a table as it’s parameter.  You are saying you want to call that table “Scene2”.  By most programmers convention, since that table contains information about the event, they tend to name it “event” or “e” for short.  But like all programming languages you can name your function parameters anything you like.  So you named this Scene2 and it is a table.

The storyboard.gotoScene() functions expects it’s first parameter to be a string, which is the scene name (the name of the scene file with out the .lua on it) and not a table.

storyboard.gotoScene( Scene2 )

Perhaps you should consider re-writing this to do (assuming you’re doing a “tap” event and not a “touch” event)

local function onPlayButtonRelease( event ) &nbsp;&nbsp;&nbsp; -- don't really need to use event in most tap handlers &nbsp;&nbsp;&nbsp; storyboard.gotoScene("Scene2") -- assumes you have a file named "Scene2.lua" and case matters!!!!! &nbsp;&nbsp;&nbsp; return true end