Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

Bad argument #1 to 'find' (string expected, got nil)
Started by ahmedmsomji Sep 26 2018 08:14 AM

6 replies to this topic
bad argument #1 to find (st bad argument #1

Best Answer nick_sherman , 26 September 2018 - 08:26 AM

game should be in double quotes.

[TOPIC CONTROLS]
This topic has been archived. This means that you cannot reply to this topic.
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

ahmedmsomji

[GLOBAL: userInfoPane.html]
ahmedmsomji
  • Observer

  • 12 posts
  • Corona SDK

Hey! i am kinda new to corona and "lua" code and i have taken the touorails but am confused as my code got this error and idk why 

 

of course i tried to search it up but couldent find a thing if u can plz help 

 

yes i am a newbie 

 

error: Bad argument #1 to 'find' (string expected, got nil)

 

 

code: 

local options = {
    effect = "fade",
    time = 800,
}

local button = display.newImage ("play_button.png")

button.x = 160
button.y = 330

button:scale( 5.0, 5.0)

function button:tap( event )
composer.gotoScene( game , options)
end

button:addEventListener( "tap", object )



[TOPIC: post.html]
#2

nick_sherman

[GLOBAL: userInfoPane.html]
nick_sherman
  • Corona Geek

  • 1,803 posts
  • Corona SDK

  Best Answer

game should be in double quotes.

[TOPIC: post.html]
#3

XeduR @Spyric

[GLOBAL: userInfoPane.html]
XeduR @Spyric
  • Contributor

  • 762 posts
  • Corona SDK

It's exactly as nick said. Corona's error messages are usually great at pointing out where the problem is and what causes the problem. In your case, the error message literally states that Corona expected the input to be in string format, i.e. "game".



[TOPIC: post.html]
#4

ahmedmsomji

[GLOBAL: userInfoPane.html]
ahmedmsomji
  • Observer

  • 12 posts
  • Corona SDK

game should be in double quotes.

i did that and am getting the following error   :mellow:

 

Attempt to concatenate global 'sceneName' (a nil value)

 

File: ?



[TOPIC: post.html]
#5

nick_sherman

[GLOBAL: userInfoPane.html]
nick_sherman
  • Corona Geek

  • 1,803 posts
  • Corona SDK

Do you have a composer scene called game.lua?

[TOPIC: post.html]
#6

ahmedmsomji

[GLOBAL: userInfoPane.html]
ahmedmsomji
  • Observer

  • 12 posts
  • Corona SDK

Do you have a composer scene called game.lua?

sry as i said i am a newbie so idk what u mean but i do have a file called game.lua 

 

but it is not linked in anyway to the composer



[TOPIC: post.html]
#7

XeduR @Spyric

[GLOBAL: userInfoPane.html]
XeduR @Spyric
  • Contributor

  • 762 posts
  • Corona SDK

When you are using composer to move from one scene to another, you need to include the necessary code in both files.

You can read about scene management at https://docs.coronalabs.com/guide/programming/04/index.html. You can also create a new project using the templates in Corona and you'll see how the code works there.




[topic_controls]
[/topic_controls]