|
number
|
|
string
|
|
boolean
|
|
table
|
|
function
|
|
userdata
|
|
thread
|
|
nil
|
|
Sum
|
+
|
|
Negation/Subtraction
|
-
|
|
Product
|
*
|
|
Division
|
/
|
|
Modulo
|
%
|
|
Power
|
^
|
|
Equal to
|
==
|
|
Not equal to
|
~=
|
|
Less than
|
<
|
|
Greater than
|
>
|
|
Less than or equal to
|
<=
|
|
Greater than or equal to
|
>=
|
|
not
|
|
and
|
|
or
|
value = (condition and truevalue) or falsevalue|
math.abs(number)
|
|
math.acos(radians), math.asin(radians), math.atan(radians)
|
|
math.ceil(number), math.floor(number)
|
|
math.cos(radians), math.sin(radians), math.tan(radians)
|
|
math.deg(radians), math.rad(degrees)
|
|
math.exp(number), math.log(number)
|
|
math.min(num1, num2, ...), math.max(num1, num2, ...)
|
|
math.sqrt(number)
|
|
math.random(), math.random(upper), math.random(lower, upper)
|
|
math.randomseed(seed)
|
|
math.huge --represents infinity
|
|
math.pi
|
|
table.concat(table [, sep [, i [, j]]])
|
Concatenate the elements of a table to form a string. Each element must be able to be coerced into a string.
|
|
table.foreach(table, f)
|
Apply the function f to the elements of the table passed. On each iteration the function f is passed the key-value pair of that element in the table. Apply the function f to the elements of the table passed. On each iteration the function f is passed the key-value pair of that element in the table. Deprecated
|
|
table.foreachi(table, f)
|
Apply the function f to the elements of the table passed. On each iteration the function f is passed the index-value pair of that element in the table. This is similar to table.foreach() except that index-value pairs are passed, not key-value pairs. Deprecated
|
|
table.sort(table [, comp])
|
Sort the elements of a table in-place. A comparison function can be provided to customise the element sorting. The comparison function must return a boolean value specifying whether the first argument should be before the second argument in the sequence.
|
|
table.insert(table, [pos,] value)
|
Insert a given value into a table. If a position is given insert the value before the element currently at that position.
|
|
table.remove(table [, pos])
|
Remove an element from a table. If a position is specified the element at that the position is removed. The remaining elements are reindexed sequentially and the size of the table is updated to reflect the change. The element removed is returned by this function.
|
|
string.byte(s [, i [, j]])
|
Return the numerical code the i-th through j-th character of the string passed.
|
|
string.char(i1, i2, ...)
|
Generate a string representing the character numerical code passed as arguments.
|
|
string.find(s, pattern [, index [, plain]])
|
Find the first occurrence of the pattern in the string passed
|
|
string.format(s, e1, e2, ...)
|
Create a formatted string from the format and arguments provided. This is similar to the printf("format",...) function in C.
|
|
string.gsub(s, pattern, replace [, n])
|
Used simply it can replace all instances of the pattern provided with the replacement. A pair of values is returned, the modified string and the number of substitutions made. The optional fourth argument n can be used to limit the number of substitutions made
|
|
string.len(s)
|
Return the length of the string passed.
|
|
string.lower(s)
|
Make all the upper case characters lower case.
|
|
string.upper(s)
|
Make all the lower case characters upper case.
|
|
string.match (s, pattern [, index])
|
Extract substrings by matching patterns.
|
|
string.rep(s, n)
|
Generate a string which is n copies of the string passed concatenated together.
|
|
string.reverse(s)
|
Reverses a string.
|
|
string.sub(s, i [, j])
|
Return a substring of the string passed. The substring starts at i. If the third argument j is not given, the substring will end at the end of the string. If the third argument is given, the substring ends at and includes j.
|
string.reverse("Test")"Test":reverse()"
local Person = {}
Person.__index = Person
function Person.new(name, surname)
local self = setmetatable({}, Person)
self.name = name
self.surname = surname
return self
end
function Person.setName(self, name)
self.name = name
end
function Person.getName(self)
return self.name
end
function Person.setSurname(self, surname)
self.surname = surname
end
function Person.getSurname(self)
return self.surname
end
return Person
-- Import with ClassName = require("classname")
-- Use with local i = ClassName.init(params)
local function MyClass(init)
local self = {
public_field = 0
}
local private_field = init
function self.foo()
return private_field
end
function self.bar()
private_field = private_field + 1
end
return self
end
return MyClass
-- Import with MyClass = require("MyClass")
-- Use with local i = MyClass(init)
No comments yet.
Cheatography n. The art of mapping complex subjects into clear, instantly navigable reference guides.