Sunday, September 30, 2007

Basics

variable types

integers
x = 1
x,y,z = 5

strings are in quotations
name = "string"

tables can store many variables

table = {1,2,3,4,5,6}
print(table[1])
print(table[4])


you can organize you code into functions if you plan to reuse the same command many times.

function function_name ( args ) body end

function count(n)
return n*2
end

// use the count function

cont(7)

loops

this for loop will print the letter i 11 times
for i = 0, 10 do
print(i)
end

No comments: