Play button is not working.

I am making a restart screen and I get this error:

Windows simulator build date: May 27 2015 @ 18:15:50

Copyright © 2009-2015  C o r o n a   L a b s   I n c .
        Version: 3.0.0
        Build: 2015.2646
Platform: SM-G900S / x64 / 6.2 / Intel® HD Graphics / 4.0.0 - Build 10.18.10.3
408 / 2015.2646
Loading project from:   c:\users\true\documents\corona projects\bouncy blocks
Project sandbox folder: C:\Users\True\AppData\Roaming\Corona Labs\Corona Simulat
or\Sandbox\bouncy blocks-C116AB3B868BE13E671AF11DFB4D395F\Documents
WARNING: display.setStatusBarMode() not supported in the simulator for SM-G900S
device

Copyright © 2009-2015  C o r o n a   L a b s   I n c .
        Version: 3.0.0
        Build: 2015.2646
Platform: SM-G900S / x64 / 6.2 / Intel® HD Graphics / 4.0.0 - Build 10.18.10.3
408 / 2015.2646
Loading project from:   c:\users\true\documents\corona projects\bouncy blocks
Project sandbox folder: C:\Users\True\AppData\Roaming\Corona Labs\Corona Simulat
or\Sandbox\bouncy blocks-C116AB3B868BE13E671AF11DFB4D395F\Documents
WARNING: display.setStatusBarMode() not supported in the simulator for SM-G900S
device
Runtime error
error loading module ‘restart’ from file ‘c:\users\true\documents\corona project
s\bouncy blocks\restart.lua’:
        c:\users\true\documents\corona projects\bouncy blocks\restart.lua:51: ‘e
nd’ expected (to close ‘if’ at line 40) near ‘<eof>’
stack traceback:
        [C]: in function ‘error’
        ?: in function ‘gotoScene’
        c:\users\true\documents\corona projects\bouncy blocks\level1.lua:136: in
 function ‘_listener’
        ?: in function <?:141>
        ?: in function <?:221>

Copyright © 2009-2015  C o r o n a   L a b s   I n c .
        Version: 3.0.0
        Build: 2015.2646
Platform: SM-G900S / x64 / 6.2 / Intel® HD Graphics / 4.0.0 - Build 10.18.10.3
408 / 2015.2646
Loading project from:   c:\users\true\documents\corona projects\bouncy blocks
Project sandbox folder: C:\Users\True\AppData\Roaming\Corona Labs\Corona Simulat
or\Sandbox\bouncy blocks-C116AB3B868BE13E671AF11DFB4D395F\Documents
WARNING: display.setStatusBarMode() not supported in the simulator for SM-G900S
device
Runtime error
error loading module ‘restart’ from file ‘c:\users\true\documents\corona project
s\bouncy blocks\restart.lua’:
        c:\users\true\documents\corona projects\bouncy blocks\restart.lua:52: ‘e
nd’ expected (to close ‘function’ at line 35) near ‘<eof>’
stack traceback:
        [C]: in function ‘error’
        ?: in function ‘gotoScene’
        c:\users\true\documents\corona projects\bouncy blocks\level1.lua:136: in
 function ‘_listener’
        ?: in function <?:141>
        ?: in function <?:221>

Copyright © 2009-2015  C o r o n a   L a b s   I n c .
        Version: 3.0.0
        Build: 2015.2646
Platform: SM-G900S / x64 / 6.2 / Intel® HD Graphics / 4.0.0 - Build 10.18.10.3
408 / 2015.2646
Loading project from:   c:\users\true\documents\corona projects\bouncy blocks
Project sandbox folder: C:\Users\True\AppData\Roaming\Corona Labs\Corona Simulat
or\Sandbox\bouncy blocks-C116AB3B868BE13E671AF11DFB4D395F\Documents
WARNING: display.setStatusBarMode() not supported in the simulator for SM-G900S
device
Runtime error
error loading module ‘restart’ from file ‘c:\users\true\documents\corona project
s\bouncy blocks\restart.lua’:
        c:\users\true\documents\corona projects\bouncy blocks\restart.lua:53: ‘e
