WildStar/uilua This is the main reference for the WildStar Lua runtime, as implemented in the WildStar UI. See also UI API.

The WildStar Lua runtime is based on Lua 5.1, and generally uses the same standard Lua functions listed on the official Lua web site. Some functions differ slightly in WildStar's implementation and are documented here as well for consistency.

Reference[edit | edit source]

Nearly all of these functions are part of the default Lua 5.1 runtime environment, described here. Notable omissions are the operating system, and file I/O libraries.

/eval Print(_VERSION)
[debug]: Lua 5.1

Basic[edit | edit source]

WildStar/id(val[, sMsg]) returns (val) - returns val if true, else throws Lua error with sMsg
WildStar/id() - forces garbage collection
WildStar/id([filename]) - opens the named file and executes its contents as a Lua chunk (stdio not usable in UI)
WildStar/id(sMsg, level) - throws error with message. use pcall() to catch errors
WildStar/id() returns (nAddOn,nLimit) - gets AddOn memory used and current GC threshold in kB
WildStar/id(any) returns (table) - gets stack frame of given function or stack level number
WildStar/id(aObject) returns (mtable) - gets metatable for table or userdata
WildStar/id(func [, chunkname]) returns (function) - gets Lua chunk from func stream, until empty, nil, no value
WildStar/id([filename]) returns (function) - similar to load, but gets from file (stdio not usable in UI)
WildStar/id(string [, chunkname]) returns (function) - gets Lua chunk for a Lua code string
WildStar/id(boolean or proxy) - creates a userdata with a sharable metatable
WildStar/id(table, index) returns (key,value) - gets next key-value pair of the table, allowing you to walk a table
WildStar/id(func, arg1, arg2, ...) returns (boolean, results or sMessage) - executes 'func' and returns true and values, otherwise false and error message
WildStar/id(string) - prints to Lua stdio (stdio not usable from UI)
WildStar/id(v1, v2) returns (boolean) - checks if v1 and v2 are equal, bypassing any metamethods
WildStar/id(table, index) - gets real value of table[index], bypassing any metamethods
WildStar/id(table, index, value) - sets real table[index] to value, bypassing any metamethods
WildStar/id(nIndex, list) returns (number or item) - gets count if 'index' is "#", or item at 'index'
WildStar/id(function or integer, table) - sets table representing the stack frame for given function or stack level
WildStar/id(aObject, mtable) returns (any) - sets the metatable of a table or userdata, returns aObject
WildStar/id(any) - gets type of variable as a string: "number", "string", "table", "function" or "userdata"
WildStar/id(table[, nStart][, nEnd]) returns (...) - converts indexed values of table to an argument list
WildStar/id(function, fCallback) returns (boolean,results) - true if successfully executes function, or executes fCallback and returns false. results are return values of function or fCallback

WS UI offers these standard Lua global data vars

WildStar/id [table] - canonical list of variables in global scope, including ones in this reference
WildStar/id [string] = "Lua 5.1" - printable Lua runtime version number

Strings[edit | edit source]

These string functions are Carbine custom, shorthand references to or a part of the Lua string library "string." See StringLibraryTutorial for more info.

WildStar/id(any[, base]) returns (number) - converts any. nil if fails. non-10 bases accept only unsigned ints
WildStar/id(any) - converts to a string, or nil if fails.

These are custom string functions available in WS but not normal Lua.

WildStar/id(any[, nPlaces]) returns (number) - converts to number and rounds, default places 0. (Carbine)

WildStar/id[edit | edit source]

WildStar/id(string[, index]) - gets internal Lua char (byte size number) of the i-th element of string
WildStar/id(nByte[, ...]) - compiles one or more Lua chars (byte size numbers) into a string
WildStar/id(function) - returns a binary representation of the given function code as a string
WildStar/id(s, pattern[, start[, plain]]) - find match for pattern on s. optional offset or plain sub-string
WildStar/id(sFormat[, value[, ...]]) - gets string of values formatted by sFormat format string
WildStar/id(s, pattern) returns iterator function for pattern over the string s. (deprecated, same as gmatch)
WildStar/id(s, pattern) gets iterator that returns the next captures each call, using pattern on string s
WildStar/id(s, pattern, replacement[, nLimit]) - globally substitute pattern for replacement in string
WildStar/id(string) - return length of the string in Lua chars (byte size numbers)
WildStar/id(string) - return string converted to all lower case
WildStar/id(string, pattern[, initpos]) - similar to strfind, but only returns the matches, not the positions
WildStar/id(string, n [, sep]) - return a string which is n copies of s, with optional delimeter sep
WildStar/id(string) - reverses a string
WildStar/id(string, index[, endIndex]) - return a substring of string starting at index
WildStar/id(string) - return string converted to all upper case

