(a nil value) error on everything

Hello, you might have seen my other post about making a spin wheel, I have borrowed some code from another post by Rob Miracle. Whenever I try to run this, it just states that everything is a (nil value) error. Even adding a background is said to be an error. Could anyone please help me? I am trying to make my first app

local function gameLoop() angle = wheel.rotation if wheel.angularVelocity == 0 and angle ~= startingAngle then local wedge = math.floor(((angle + 45) % 360) /45) + 1 startingAngle = angle mydata.gameCategory = wedge if movementEnded then timer.performWithDelay(1000,playRound); end end end local function spinWheel(event) local t = event.target local phase = event.phase if (phase == "began") then display.getCurrentStage():setFocus( t ) t.isFocus = true t.x1 = event.x t.y1 = event.y startTime = event.time elseif t.isFocus then if (phase == "moved") then t.x2 = event.x t.y2 = event.y angle1 = 180/math.pi \* math.atan2(t.y1 - t.y , t.x1 - t.x) angle2 = 180/math.pi \* math.atan2(t.y2 - t.y , t.x2 - t.x) rotationAmt = angle1 - angle2 t.rotation = t.rotation - rotationAmt t.x1 = t.x2 t.y1 = t.y2 elseif (phase == "ended") or (phase == "cancelled") then local deltaTime = event.time - startTime if deltaTime \< 500 then wheel:applyAngularImpulse( 100000 + rand(33000)) wheel:removeEventListener("touch", spinWheel) else wheel:removeEventListener("touch", spinWheel) timer.performWithDelay(500,playRound); end movementEnded = true display.getCurrentStage():setFocus( nil ) t.isFocus = false end end return true end function scene:createScene( event ) local group = self.view physics.start() physics.setGravity(0,0) physics.pause() local background = display.newImageRect("snipwheel3.jpg", 756, 504) background.x = display.contentWidth / 2 background.y = display.contentHeight / 2 group:insert(background) wheel = display.newImageRect("images/wheel.png", 250, 250) startingAngle = wheel.rotation print("Starting Angle: " .. startingAngle) wheel.x = 140 wheel.y = display.contentHeight / 2 + 20 group:insert(wheel) physics.addBody(wheel, {density=0.5, friction=0.8, bounce=0.0, radius=125 } ) wheel.angularDamping = 0.7 wheel:addEventListener("touch", spinWheel) local pointer = display.newImageRect("images/pointer.png", 32, 16) pointer.x = 15 pointer.y = display.contentHeight / 2 + 20 group:insert(pointer) end function scene:enterScene( event ) local group = self.view storyboard.removeScene("loading") Runtime:addEventListener("enterFrame", gameLoop) physics.start() end

Have you got the jpg and png images in your project folder?

Yes, all three are there

Alex,

  Nick pointed you in the correct direction to solving the problem.  If all of those images are in the project folder directly, you will get error on 2 of them as you have the path for those images as ‘images/…’    So check to see if 2 of those images are actually in a folder called ‘images’ in your project folder?   I take it since you said you copied the code from Rob, maybe you did not make a folder named ‘images’ to hold all the images.  

In any case, normally to keep things organized, most developers will keep all their assets in folders such as images or sounds or audio. In your code sample you show one image as being directly in the project folder  ‘spinwheel3.jpg’, and the other 2 images in your sample code show ‘images/…’

If you re-read your error messages completely, usually closer to the top of the list of errors will be message saying ‘failed to find image’ indwell show the directory path to the image …  read that carefully and make sure the path and image name are spelled exactly the same including proper and exact matching ‘case’.

Good Luck

Bob 

Also it’s really helpful for people trying to help you to see the exact error text which is best copied from the console window that opens in the background and pasted into your forum post.

Rob

FWIW I think the errors exist in this thread

https://forums.coronalabs.com/topic/65534-how-do-i-make-a-working-spinwheel-app-that-can-be-changed-any-help-will-be-greatly-appreciated/

This appears to be a second thread regarding the thread Alex mentioned above. Please continue discussion there so we can concentrate on the problem instead of it being divided across threads.

https://forums.coronalabs.com/topic/65534-how-do-i-make-a-working-spinwheel-app-that-can-be-changed-any-help-will-be-greatly-appreciated/

Have you got the jpg and png images in your project folder?

Yes, all three are there

Alex,

  Nick pointed you in the correct direction to solving the problem.  If all of those images are in the project folder directly, you will get error on 2 of them as you have the path for those images as ‘images/…’    So check to see if 2 of those images are actually in a folder called ‘images’ in your project folder?   I take it since you said you copied the code from Rob, maybe you did not make a folder named ‘images’ to hold all the images.  

In any case, normally to keep things organized, most developers will keep all their assets in folders such as images or sounds or audio. In your code sample you show one image as being directly in the project folder  ‘spinwheel3.jpg’, and the other 2 images in your sample code show ‘images/…’

If you re-read your error messages completely, usually closer to the top of the list of errors will be message saying ‘failed to find image’ indwell show the directory path to the image …  read that carefully and make sure the path and image name are spelled exactly the same including proper and exact matching ‘case’.

Good Luck

Bob 

Also it’s really helpful for people trying to help you to see the exact error text which is best copied from the console window that opens in the background and pasted into your forum post.

Rob

FWIW I think the errors exist in this thread

https://forums.coronalabs.com/topic/65534-how-do-i-make-a-working-spinwheel-app-that-can-be-changed-any-help-will-be-greatly-appreciated/

This appears to be a second thread regarding the thread Alex mentioned above. Please continue discussion there so we can concentrate on the problem instead of it being divided across threads.

https://forums.coronalabs.com/topic/65534-how-do-i-make-a-working-spinwheel-app-that-can-be-changed-any-help-will-be-greatly-appreciated/