Game Development Reference
In-Depth Information
boolean
boolean variables are our trusty true and false . These are used to check for conditions; however, it
should be noted that both nil and false will result in the condition being false and any other value
resulting in true .
trusted = false
if (trusted) then print("Yes") end -- Nothing is printed
trusted = 1
if (trusted) then print("Yes") end -- Yes is printed
trusted = nil
if (trusted) then print("Yes") end -- Nothing is printed
number
number variables are numbers that can be expressed as decimals, longs, integers, hexadecimals, and
floats. Lua saves the numbers as double-precision floating-point numbers.
string
Lua strings are generally 8-bit clean strings (i.e., they can hold any 8-bit character, including
embedded zeros). Unicode variables are a slightly different matter, but are handled by Lua if the
platform supports Unicode.
function
In Lua, functions can also be stored and passed as variables. This functionality of being able to store
and pass functions as parameters makes the functions in Lua “ first-class functions .”
userdata
This is a memory block that is allocated from C, allowing C functions to store and access data.
userdata variables cannot be created or manipulated in Lua, but only through the C API.
thread
This is a special type of variable; this specifies an independent thread of execution. This is not the
same as the operating system thread.
table
table variables are what we would call arrays, associative arrays, hash tables, sets, records, lists,
trees, and even objects in Lua.
Note
Tables, functions, and threads do not really hold any values—only references to them.
 
 
Search WWH ::




Custom Search