Tables[edit | edit source]

These table functions are shorthand references to the Lua table library (which is available via "table.", see TableLibraryTutorial for more info). Be aware that some table functions only work with tables with proper numerical indexes, where {[1] = "x", [3] = "y"} would have only one indexed value at 1. Not being aware of this fact is one major causes for bugs in code written in Lua.

WildStar/id(table) - gets an iterator of type integer to traverse a table
WildStar/id(table) - gets an iterator to traverse a table

WildStar/id[edit | edit source]

WildStar/id(table [, sep [, i [, j]]]) returns (string) - build a string from table elements
WildStar/id(table, function) - runs function for each name-value in table. (deprecated, use pairs)
WildStar/id(table, function) - runs function for each index in table, in order. (deprecated, use ipairs)
WildStar/id(table) returns (number) - gets cached size of table array values. (deprecated, use #table operator)
WildStar/id(table[, pos], value) - insert value into table at pos. default is end of table
WildStar/id(table) returns (number) - last positive numerical index. requires scan of whole table
WildStar/id(table[, pos]) returns (any) - remove and return element at pos. default is last entry in table
WildStar/id(table, number) - attempts to set cached table size value. (deprecated, like getn)
WildStar/id(table[, comp]) - sort the elements in the table in-place, optionally using a custom comparator.

Arithmetic[edit | edit source]

WildStar/id[edit | edit source]

WildStar/id(value) - returns the absolute value of the number
WildStar/id(value) - returns the arc cosine of the value in degrees
WildStar/id(value) - returns the arc sine of the value in degrees
WildStar/id(value) - returns the arc tangent of the value in degrees
WildStar/id(y, x) - returns the arc tangent of Y/X in degrees
WildStar/id(value) - returns the ceiling of value
WildStar/id(degrees) - returns the cosine of the degree value
WildStar/id(value) - returns the hyperbolic cosine of value
WildStar/id(radians) - returns the degree equivalent of the radian value
WildStar/id(value) - returns the exponent of value
WildStar/id(value) - returns the floor of value
WildStar/id(x, y) - returns remainder of division of x by y, rounding quotient toward zero
WildStar/id(num) - Extract mantissa and exponent from a floating point number
WildStar/id = 1.#INF
WildStar/id(value, exponent) - Load exponent of a floating point number
WildStar/id(value) - returns the natural logarithm (log base e) of value
WildStar/id(value) - returns the base-10 logarithm of value
WildStar/id(value[, values...]) - returns the numeric maximum of the input values
WildStar/id(value[,values...]) - returns the numeric minimum of the input values
WildStar/id(a, b) - returns the integer remainder of a divided by b
WildStar/id(x) - returns two numbers. integral part of x, and fractional part of x
WildStar/id = 3.1415926535898
WildStar/id(x, y) - returns x to power of y. can also use operator ^, as expression x^y
WildStar/id(degrees) - returns the radian equivalent of the degree value
WildStar/id([ [lower,] upper]) - returns a random number, optionally bounded integer value
WildStar/id(x) - sets x "seed" for random generator. seed always makes same sequence
WildStar/id(degrees) - returns the sine of the degree value
WildStar/id(value) - returns the hyperbolic sine of value
WildStar/id(x) - returns the square root of x
WildStar/id(degrees) - returns the tangent of the degrees value
WildStar/id(x) - returns the hyperbolic tangent of x

Bitwise[edit | edit source]

WildStar includes the Lua BitLib library, which is available via "bit32." table, which provides access to C-style bitwise manipulation operators. This library uses the 32-bit integer size, e.g. bit32.lshift(2147483648, 1) = 0, because 1000 0000 0000 0000 0000 0000 0000 0000 -> 0000 0000 0000 0000 0000 0000 0000 0000.

WildStar/id[edit | edit source]

WildStar/id(a, b) - returns a shifted arithmetically right b places
WildStar/id(w1, ...) - returns the bitwise and of the w's
WildStar/id(a) - returns the one's complement of a
WildStar/id(w1, ...) - returns the bitwise or of the w's
WildStar/id(···) returns (boolean) - true if bitwise and of all operands is not zero
WildStar/id(w1, ...) - returns the bitwise exclusive or of the w's
WildStar/id(n, start[, width]) - gets set of bits from n. start is 0-31. default width is 1
WildStar/id(x, disp) - returns x rotated left disp places
WildStar/id(a, b) - returns a shifted left b places
WildStar/id(n, v, start [, width]) - gets copy n with bits set from value v. start is 0-31. default width is 1
WildStar/id(x, disp) - returns x rotated right disp places
WildStar/id(a, b) - returns a shifted logically right b places

System[edit | edit source]

The system functions whaich are generally just a subset of the Lua standard os library. Alternatively the WildStar/api and WildStar/api libraries offer standard WS UI date and time functions, like WildStar/api, WildStar/api and WildStar/api.

WildStar/id[edit | edit source]

WildStar/id() - returns an approximation in seconds of CPU time used by the program
WildStar/id(t2, t1) - returns diff in seconds between t1 and t2. in Windows and others is exactly t2-t1
WildStar/id([table]) returns (number) - current machine time, or from date table, in secs since 00:00 Jan 1 1970
WildStar/id([format[, time]]) returns (table or string) - gets table or format string, of current or time date

Debugging[edit | edit source]

The debugging functions which are generally just a subset of the Lua stardard debug library.

WildStar/id[edit | edit source]

WildStar/id() enters an interactive mode with the user (not useable from UI)
WildStar/id([thread]) - gets thread's hook settings: function, mask, count
WildStar/id([thread,] f [, what]) - gets table of information about a function f as: nups, what, func, lastlinedefined, source, currentline, namewhat, linedefined, short_src
WildStar/id([thread,] nLevel, nLocal) - gets name and value of the variable at nLocal in stack nLevel
WildStar/id(obj) returns (mtable) - gets metatable for table or userdata (same as _G.getmetatable)
WildStar/id() - returns the registry table (not useable from UI)
WildStar/id(f, nUp) - gets name, value of upvalue nUp of function f. nil if no upvalue
WildStar/id([thread,] f, sMask [, count]) - sets function f as to be called for event sMask
WildStar/id([thread,] nLevel, nLocal, value) - assigns value to nLocal at stack nLevel. gets name, or nil if no nLocal. throws if no nLevel
WildStar/id(obj, mtable) returns (obj) - sets metatable for table or userdata (same as _G.setmetatable)
WildStar/id(f, nUp, value) - assigns value to upvalue nUp of function f. gets name or nil if no upvalue
WildStar/id([thread,] [sMessage [, nLevel]]) - gets string with a trace of call stack, starting at nLevel.

References added to debug. in WildStar

WildStar/id(any) returns (table) - stack frame of given function or stack level (same as _G.getfenv)
WildStar/id(function or nLevel, table) - sets table for stack frame for func or level (same as _G.setfenv)

Modules[edit | edit source]

The modules functions which are generally just a subset of the Lua stardard package library. Other than using the require keyword to access standard Carbine WS modules, the WildStar/api library should be used instead for AddOns and Lua libraries, like WildStar/api and WildStar/api.

WildStar/id(name [, ···]) - sets this Lua chunk as named Lua module, in package.loaded[name] and _G[name]
WildStar/id(modname) - loads a module as reference in this Lua chunk, from package.loaded[name] or loader

WildStar/id[edit | edit source]

WildStar/id [string] = "\\\n;\n?\n!\n-" - list of chunk string seperators (undocumented)
WildStar/id [string] = ".\?.dll;!\?.dll;!\loadall.dll" - require path for C loader
WildStar/id [table] - table used by require for modules are already loaded
WildStar/id [table] - table used by require for how to load modules
WildStar/id(libname, sFunc) - loads and links a C Lua library
WildStar/id [string] = ".\?.lua;!\lua\?.lua;!\lua\?\init.lua;!\?.lua;!\?\init.lua" - require path for Lua loader
WildStar/id [table] - table to store loaders for specific modules
WildStar/id(module) - sets metatable on module so inherits from global environment. option to module()

See also[edit | edit source]

  • Lua - which has plenty of links to other reference material
  • API types - with a list of Lua types and 'psudo-types' used in WS
Community content is available under CC-BY-SA unless otherwise noted.