Problem with file UI.LU in Gear tutorial

Hi guys

I’m learning Corona SDK :slight_smile: I watched Corona tutorial videos. I got problems with the “Gear” tutorial

This is the link to that video

http://www.youtube.com/watch?v=Y5Oz72MO4JI

At first, it reports there is no UI.LU file in my computer. I google it and people told me to download any UI.LU file. I download a UI.LUA file from Corona forum and put in my folder. But it still didn’t work.

The second problem is that the video was hard to follow (for a newbie like me) The teacher copied and pasted every code so I found it too fast for me. The screen is also small.

Anyone made this Gear tutorial before, could you send me your samples (the main.lua file) so I can see the code. I tried to download but the link died

Thanks [import]uid: 54857 topic_id: 10024 reply_id: 310024[/import]

Hey there,

What error are you getting?

Peach :slight_smile: [import]uid: 52491 topic_id: 10024 reply_id: 36645[/import]

I followed the video until the 1ST button added but when I relaunch my simulator the button didn’t show up

I continued to follow the video and complete the coding. When I relaunched the simulator the screen was empty

It reported the error: “=” expected near “==”

I think I missed some code lines because the video didn’t show the full screen and it was very fast (only copy and paste)

The link to samples didn’t work anymore so I can’t download to see. If you guys have the main.lua file of this project. Please give it to me
Thanks [import]uid: 54857 topic_id: 10024 reply_id: 36652[/import]

Windows simulator build date: Apr 12 2011 @ 11:44:54
Copyright © 2009-2010 A n s c a , I n c .
Version: 2.0.0
Build: 2011.484
Syntax error: C:\Users\Public\Documents\CoronaPratice2\lesson5\main.lua:41: ‘=’
expected near ‘==’

Copyright © 2009-2010 A n s c a , I n c .
Version: 2.0.0
Build: 2011.484
Syntax error: C:\Users\Public\Documents\CoronaPratice2\lesson5\main.lua:43: unex
pected symbol near ‘.’

Copyright © 2009-2010 A n s c a , I n c .
Version: 2.0.0
Build: 2011.484
Runtime error
…Users\Public\Documents\CoronaPratice2\lesson5\ui.lua:130: attempt to
index local ‘button’ (a nil value)
stack traceback:
[C]: ?
…Users\Public\Documents\CoronaPratice2\lesson5\ui.lua:130: in function
‘newButton’
…ers\Public\DocumenRuntime error: …Users\Public\Documents\CoronaPrat
ice2\lesson5\ui.lua:130: attempt to index local ‘button’ (a nil value)
stack traceback:
[C]: ?
…Users\Public\Documents\CoronaPratice2\lesson5\ui.lua:130: in function
‘newButton’
…ers\Public\Documents\CoronaPratic [import]uid: 54857 topic_id: 10024 reply_id: 36654[/import]

Could you please paste your code, as it was when that error occurred? [import]uid: 52491 topic_id: 10024 reply_id: 36684[/import]

[lua]local ui = require(“ui”)

local background = display.newImage (“background.png”)
local gear = display.newImage (“gear.png”)
local gear2 = display.newImage (“gear.png”)
gear.xScale = 1.5
gear.yScale = 1.5

gear2.xScale = 1.5
gear2.yScale = 1.5
gear.x = display.contentWidth / 4 + 40
gear.y = display.contentHeight / 2 - 50

gear2.x = gear.x + gear.contentWidth * .67
gear2.y = gear.y + gear.contentHeight * .67
gear2.rotation = 7
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 eveent.id == “reverse” then
rotateAmount = rotateAmount -1
end
end
end

local button1 = ui.newButton{
default = “buttonGray.png”,
over = “buttonGrayOver.png”,
onEvent = buttonHandler,
text = “Stop”,
id = “stop”,
size = 12,
emboss = true
}

button1.x = (display.contentWidth / 4 * 1) - display.contentWidth[/lua]

*Edited: Please post all code within Lua tags [import]uid: 54857 topic_id: 10024 reply_id: 36692[/import]

Hey,

I didn’t notice in the last post (was waiting to compare errors with code) but it seems you have posted some errors not related to your problem, is that right?

What I mean is, your first error is about a “.” or “:” used in the wrong place, your second is about using “=” or “==” in the wrong place and then the rest refer to other issues.

Are you still getting these original errors, or just the last one? [import]uid: 52491 topic_id: 10024 reply_id: 36787[/import]

PS - You have a typo on line 42; “eveent”. [import]uid: 52491 topic_id: 10024 reply_id: 36788[/import]

Hi,

IN case the typo is not your error and you have done everything, please try replacing the ui.lua file with the one found in “maritan control” project. That apparently has resolved the issue i was facing with ui.lua [import]uid: 55009 topic_id: 10024 reply_id: 36818[/import]

I didn’t make any mistake with “=” or “==”. It has nothing to do with this problem.

I fixed Eveent to Event but it still didn’t work. The gears are fine but no button show up. None of them [import]uid: 54857 topic_id: 10024 reply_id: 36983[/import]

This is my code

local ui = require(“ui”)

local background = display.newImage (“background.png”)
local gear = display.newImage (“gear.png”)
local gear2 = display.newImage (“gear.png”)
gear.xScale = 1.5
gear.yScale = 1.5

gear2.xScale = 1.5
gear2.yScale = 1.5
gear.x = display.contentWidth / 4 + 40
gear.y = display.contentHeight / 2 - 50

gear2.x = gear.x + gear.contentWidth * .67
gear2.y = gear.y + gear.contentHeight * .67
gear2.rotation = 7
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 = “buttonGray.png”,
over = “buttonGrayOver.png”,
onEvent = buttonHandler,
text = “Stop”,
id = “stop”,
size = 12,
emboss = true
}

button1.x = (display.contentWidth / 4 * 1) - display.contentWidth [import]uid: 54857 topic_id: 10024 reply_id: 36984[/import]

local ui = require(“ui”)

local background = display.newImage (“background.png”)
local gear = display.newImage (“gear.png”)
local gear2 = display.newImage (“gear.png”)
gear.xScale = 1.5
gear.yScale = 1.5

gear2.xScale = 1.5
gear2.yScale = 1.5
gear.x = display.contentWidth / 4 + 40
gear.y = display.contentHeight / 2 - 50

gear2.x = gear.x + gear.contentWidth * .67
gear2.y = gear.y + gear.contentHeight * .67
gear2.rotation = 7
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 = “buttonGray.png”,
over = “buttonGrayOver.png”,
onEvent = buttonHandler,
text = “Stop”,
id = “stop”,
size = 12,
emboss = true
}

button1.x = (display.contentWidth / 4 * 1) - display.contentWidth [import]uid: 54857 topic_id: 10024 reply_id: 36985[/import]

This is the error reported

Runtime error

ui.lua:130 attempt to index local ‘button’

uilua:130 in function “newButton” [import]uid: 54857 topic_id: 10024 reply_id: 36987[/import]