Function Dump: Difference between revisions

From Legacy Roblox Wiki
Jump to navigationJump to search
>Bullshiiter
No edit summary
>JulienDethurens
No edit summary
 
(148 intermediate revisions by 7 users not shown)
Line 1: Line 1:
=Standard Lua Function libraries=
This is the location for the listing of all of the Lua based functions, ones that are built into the system. These are not to be confused with user-defined functions, ones that are made in your own code. These are changed/added to by the ROBLOX staff for the base Lua code, and cannot be overwritten or edited.


Directly off of the [http://www.lua.org/manual/5.1/manual.html#5 Lua Help Manual. ] These are all the functions included in the standard libraries that Roblox has built-in. Some functions have been removed, to preserve security.
These are broken up into 6 groups, where you can find more information about what you want to do on each page.


 
;[[Function Dump/Core Functions|Core Functions]]
 
:These are what help the Lua code run on Roblox. In here you can find listings for file manipulation, metatables, error handling and other basic system functions. If you aren't sure where the function is listed, look here first.
==Coroutine Manipulation==
;[[Function Dump/Coroutine Manipulation|Coroutine Manipulation]]
 
:Here is the listing for coroutine manipulation, which allows you to set several things working at once and for a limited time of running. Take a look [http://en.wikipedia.org/wiki/Coroutine here] and [http://www.lua.org/manual/5.1/manual.html#2.11 here] for more detailed explanations of coroutines.
The operations related to coroutines comprise a sub-library of the basic library and come inside the table coroutine. See §2.11 for a general description of coroutines.
;[[Function Dump/String Manipulation|String Manipulation]]
 
:These functions let you do fancy things with words, such as changing the order of a string, comparing two strings and using the chat commands to do all kinds of fun stuff.
 
;[[Function Dump/Table Manipulation|Table Manipulation]]
'''coroutine.create (f)'''
:This section tells you how to play around with long lists of things and do fun stuff as well, such as reordering a table, sorting them, and searching for a specific item in a table.
 
;[[Function Dump/Mathematical Functions|Mathematical Functions]]
 
:Just as the name implies, this is a listing of all the math functions in Roblox Lua. Here you can find a listing of everything from trigonometry to a value so huge it doesn't have a real number.
Creates a new coroutine, with body f. f must be a Lua function. Returns this new coroutine, an object with type "thread".
;[[Function Dump/Roblox Specific Functions|Roblox Specific Functions]]
 
:These are functions that are only found in Roblox, and are used for a variety of things.
 
'''coroutine.resume (co [, val1, ···])'''
 
 
Starts or continues the execution of coroutine co. The first time you resume a coroutine, it starts running its body. The values val1, ··· are passed as the arguments to the body function. If the coroutine has yielded, resume restarts it; the values val1, ··· are passed as the results from the yield.
 
If the coroutine runs without any errors, resume returns true plus any values passed to yield (if the coroutine yields) or any values returned by the body function (if the coroutine terminates). If there is any error, resume returns false plus the error message.
 
 
'''coroutine.running ()'''
 
 
Returns the running coroutine, or nil when called by the main thread.
 
 
'''coroutine.status (co)'''
 
 
Returns the status of coroutine co, as a string: "running", if the coroutine is running (that is, it called status); "suspended", if the coroutine is suspended in a call to yield, or if it has not started running yet; "normal" if the coroutine is active but not running (that is, it has resumed another coroutine); and "dead" if the coroutine has finished its body function, or if it has stopped with an error.
 
 
'''coroutine.wrap (f)'''
 
 
Creates a new coroutine, with body f. f must be a Lua function. Returns a function that resumes the coroutine each time it is called. Any arguments passed to the function behave as the extra arguments to resume. Returns the same values returned by resume, except the first boolean. In case of error, propagates the error.
 
 
'''coroutine.yield (···)'''
 
 
Suspends the execution of the calling coroutine. The coroutine cannot be running a C function, a metamethod, or an iterator. Any arguments to yield are passed as extra results to resume.
 
----
 
 
==Table Manipulation==
 
This library provides generic functions for table manipulation. It provides all its functions inside the table table.
 
Most functions in the table library assume that the table represents an array or a list. For these functions, when we talk about the "length" of a table we mean the result of the length operator.
 
 
'''table.concat (table [, sep [, i [, j]]])'''
 
 
Given an array where all elements are strings or numbers, returns table[i]..sep..table[i+1] ··· sep..table[j]. The default value for sep is the empty string, the default for i is 1, and the default for j is the length of the table. If i is greater than j, returns the empty string.
 
 
'''table.insert (table, [pos,] value)'''
 
 
Inserts element value at position pos in table, shifting up other elements to open space, if necessary. The default value for pos is n+1, where n is the length of the table (see §2.5.5), so that a call table.insert(t,x) inserts x at the end of table t.
 
 
'''table.maxn (table)'''
 
 
Returns the largest positive numerical index of the given table, or zero if the table has no positive numerical indices. (To do its job this function does a linear traversal of the whole table.)
 
 
'''table.remove (table [, pos])'''
 
 
Removes from table the element at position pos, shifting down other elements to close the space, if necessary. Returns the value of the removed element. The default value for pos is n, where n is the length of the table, so that a call table.remove(t) removes the last element of table t.
 
 
'''table.sort (table [, comp])'''
 
 
Sorts table elements in a given order, in-place, from table[1] to table[n], where n is the length of the table. If comp is given, then it must be a function that receives two table elements, and returns true when the first is less than the second (so that not comp(a[i+1],a[i]) will be true after the sort). If comp is not given, then the standard Lua operator < is used instead.
 
The sort algorithm is not stable; that is, elements considered equal by the given order may have their relative positions changed by the sort.
 
----
 
==Mathematical Functions==
 
This library is an interface to the standard C math library. It provides all its functions inside the table math.
 
 
'''math.abs (x)'''
 
 
Returns the absolute value of x.
 
 
'''math.acos (x)'''
 
 
Returns the arc cosine of x (in radians).
 
 
'''math.asin (x)'''
 
 
Returns the arc sine of x (in radians).
 
 
'''math.atan (x)'''
 
 
Returns the arc tangent of x (in radians).
 
 
'''math.atan2 (y, x)'''
 
 
Returns the arc tangent of y/x (in radians), but uses the signs of both parameters to find the quadrant of the result. (It also handles correctly the case of x being zero.)
 
 
'''math.ceil (x)'''
 
 
Returns the smallest integer larger than or equal to x.
 
 
'''math.cos (x)'''
 
Returns the cosine of x (assumed to be in radians).
 
 
'''math.cosh (x)'''
 
 
Returns the hyperbolic cosine of x.
 
 
''''math.deg (x)'''
 
 
Returns the angle x (given in radians) in degrees.
 
 
'''math.exp (x)'''
 
 
Returns the the value ex.
 
 
'''math.floor (x)'''
 
 
Returns the largest integer smaller than or equal to x.
 
 
'''math.fmod (x, y)'''
 
 
Returns the remainder of the division of x by y.
 
 
'''math.frexp (x)'''
 
 
Returns m and e such that x = m2e, e is an integer and the absolute value of m is in the range [0.5, 1) (or zero when x is zero).
 
 
'''math.huge'''
 
 
The value HUGE_VAL, a value larger than or equal to any other numerical value.
 
 
'''math.ldexp (m, e)'''
 
 
Returns m2e (e should be an integer).
 
 
'''math.log (x)'''
 
 
Returns the natural logarithm of x.
 
 
'''math.log10 (x)'''
 
 
Returns the base-10 logarithm of x.
 
 
'''math.max (x, ···)'''
 
 
Returns the maximum value among its arguments.
 
 
'''math.min (x, ···)'''
 
 
Returns the minimum value among its arguments.
 
 
'''math.modf (x)'''
 
 
Returns two numbers, the integral part of x and the fractional part of x.
 
 
'''math.pi'''
 
 
The value of pi.
 
 
'''math.pow (x, y)'''
 
 
Returns xy. (You can also use the expression x^y to compute this value.)
 
 
'''math.rad (x)'''
 
 
Returns the angle x (given in degrees) in radians.
 
 
'''math.random ([m [, n]])'''
 
 
This function is an interface to the simple pseudo-random generator function rand provided by ANSI C. (No guarantees can be given for its statistical properties.)
 
When called without arguments, returns a pseudo-random real number in the range [0,1). When called with a number m, math.random returns a pseudo-random integer in the range [1, m]. When called with two numbers m and n, math.random returns a pseudo-random integer in the range [m, n].
 
 
'''math.randomseed (x)'''
 
 
Sets x as the "seed" for the pseudo-random generator: equal seeds produce equal sequences of numbers.
 
 
'''math.sin (x)'''
 
 
Returns the sine of x (assumed to be in radians).
 
 
'''math.sinh (x)'''
 
 
Returns the hyperbolic sine of x.
 
 
'''math.sqrt (x)'''
 
 
Returns the square root of x. (You can also use the expression x^0.5 to compute this value.)
 
 
'''math.tan (x)'''
 
 
Returns the tangent of x (assumed to be in radians).
 
 
'''math.tanh (x)'''
 
 
Returns the hyperbolic tangent of x.
----


[[Category:Reference Pages]]
[[Category:Reference Pages]]

Latest revision as of 23:46, 11 March 2012

This is the location for the listing of all of the Lua based functions, ones that are built into the system. These are not to be confused with user-defined functions, ones that are made in your own code. These are changed/added to by the ROBLOX staff for the base Lua code, and cannot be overwritten or edited.

These are broken up into 6 groups, where you can find more information about what you want to do on each page.

Core Functions
These are what help the Lua code run on Roblox. In here you can find listings for file manipulation, metatables, error handling and other basic system functions. If you aren't sure where the function is listed, look here first.
Coroutine Manipulation
Here is the listing for coroutine manipulation, which allows you to set several things working at once and for a limited time of running. Take a look here and here for more detailed explanations of coroutines.
String Manipulation
These functions let you do fancy things with words, such as changing the order of a string, comparing two strings and using the chat commands to do all kinds of fun stuff.
Table Manipulation
This section tells you how to play around with long lists of things and do fun stuff as well, such as reordering a table, sorting them, and searching for a specific item in a table.
Mathematical Functions
Just as the name implies, this is a listing of all the math functions in Roblox Lua. Here you can find a listing of everything from trigonometry to a value so huge it doesn't have a real number.
Roblox Specific Functions
These are functions that are only found in Roblox, and are used for a variety of things.