nd’ expected (to close ‘function’ at line 30) near ‘<eof>’
stack traceback:
        [C]: in function ‘error’
        ?: in function ‘gotoScene’
        c:\users\true\documents\corona projects\bouncy blocks\level1.lua:136: in
 function ‘_listener’
        ?: in function <?:141>
        ?: in function <?:221>

Copyright © 2009-2015  C o r o n a   L a b s   I n c .
        Version: 3.0.0
        Build: 2015.2646
Platform: SM-G900S / x64 / 6.2 / Intel® HD Graphics / 4.0.0 - Build 10.18.10.3
408 / 2015.2646
Loading project from:   c:\users\true\documents\corona projects\bouncy blocks
Project sandbox folder: C:\Users\True\AppData\Roaming\Corona Labs\Corona Simulat
or\Sandbox\bouncy blocks-C116AB3B868BE13E671AF11DFB4D395F\Documents
WARNING: display.setStatusBarMode() not supported in the simulator for SM-G900S
device
Runtime error
error loading module ‘restart’ from file ‘c:\users\true\documents\corona project
s\bouncy blocks\restart.lua’:
        c:\users\true\documents\corona projects\bouncy blocks\restart.lua:54: ‘e
nd’ expected (to close ‘function’ at line 4) near ‘<eof>’
stack traceback:
        [C]: in function ‘error’
        ?: in function ‘gotoScene’
        c:\users\true\documents\corona projects\bouncy blocks\level1.lua:136: in
 function ‘_listener’
        ?: in function <?:141>
        ?: in function <?:221>

Copyright © 2009-2015  C o r o n a   L a b s   I n c .
        Version: 3.0.0
        Build: 2015.2646
Platform: SM-G900S / x64 / 6.2 / Intel® HD Graphics / 4.0.0 - Build 10.18.10.3
408 / 2015.2646
Loading project from:   c:\users\true\documents\corona projects\bouncy blocks
Project sandbox folder: C:\Users\True\AppData\Roaming\Corona Labs\Corona Simulat
or\Sandbox\bouncy blocks-C116AB3B868BE13E671AF11DFB4D395F\Documents
WARNING: display.setStatusBarMode() not supported in the simulator for SM-G900S
device
Runtime error
c:\users\true\documents\corona projects\bouncy blocks\restart.lua:7: attempt to
index global ‘self’ (a nil value)
stack traceback:
        [C]: in function ‘error’
        ?: in function ‘gotoScene’
        c:\users\true\documents\corona projects\bouncy blocks\level1.lua:136: in
 function ‘_listener’
        ?: in function <?:141>
        ?: in function <?:221>

level1.lua code:

