Professional Documents
Culture Documents
Reviewer For Application Development
Reviewer For Application Development
Lua
- is the programming language used to x = { y="Monday" } -- create table
develop the Corona SDK. print( x.y ) -- "Monday"
- The industry standard for game z = "Tuesday" -- assign a new value to property
"Tuesday"
programming.
print( z ) -- "Tuesday"
- Useful in creating various applications x.z = 20 -- create a new property
and games. print( x.z ) -- 20
- Consistent scripting language. print( x["z"] ) – 20
Variables – something that stores values. The following are valid variables:
x
Statements- provides instructions on what X
operations & computations need to be done. ABC
_abc
Variables - store the values of these test_01
computations. myGroup
Assignment - Setting a value into a variable. The following are invalid variables:
three kinds of variables: function
global my-variable
local 123
table fields
The basic types of values that you'll deal with
global variable - can be accessed in every are the following:
scope and can be modified from anywhere.
nil—It is the only type whose value
myVariable = 10 is nil.
print( myVariable ) -- prints the number 10 Boolean—The Boolean type has two
values, false and true.
Scope - used to describe the area in which a Numbers—Represents real (double-
set of variables live. precision floating-point) numbers.
String—A String is a sequence of
local variable - accessed from a local scope characters.
and usually called from a function or block of Tables—A data structure in Lua.
code. Functions—Known as first-class
values of Lua.
x = 10 -- global 'x' variable
local i = 1 associative array- an array that can be
while i <= 10 do indexed not only with numbers, but also with
local x = i * 2 -- a local 'x' variable for the while
block
strings or any
print( x ) -- 2, 4, 6, 8, 10 ... 20 other value, except nil.
i=i+1
end Expression
- something that has a value.
- can include numeric constants, quoted
strings, variable names, unary and binary
Table fields - are elements of the table operations, and function calls.
themselves.
arithmetic operators
Arrays - can be indexed with numbers and +, -, *, /, %, and ^
strings or any value pertaining to Lua except
nil. Modulo (division remainder) operator:
Strings - may contain characters with Functions - deal with a particular type of
any numeric value, including embedded value are part of that value.
zeros. value is called an object
functions are called methods.