Lesson 2: Variables
In this lesson I will teach you how to use variables to make a program that will paste your age to the screen!
Ok lets start by adding are colors.
green = Color.new(0,255,0)
now lets make some variables
birthyear = 1976
currentyear = 2010
age = nil
okay that should be pretty easy to understand(nil = nothing!)so lets start are loop
while true do
now lets calculate are age
currentyear - birthyear = age
That will calculate are age but it is not being pasted to the screen yet. To paste this to the screen we type this
screen:print(100,200,"My age is" .. age, red)
Ok so again this is printing the text My age is then there is two dots which is like end of the text and put a variable. so this will say my age is 34ok so now lets finish up the loop
screen.flip()screen.waitVblankStart()end
Ok so now save as myAge.lua and try it out.Ok so now you know variable lets move on!
back next
Ok lets start by adding are colors.
green = Color.new(0,255,0)
now lets make some variables
birthyear = 1976
currentyear = 2010
age = nil
okay that should be pretty easy to understand(nil = nothing!)so lets start are loop
while true do
now lets calculate are age
currentyear - birthyear = age
That will calculate are age but it is not being pasted to the screen yet. To paste this to the screen we type this
screen:print(100,200,"My age is" .. age, red)
Ok so again this is printing the text My age is then there is two dots which is like end of the text and put a variable. so this will say my age is 34ok so now lets finish up the loop
screen.flip()screen.waitVblankStart()end
Ok so now save as myAge.lua and try it out.Ok so now you know variable lets move on!
back next