Note that there are some explanatory texts on larger screens.

plurals
  1. POAttempt to index local 'button' (a nil value)
    primarykey
    data
    text
    <p>I'm walking through the following tutorial <a href="http://www.youtube.com/watch?v=Y5Oz72MO4JI" rel="nofollow">http://www.youtube.com/watch?v=Y5Oz72MO4JI</a></p> <p>but for some reason i'm getting the error <code>Attempt to index local 'button' (a nil value)</code> I've rechecked everything in my code, and it seams correct like in the video</p> <p>the full error:</p> <pre><code>ui.lua:130 Attempt to index local 'button' (a nil value) stack traceback: [C]:? ui.lua:130 in function 'newButton' </code></pre> <p>code:</p> <pre><code>----------------------------------------------------------------------------------------- -- -- main.lua -- ----------------------------------------------------------------------------------------- local ui = require("ui") local background = display.newImage("background.jpg") local gear = display.newImage("gear.png") local gear2 = display.newImage("gear.png") gear.x = display.stageWidth / 2 + 26 gear.y = display.stageHeight / 2 - 50 gear2.x = display.stageWidth * .63 gear2.y = display.stageHeight * .60 local rotateAmount = 1 local function animate( event ) gear.rotation = gear.rotation + rotateAmount gear2.rotation = gear2.rotation - rotateAmount end Runtime:addEventListener( "enterFrame", animate ) local buttonHandler = function( event ) if event.phase == "release" then if event.id == "stop" then rotateAmount = 0 elseif event.id == "+1" then rotateAmount = rotateAmount + 1 elseif event.id == "-1" then rotateAmount = rotateAmount - 1 elseif event.id == "reverse" then rotateAmount = rotateAmount * -1 end end end local button1 = ui.newButton{ default = "button.png", over = "buttonOver.png", onEvent = buttonHandler, text = "Stop", id = "stop", size = 12, emboss = true } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload