Game Development Reference
In-Depth Information
setfenv ( f, table )
This function sets the environment to be given to the function f . f can be a Lua function or a number
that specifies the value of the platform.
setmetatable ( table, metatable )
This function is used to set the metatable for any table.
tonumber( e [,base] )
This function is used for converting between the numbers from string to numerical values. If the
argument e is in a form that can be converted, it is converted and returned; otherwise, nil is
returned.
print( tonumber("42") )
print( tonumber("2A",16))
tostring ( e )
This function tries to convert the given argument to string format. If the passed parameter is a
number, it is converted into a string. If it is an object and its metatable has a __tostring function, the
__tostring function is called to convert the passed parameter.
Note Lua converts between numbers and strings as required (and if possible). However, calling the
tostring function is a way to tell Lua to convert the value into a string. Objects and tables are not
automatically converted into strings; instead, the function tostring (if present) is called, which returns
the string representation of the object/table.
type ( v )
This function returns the type of the arguments, coded as a string. The possible results are "nil" ,
"number" , "string" , "boolean" , "table" , "thread" , and "userdata" .
print(type("Hello World"))
print(type(4))
print(type({}))
unpack ( list [, i [, j] ] )
This function returns the elements from an array table. This function is equivalent to
return list[i], list[i+1], ... , list[j]
 
 
Search WWH ::




Custom Search