local composer = require( "composer" ) local scene = composer.newScene() local physics = require( "physics" ) physics.start() physics.setGravity(0, 40) -- display background image local background = display.newImage( "background.png" ) background.x = 10; background.y = 308 -- display ground image local ground = display.newImage( "ground.png" ) ground.x = 145; ground.y = 480 ground.myName = "ground" ground.isGround = true physics.addBody( ground, "static" , { friction=0.5, bounce=0.1 } ) -- create object local myObject = display.newRect( 0, 0, 100, 30 ) myObject:setFillColor( 0 ) myObject.x = 145; myObject.y = 400 myObject.isMyObject = true physics.addBody( myObject, "kinematic" , { myObject, friction=0.5, bounce=2 } ) -- touch listener function function myObject:touch( event ) if event.phase == "moved" then self.x = event.x self.y = event.y end return true end -- make 'myObject' listen for touch events myObject:addEventListener( "touch", myObject ) local wall = display.newImageRect( "wall.png", 100, 10 ) wall.x, wall.y = -6, 387 wall.rotation = 90 physics.addBody( wall, "static" , { wall, friction=0.5, bounce=0.5 } ) local wall = display.newImageRect( "wall.png", 100, 10 ) wall.x, wall.y = -6, 300 wall.rotation = 90 physics.addBody( wall, "static" , { wall, friction=0.5, bounce=0.5 } ) local wall = display.newImageRect( "wall.png", 100, 10 ) wall.x, wall.y = -6, 202 wall.rotation = 90 physics.addBody( wall, "static" , { wall, friction=0.5, bounce=0.5 } ) local wall = display.newImageRect( "wall.png", 100, 10 ) wall.x, wall.y = -6, 104 wall.rotation = 90 physics.addBody( wall, "static" , { wall, friction=0.5, bounce=0.5 } ) local wall = display.newImageRect( "wall.png", 100, 10 ) wall.x, wall.y = -6, 7 wall.rotation = 90 physics.addBody( wall, "static" , { wall, friction=0.5, bounce=0.5 } ) local wall = display.newImageRect( "wall.png", 100, 10 ) wall.x, wall.y = 50, -49 physics.addBody( wall, "static" , { wall, friction=0.5, bounce=0.5 } ) local wall = display.newImageRect( "wall.png", 100, 10 ) wall.x, wall.y = 135, -49 physics.addBody( wall, "static" , { wall, friction=0.5, bounce=0.5 } ) local wall = display.newImageRect( "wall.png", 100, 10 ) wall.x = 232 wall.y = -49 physics.addBody( wall, "static" , { wall, friction=0.5, bounce=0.5 } ) local wall = display.newImageRect( "wall.png", 100, 10 ) wall.x = 335 wall.y = -49 physics.addBody( wall, "static" , { wall, friction=0.5, bounce=0.5 } ) local wall = display.newImageRect( "wall.png", 100, 10 ) wall.rotation = 90 wall.x = 325 wall.y = 3 physics.addBody( wall, "static" , { wall, friction=0.5, bounce=0.5 } ) local wall = display.newImageRect( "wall.png", 100, 10 ) wall.rotation = 90 wall.x = 325 wall.y = 98 physics.addBody( wall, "static" , { wall, friction=0.5, bounce=0.5 } ) local wall = display.newImageRect( "wall.png", 100, 10 ) wall.x = 325 wall.y = 195 wall.rotation = 90 physics.addBody( wall, "static" , { wall, friction=0.5, bounce=0.5 } ) local wall = display.newImageRect( "wall.png", 100, 10 ) wall.rotation = 90 wall.x = 325 wall.y = 292 physics.addBody( wall, "static" , { wall, friction=0.5, bounce=0.5 } ) local wall = display.newImageRect( "wall.png", 100, 10 ) wall.rotation = 90 wall.x = 325 wall.y = 387 physics.addBody( wall, "static" , { wall, friction=0.5, bounce=0.5 } ) local block = display.newImage( "block.png" ) block.rotation = 8 block.x = 200 block.myName = "block" block.isBlock = true physics.addBody( block, "dynamic" , { block, friction=0.5, bounce=0.5 } ) local function onCollision( self, event ) local other = event.other if( event.phase == "began" and self.isBlock and other.isGround ) then timer.performWithDelay( 30, function() composer.gotoScene ( "restart", "fade", 500 ); end) self:removeEventListener( "collision" ) end return true end block.collision = onCollision block:addEventListener( "collision" ) local block2 = display.newImage( "block2.png" ) block2.rotation = 8 block2.x = 100 block2.isBlock2 = true physics.addBody( block2, "dynamic" , { block2, friction=0.5, bounce=0.5 } ) local function onCollision( self, event ) local other = event.other if( event.phase == "began" and self.isBlock2 and other.isGround ) then timer.performWithDelay( 30, function() composer.gotoScene ( "restart", "fade", 500 ); end) self:removeEventListener( "collision" ) end return true end block2.collision = onCollision block2:addEventListener( "collision" ) scene:addEventListener( "createScene", scene ) scene:addEventListener( "showScene", scene ) scene:addEventListener( "hideScene", scene ) scene:addEventListener( "destroyScene", scene ) return scene 

restart.lua:

