LUA functions [Go]

Source: Internet
Author: User
Tags natural logarithm strfind blizzard

These standard LUA functions are available in most LUA parsing. It is indisputable that we can look at the LUA Web site, but some of the fewer functions have been blizzard. All LUA functions are listed below. The LUA note in WoW API does not provide all the standard LUA functions in Wowapi, and it is clear that the operating system and file I/o Library is a LUA function that is not supported these functions are part of the LUA programming language, click here to learn more.assert(value)-checks if a value is non-nil, if not (if the debug command is opened in Wow.exe), displays a dialog box and outputs error debugging information ·CollectGarbage()-Garbage collector. (added in 1.)10.1) Date (format, time)-returns the time on the current user's machine.Error("error Message", level)-When an error occurs, output a defined error message. Use Pcall () (see below) to catch an error. gcinfo ()-returns the amount of memory used in the plug-in (KB) and the current garbage collector usage (KB).getfenv(function orInteger)-returns the stack structure or stack level of the function that this table has acquired ·getmetatable(obj, mtable)-gets the current meta-table or user data object.LoadString("Lua Code") -parses a LUA code block in a string and returns 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 function contents while capturing all exceptions and errors. •Select(Index, list)-Returns the value of the item selected in this list. Or is the index of this item in the list ·setfenv(function orInteger, table)-sets the stack structure or stack level of the function that this table has acquired ·setmetatable(obj, mtable)-set the current table's meta-table or user data object time (table)-return from a Unix time value ·type(Var)-Determines the type 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. In addition, the function or the incorrect return value of the Math function these table functions can also refer to the LUA library (they all start with math. See Math Library for more information). Trigonometric functions are of no reference, Include Angle-conversion of radians. The blizzard version uses the angle. and the standard math library of LUA uses radians. ABS (value)-returns the absolute value of the current value ACOs (value)-returns the Arc cosine value of this angle value. ASIN (value)-returns the arc sine value of this angle value atan (value)-returns the arc tangent value of this angle value atan2 (y, x)-In the angle, return y/the arc tangent of X. ceil (value)-returns an integer, regardless of the number after the decimal point, into the 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 value of the current digit after the decimal point and the number of digits after the decimal point ldexp (value, multiple)-outputs multiples of this number log (value)-returns the natural logarithm (base e) of this value log10 (value)-returns a base value of 10 max (value[, Values ...])-find maximum value in a bunch of values min (value[,values ...])-Find minimum value mod (value,modulus) in a bunch of values-returns the remainder of this value rad (degrees)-Angle Conversion Radian random ([[[Lower,] upper])-returns a random number (optional bounds is an integer value) randomseed (Seed)-set seed sin (degrees) for pseudo-random number generator-returns the sine of the current angle sqrt (value)-returns the square root of a numeric value (for example, a square root of 100 is 10) tan (degrees)-returns the tangent string library for the current angle these table functions can also refer to the LUA string library (they all start with a string. Refer to the strings library for more information) format (formatstring[, value[, ...])-formatted 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 an integer to the corresponding character strfind (string, pattern[, initpos[, plain])-searches for the specified content in a specified target string (the third parameter is an index) and returns its specific position. 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 of the specified position of the string. strupper (String)-convert the letter of a string to uppercase format ·Tonumber(arg[, base])-returns a numeric value if the parameter can be converted to a number. You can specify the type of conversion. Default is a decimal integer ·ToString(ARG)-The string function that converts the argument to a string is the Strtrim (string) unique to Wow-remove string before and after whitespace 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 are all"table. Start", consult table Library F for more information). Also know that many tables are designed to have only numeric indexes, starting at 1 and without endings (like {[1] ="Foo", [3] ="Bar"}---[2] is not present, so it is nil value). While working, there is no difference from any other table, but it is likely to produce unexpected results. In writing Lua, this is the usual bug .foreach (table,function) -executes a function Foreachi (table) for each element in the table,function) -perform functions for each element in the table, sequentially access (not recommended, can use Ipairs instead) getn (table)-Returns the size of the current table when it is a chat table. Now it's obsolete, you can use the # symbol directly. Use #(table) instead of table.getn (table) ·Ipairs(table)-returns an iterative integer traversal table. •Pairs(table)-returns an iterative traversal table sort (table[, comp])-to sort an array, you can also specify 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."Start). Is the same as the bitwise operation of C. Bit operations Library is not part of the LUA standard library, but in Wow1. 9 has been applied Bit.bnot (a)-returns a supplement to a Bit.band (W1,...)-returns the bit of W with Bit.bor (W1,...)-returns the bit or Bit.bxor of W (W1,...)-returns the bit XOR or bit.lshift (A, b) of W-return A to the left offset to the B-bit bit.rshift (A, a)-returns a logical right offset to B-bit bit.arshift (A, a)-returns a arithmetic offset to B-bit bit.mod (A, A, a)-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 for invocation: Toggle line number Display1 Locals =String.Format(input, arg1, arg2, ...) 2    3 --can be written like this   4 Locals = Input:format (Arg1, arg2, ...)--input is 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 a toggle line number display1("%d"): Format (ARG1) • Since the use of string tables, some functions are also available in the string table, and the following example is valid: Toggle line number Display1 functionString.Print(a)2  return Print(a)3 End   4("Test"):Print() Although you should try to avoid populating the string table with your function. Related Resources You can also refer to LUA for more information about LUA development. 

Lua function [go]

Related Article

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.