Lua all built-in Functions list _lua

Source: Internet
Author: User
Tags data structures numeric lua natural logarithm numeric value square root strfind blizzard

These standard LUA functions are available in most LUA parsing. It's indisputable that we can refer to the LUA Web site, but some of the fewer functions have been adjusted by Blizzard. All the LUA functions are listed below.

The LUA note in the WoW API does not provide all the standard LUA functions in Wowapi, and obviously the operating system and file I/O libraries are not supported

The LUA functions are all part of the LUA programming language, and click here to learn more.

assert (value)-Checks whether a value is nil, if not (if you open the Debug command in Wow.exe) display a dialog box and output error debugging information
collectgarbage ()-Garbage collector. (added to 1.10.1)
date (format, time)-returns the Times on the current user's machine.
Error (' Error message ', level)-When an error occurs, output a defined error information. Use Pcall () (see below) to catch an error.
gcinfo ()-Returns the amount of memory used in the plug-in (KB) and the current amount of garbage collector usage in kilobytes (KB).
getfenv (function or integer)-Returns the stack structure or stack level
getmetatable (obj, mtable) of the function that this table has obtained-gets the current meta table or user data object.
loadstring ("LUA Code")-Parse the LUA code block in a string and return the result as a function
next (table, index)-Returns the next key, a pair of table values. Allow traversal of the entire table
pcall (Fu NC, Arg1, arg2, ...) -protected invocation. Executes the contents of the function while capturing all exceptions and errors.
Select (Index, list)-Returns the value of the item selected in this list. or the index value of this item in the list
setfenv (function or integer, table)-Sets the stack structure or stack of the function that this table has obtained Level
setmetatable (obj, mtable)-Sets the current table's meta table or user data Object
time (table)-Returns the type of the current variable from a UNIX time value
type (var), "number "," string "," table "," function ", or" UserData ".
Unpack (table)-Unzip a table. Returns all values in the current table.
Xpcall (func, Err)-Returns a Boolean value indicating the function that was executed successfully and the error message that the call failed. Another run function or wrong return value

Mathematical functions These table functions can also refer to the LUA library (they all start with math, see the Math Library for more information).

Trigonometric functions are not referenced, including the conversion of angular-> radians. The blizzard version uses the angle. And the LUA standard math library uses radians.

ABS (value)-Returns the absolute value of the current value
ACOs (value)-Returns the arc cosine of this angle value.
ASIN (value)-Returns the arc sine value of this angle value
Atan (value)-Returns the arc tangent of this angle value
atan2 (y, x)-In the angle, returns the arc tangent of the y/x.
ceil (value)-Returns an integer, regardless of the number after the decimal point, the integer part into 1
cos (degrees)-returns the cosine of the angle
deg (radians)-radians conversion angle
exp (value)-Returns the exponential value of this value
floor (value)-Returns the integer value of this value
frexp (NUM)-Returns the number of digits after the current decimal point and the digit after the decimal point
ldexp (value, multiple)-outputs a multiple of this value
log (value)-Returns the natural logarithm of this value (based on E)
log10 (value)-Returns a value of 10
Max (value[, Values ...])-Find the maximum value in a heap of values
min (value[,values ...])-Find the minimum value in a heap of values
MoD (Value,modulus)-Returns the remainder of this value
rad (degrees)-angular conversion radians
random ([[Lower,] upper])-Returns a random number (the optional bounds are integer values)
randomseed (Seed)-set the seed for the pseudo-random number generator
sin (degrees)-Returns the sine value of the current angle
sqrt (value)-Returns the square root of a value (for example, 100 of the square root is 10)
Tan (degrees)-returns the tangent of the current angle

String libraries These table functions can also refer to the LUA string library (they all start with string. Reference string library for more information)

format (formatstring[, value[, ...)]-format string
gsub (string,pattern,replacement[, Limitcount])-Global replacement
strbyte (string[, index])-The conversion string is an integer value (you can specify a character).
Strchar (asciicode[, ...])-Converts the integer to the corresponding character
strfind (String, pattern[, initpos[, plain])-searches a specified target string for the specified content (the third parameter is an index) and returns its exact location.
strlen (String)-returns the number of characters in the current string
Strlower (String)-Converts the letter of a string to lowercase format
Strmatch (String, pattern[, Initpos])-unlike strfind, MACTH returns a specific value, and find returns the position of this value
Strrep (Seed,count)-Returns the number of seed copies of a string
strsub (String, index[, Endindex])-Returns the value at the specified position of the string.
Strupper (String)-Converts the letter of a string to uppercase
Tonumber (arg[, base])-Returns a numeric value if the parameter can be converted to a number. You can specify the type of conversion. The default is a decimal integer
ToString (ARG)-Convert parameter to string
The following string function is Wow unique
Strtrim (String)-remove spaces before and after strings
Strsplit (delimiter, String)-split string
Strjoin (delimiter, String, string[, ...))-concatenate strings by delimiter

Table functions These table functions can also refer to the LUA table library (they all start with "table.", see table Library F for more information).

It is also known that many tables are designed to have only numeric indices, starting at 1 and having no end (such as like {[1] = "Foo", [3] = "Bar"}---[2] is not present, so it is nil value). When working, it does not differ from any other table, but it is likely to produce unexpected results. In the writing of Lua, this is the usual bug.
foreach (table,function)-performs functions for each element in a table
Foreachi (table,function)-performs functions for each element in the table, accessed sequentially (not recommended, you can use Ipairs instead)
GETN (table)-Returns the size of the current table when it is used as a chat table. Now obsolete, you can use the # symbol directly. Use # (table) instead of TABLE.GETN (table)
ipairs (table)-Returns an iterative integer traversal of the table.
Pairs (table)-Returns an iterative traversal table
sort (table[, comp])-Sorts an array, optionally specifying an optional order function
Tinsert (table[, POS], value)-Inserts an element into the specified position (default at the end of the table)
tremove (table[, POS])-Deletes the element at the specified location (the default table is the last)

Bit functions World of Warcraft includes the Lua Bitlib library (they are all "bit." Beginning). The same as the bitwise operation of C. The bit operation library is not part of the LUA standard function library, but it is applied in Wow 1.9
Bit.bnot (a)-Returns a supplement to a
Bit.band (W1,...)-Returns the bit of W with
Bit.bor (W1,...)-Returns the bit of W or
Bit.bxor (W1,...)-Returns the bit XOR of W or
Bit.lshift (A,B)-Returns a left offset to B-bit
Bit.rshift (A,B)-Returns a logical right offset to B-bit
Bit.arshift (A,B)-Returns a arithmetic offset to b bit
Bit.mod (A,B)-Returns the integer remainder of a divided by B
Lua is a scripting language that uses these functions to compare your data structures very slowly. Unless you have a very large database and need to protect the RAM used, save your information to several or individual variables.

Notes • All characters have their meta table set to the Global string table, so some string functions can be written directly before the colon to invoke:

Copy Code code as follows:

1 Local s = String.Format (input, arg1, arg2, ...)
2
3--can be written like this
4 local s = Input:format (Arg1, arg2, ...) --input will be copied to the code as the first parameter, which is the colon syntax

• This can also be used on strings, "%d": Format (ARG1) is not a valid LUA code, you can write

Copy Code code as follows:

1 ("%d"): Format (ARG1)

• Since the use of string tables, some functions can also work in the string table, and the following examples are valid:
Copy Code code as follows:

1 function String.print (a)
2 return print (a)
3 End
4 ("Test"):p rint ()

Although you should try to avoid filling the string table with your function.

Related resources you can also see LUA for more information about LUA development.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.