local composer = require( "composer" ) local scene = composer.newScene() function scene:create( event ) end local sceneGroup = self.view -- display background image local background = display.newImage( "background.png" ) background.x = 10; background.y = 308 -- display ground image local ground = display.newImage( "ground.png" ) ground.x = 145; ground.y = 480 local loseTxt = display.newImageRect( "loseTxt.png", 335, 200 ) loseTxt.x = 160 loseTxt.y = 30 -- display play button image local button = display.newImageRect( "button.png", 110, 80 ) button.x = 160 button.y = 300 function button:touch(event) if event.phase == "ended" then composer.gotoScene("level1", "fade", 200) end return true end button:addEventListener("touch", button) function scene:show( event ) end local sceneGroup = self.view local phase = event.phase function scene:hide( event ) end local sceneGroup = self.view local phase = event.phase if ( phase == "will" ) then elseif ( phase == "will" ) then end function scene:destroy( event ) local sceneGroup = self.view end scene:addEventListener( "create", scene ) scene:addEventListener( "show", scene ) scene:addEventListener( "hide", scene ) scene:addEventListener( "destroy", scene ) return scene 

I don’t understand what this error means .what is the problem .How do I fix it?

Thank you.

trueisawesome,

The error code shows you what the error is and gives a line number about the error.

      bouncy blocks\restart.lua:54: ‘end’ expected (to close ‘function’ at line 4) near ‘<eof>’

Now, this is a common error and the problem is it is ‘very misleading’ : the error is not at line 54 and not on line 4, just anywhere and maybe several place in between those lines.  This error (as far as I have ever experienced) is going to be about a misplaced or missing ‘end’ for a function or if statement. Every function and every if statement needs and ‘end’ at this proper place.

I see I can give you a quick answer and tell you the 3 or so lines to either move or delete and the problem will be fixed… BUT,  but I think it best to let you find them yourself.

To help you figure this out, I can say this:  3 of the 4 ‘composer functions’ (create, show, hide, destroy) have the function definition and then the end statement…  but no code in between.  What code do you want to be in each of those functions…  figure that out and put the code between  the ‘function definition’ and the ‘end’ statement.

Where do you think   ‘local sceneGroup = self.view’ code belongs?  Why is it repeated 4- times in the code?  

Hint:4 is the same number of composer functions in the code.

Good luck!

Bob

Actually you seem to have an extra end on line 5.

rob,

Line 5 is one of the lines I mention that I would delete or move… I was going to post the same short answer, but noticed after looking at the code closer he has several things wrong; and even removing just line 5 is going to still get a similar error.

Since I have noticed trueisawesome has posted several questions on the forum, I decided to give him just a nudge and a hint to help him get a better understanding of what is causing the error.

It is hard to tell for sure which code he wants to be in the scene:create function. I could guess, but probably would guess wrong.  Hopefully he can take some time and look over all the code in that file, because there are several things out of place.

trueisawesome,

The error code shows you what the error is and gives a line number about the error.

      bouncy blocks\restart.lua:54: ‘end’ expected (to close ‘function’ at line 4) near ‘<eof>’

Now, this is a common error and the problem is it is ‘very misleading’ : the error is not at line 54 and not on line 4, just anywhere and maybe several place in between those lines.  This error (as far as I have ever experienced) is going to be about a misplaced or missing ‘end’ for a function or if statement. Every function and every if statement needs and ‘end’ at this proper place.

I see I can give you a quick answer and tell you the 3 or so lines to either move or delete and the problem will be fixed… BUT,  but I think it best to let you find them yourself.

To help you figure this out, I can say this:  3 of the 4 ‘composer functions’ (create, show, hide, destroy) have the function definition and then the end statement…  but no code in between.  What code do you want to be in each of those functions…  figure that out and put the code between  the ‘function definition’ and the ‘end’ statement.

Where do you think   ‘local sceneGroup = self.view’ code belongs?  Why is it repeated 4- times in the code?  

Hint:4 is the same number of composer functions in the code.

Good luck!

Bob

Actually you seem to have an extra end on line 5.

rob,

Line 5 is one of the lines I mention that I would delete or move… I was going to post the same short answer, but noticed after looking at the code closer he has several things wrong; and even removing just line 5 is going to still get a similar error.

Since I have noticed trueisawesome has posted several questions on the forum, I decided to give him just a nudge and a hint to help him get a better understanding of what is causing the error.

It is hard to tell for sure which code he wants to be in the scene:create function. I could guess, but probably would guess wrong.  Hopefully he can take some time and look over all the code in that file, because there are several things out of place.