Common function library Rollup in Lua _lua

Source: Internet
Author: User

LUA Library functions

These 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 Debug command in Wow.exe) display a dialog box and output error debugging information

CollectGarbage ()-Garbage collector. (added to 1.10.1)

Date-Returns the time on the current user's machine.

Error (' Error message ', level)-When an error occurs, output a defined error. 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 rank of the function that this table has obtained

Getmetatable (obj, mtable)-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 (func, 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 level of the function that this table has obtained

Setmetatable (obj, mtable)-Sets the metadata table or user data object for the current table

Time (table)-Returns a Unix value from

Type (VAR)-Determines the types of the current variable, "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 also refer to the LUA Library of functions (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)-angle 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 Library

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[, ...)]-formatting strings

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)-The conversion parameter is a 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 contains 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.

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.