Jump to content

User:Thieving6/X-FI 2 Lua

From Wikipedia, the free encyclopedia

Creative Zen X-FI2 Lua Function List

[edit]

Non XFi2 function information found here: http://www.lua.org/manual/5.1/

What's needed

[edit]

These functions need more information:

  • image.setbg()

String table

[edit]

string.byte(string, [i], [j]): byte, byte, ...;

 Returns the byte code of the character from the
 i-th to j-th character of the string.
 -string.byte("ABCDE",2,3) = 66, 67

string.char(i, [j], [k], [...]): string;

 Returns the string representation of a list of
 numerical byte codes.
 -string.char(65,66,67) = "ABC"

string.dump(function): string;

 Returns a binary representation of the given
 function. The opposite of loadstring().

string.find(string, pattern, [i], [plain]): string;

 Returns the index in the string of the first
 location of the pattern. Optionally start search
 at i. Turn on and off regular expression parsing
 with the plain bool.
 -string.find("Hello world!","llo") = 3
 -string.find("Hello world!","l",7) = 10

string.format(formatstring, var1, [var2], [...]): string;

 Fills formatstring with var1, var2, etc.
 c, d, e, f, g, o, u, X, x
 %c: character
 %d: signed integer
 %e: scientific notation
 %f: float
 %g: use shorter of %e or %f
 %o: signed octal
 %u: unsigned integer
 %x: unsigned hexadecimal integer
 -string.format("It has been %d days.",5) = "It has been 5 days."

string.gfind(string, pattern): function;

 Returns an iterator function for "for in" loops.

string.gmatch(string, pattern): function;

 Returns a iterator function for "for in" loops.
 -for word in string.gmatch("Hello World", "%a+") = "Hello", "World"

string.gsub(string, pattern, replace, [n]): string;

 Returns a function that replaces all instances
 of the pattern with the replace limited to n
 substitutions.
 -string.gsub("Hello World","l","L",2) = "HeLLo World"

string.len(string): integer;

 Returns the length of the string. Returns 0 if
 the string is empty or null.
 -string.len("Hello") = 5

string.lower(string): string;

 Returns the string with all uppercase characters
 transformed to lowercase ones.
 -string.lower("Hello World") = "hello world"

string.match(string, pattern, [init]): string;

 Returns extracted substring matching patter from
 string starting optionally at init.
 -string.match("Hello 2 the World","%d+ %a+") = "2 the"

string.rep(string, n): string;

 Returns a string that has n repetitions of string.
 -string.rep("Hello World ",2) = "Hello World Hello World "

string.reverse(string): string;

 Returns the string in reverse order.
 -string.reverse("Hello World") = "dlroW olleH"

string.sub(string, i, [j]): string;

 Returns a substring of the string passed starting
 at i and ending at j. If j is not given it will end
 at the end of the string.
 -string.sub("Hello World",4) = "lo World"
 -string.sub("Hello World",4,6) = "lo "

string.upper(string): string;

 Returns string with all lowercase characters
 transformed into uppercase ones.
 -string.upper("Hello World") = "HELLO WORLD"


Package table

[edit]

package.cpath(): string;

 The path used by require to search for a C loader.

package.loaded(): table;

 A table used by require to control which modules are already
 loaded.
 -package.loaded["module.lua"] = nil;

package.loaders(): table;

 A table used by require to search for module loaders.

package.loadlib(libname, funcname): function;

 Links the library libname and locates the function funcname.
 It returns the function as a C function.

package.path(): string;

 The path used by require to search for a Lua loader.

package.preload(): table;

 A table to store loaders for specific modules.

package.seeall(module);

 Sets a metatable for module with it's __index field referring
 to the global environment.


Image table

[edit]

image.close();

 Closes the image object you created with either load() or
 create().

image.draw(x, y, [x2], [y2]);

 Draws the image on the screen at coordinates (x,y) by (x2,y2).
 Can stretch image in this fashion.
 -myimage = image.load("test.bmp");
 -myimage:draw(0,0);

image.draw(x,y,[imx],[imy],[imw],[imh]);

 x, y = offset of image on screen (where would be left upper corner of full image positioned on screen)
 imx, imy = screen coordinates of upper left corner of scissor rectangle
 imw, imh = width and height of scissor rectangle
 -myimage = image.load("test.bmp");
 -myimage:draw(0,0,0,0,32,32);

image.create(width,height,[...]): image;

 Creates image object. Its size depends on parameters.
 -myimage = image.create(100,100);
 -myimage:draw(10,10);

image.setbg(?): ?;

 ?
 -?

image.width(): integer;

 Returns the width of the image obj it referrs to.
 -myimage = image.load("test.bmp");
 -myimage:draw(0,0,myimage:width(),myimage:height());

image.height(): integer;

 Returns the height of the image obj it refers to.
 -myimage = image.load("test.bmp");
 -myimage:draw(0,0,myimage:width(),myimage:height());

image.setresource(filename);

 Sets the resource file for the image library to use in subsequent
 calls to image.load().
 -image.setresource("myres.bin");
 -myimage1 = image.load("myres/myimage.png");

image.load(imagename): image;

 Opens the image at path imagename and returns the image obj.
 -myimage = image.load("test.bmp");

image.fill(color);

 Fills an image with a color.
 -myimage = image.create(100,100);
 -myimage.fill(color.new(255,0,0));

OS table

[edit]

os.clock(): integer;

 Returns an approximation of the amount in secons of CPU time used by
 the program.

os.date([format], [time]): string/table;

 Returns a string or a table containing date an time formatted to
 the given string format.
 -os.date() = "12/21/2012 12:12PM";

os.difftime(time1, time2): integer;

 Returns the number of sectons from time1 and time2.

os.exit([exitcode]);

 Exits the lua interpreter and returns to the main application.
 Optionally you can return an exit code for the interpreter.

os.getenv(varname): variant;

 Returns the vale of the process enviornment variable varname.
 Nil if undefined.

os.remove(filename): integer, string;

 Deletes the file or directory with the name filename.
 Directories must be empty to be removed. If the function fails,
 it returns 0, plus a string describing the error.
 -os.remove("file.jpg");

os.rename(oldname, newname): integer, string;

 Renames file or directory from oldname to newname. If the function
 fails, it returns 0, plus a string describing the error.
 -os.rename("myfile2.jpg","myfile1.jpg");

os.setlocale(locale, [category]): string;

 Sets the current locale of the program. Category is an optional
 string describing which category to change: "all", "collate",
 "ctype", "monetary", "numeric", or "time"; the default category
 is "all".

os.time([table]): integer;

 See os.date().

os.ostime(): number;

 Returns seconds that have passed since 01/01/1970 on the Simulator;
 Returns milliseconds that have passed since os boot on the Zen.
 -local oldtime = os.ostime();
 -os.sleep(100);
 -local newtime = os.ostime();
 -print("Zen running for " .. tostring((newtime - oldtime) / 1000) .. " seconds.");

os.sleep(time);

 Halts processing of the interpreter for (time * 10)ms.
 -os.sleep(100); --Sleeps for 1 second

os.wait(ms);

 Same as os.sleep() only in intervals of ms.

Button table

[edit]

button.home(): bytebool;

 Checks the message queue for the press of the home button.
 -if (control.read() == 1) and (control.isButton() == 1) and
  (button.home() == 1) then

button.power(): bytebool;

 Checks the message queue for the press of the power button.
 -if (control.read() == 1) and (control.isButton() == 1) and
 (button.power() == 1) then

button.up(): bytebool;

 Checks to see if the pressed button has been released, removes the
 message from the queue.
 -if (control.read() == 1) and (control.isButton() == 1) and
 (button.power() == 1) and (button.up() == 1) then

button.hold(): bytebool;

 Checks to see if the pressed button has been held, removes the
 message from the queue.
 -if (control.read() == 1) and (control.isButton() == 1) and
 (button.power() == 1) and (button.hold() == 1) then

button.event(): integer;

 Returns integer representing type of button event.
 Probably bitwise coded, because returned numbers are power of two.
 Results:
   button pressed down = 4
   button clicked = 8
   button released = 1
   button hold = 16
   button released after holdig = 8
 (tested only on home button on simulator)
 removes the message from the queue.
 - if(control.read()==1) then
      if(control.isButton()==1) then
         inputType = button.event()
      end
   end

button.click(): bytebool;

 Checks to see if the pressed button has been clicked, removes the
 message from the queue.
 -if (control.read() == 1) and (control.isButton() == 1) and
 (button.power() == 1) and (button.click() == 1) then

Touch table

[edit]

touch.click(): bytebool;

 Checks to see if the screen has been tapped, removes the message
 from the queue.
 -if (control.read() == 1) and (control.isTouch() == 1) and
 (touch.click() == 1) then

touch.hold(): bytebool;

 Checks to see if the screen has been pressed for a period of time,
 removes the message from the queue.
 -if (control.read() == 1) and (control.isTouch() == 1) and
 (touch.hold() == 1) then

touch.up(): bytebool;

 Checks to see if the screen has been released from a tap,
 removes the message from the queue.
 -if (control.read() == 1) and (control.isTouch() == 1) and
 (touch.up() == 1) then


touch.move(): bytebool;

 Checks to see if their is movement of touch on the screen,
 removes the message from the queue.
 -if (control.read() == 1) and (control.isTouch() == 1) and
 (touch.move() == 1) then


touch.down(): bytebool;

 Checks to see if the screen has been pressed and not released,
 removes the message from the queue.
 -if (control.read() == 1) and (control.isTouch() == 1) and
 (touch.down() == 1) then

touch.event(): integer;

 Returns integer representing type of touch screen event.
 Probably bitwise coded, because returned numbers are power of two.
 Results:
   touch down = 2
   touch click = 4
   touch hold = 16
   touch move = 32
 (tested only on simulator)
 removes the message from the queue.
 - if(control.read()==1) then
      if(control.isTouch()==1) then
         inputType = touch.event()
      end
   end

touch.pos(): integer, integer;

 If there has been a touch screen event, return the X, Y coords
 of the event.
 -x, y = touch.pos();

Wav table

[edit]

wav.load(wavefile): wavobj;

 Loads an acceptable wave audio file and creates a wav object.
 -mysound = wav.load("mywave.wav");

wav.play(wavobj, [time]);

 Starts playing the audio file. For time amound of ms.
 Call with a time of -1 to stop playing.
 -mysound = wav.load("mywave.wav");
 -mysound:play();

wav.close(wavobj);

 Stops and closes the wavobj. Do not call if the file is still
 playing, you will crash your player.
 -mysound = wav.load("mywave.wav");
 -mysound.close();

wav.time(wavobj): integer

 Returns the length of the wav file in ms.

Control table

[edit]

control.read([wait]): bytebool;

 Determines if there is a message in the queue and reads it.
 If wait = 1 then control.read() won't return until an event
 has been activated.
 -if (control.read() == 1) then

control.isSensor(): bytebool;

 Determines if the read message is a accelerometer message.
 -if (control.read() == 1) and (control.isSensor() == 1) then

control.isTouch(): bytebool;

 Determines if the read message is a touch message.
 -if (control.read() == 1) and (control.isTouch() == 1) then

control.isButton(): bytebool;

 Determines if the read message is a button message.
 -if (control.read() == 1) and (control.isButton() == 1) then

Screen table

[edit]

screen.clear();

 Clears the memory to screen buffer, initializes for drawing.
 -screen.clear();

screen.update();

 Moves the screen memory buffer onto the screen and refreshes
 the screen. X-Fi2's LCD has a refresh rate of 30fps.
 -screen.update();

screen.width(): integer;

 Returns the current screen width. Changes with the orientation.

screen.drawline(x, y, x2, y2, c);

 Draws a line on the screen memory buffer from (x,y) to (x2,y2) in
 the color c.
 -screen.drawline(0,0,400,240,clBlack);

screen.backlight(percent, [fade]);

 Changes the screens backlight to percent of maximum brightness.
 If fade is 1 then the backlight will change progressively to the
 new percent.
 -screen.backlight(100);

screen.orientation([orientation]): byte;

 When passed with no parameters it returns the current orientation.
 0 = 0 degrees
 1 = 90 degrees
 2 = 180 degrees
 3 = 270 degrees

screen.height(): integer;

 Returns the current screen height. Changes with the orientation.

screen.drawpixel(x, y, c);

 Turns a pixel at (x,y) on the memory buffer to color c.
 -screen.drawpixel(100,100,clRed);

screen.fillrect(x, y, w, h, c);

 Fills a rectangle starting at (x,y) to (x + w,y + h) on the
 memory buffer to color c.
 -screen.fillrect(0,0,400,240,clBlack);

screen.drawrect(x, y, x2, y2, c);

 Draws an outline of a rectangle on the memory buffer in the
 color c.
 -screen.drawrect(0,0,400,240,clWhite);

Color table

[edit]

color.a(colorobj): number;

 Returns the alpha (transparency) value of a color object.
 -MyColorAlpha = color.a(MyColor);

color.r(colorobj): number;

 Returns the red value of a color object.
 -MyColorRed = color.r(MyColor);

color.b(colorobj): number;

 Returns the blue value of a color object.
 -MyColorBlue = color.b(MyColor);

color.g(colorobj): number;

 Returns the green value of a color object.
 -MyColorGreen = color.g(MyColor);

color.new(r, g, b, [a]): colorobj;

 Creates a new color object to use with many other functions.
 Uses standard (r,g,b) format. You can provide an
 alpha(transparency) value as well.
 -clWhite = color.new(255,255,255);
 -clGreen = color.new(0,255,0);

Text table

[edit]

text.color(colorobj);

 Changes the current text color brush to colorobj.
 -text.color(clWhite);

text.size(h): integer;

 Changes the current text size height to h. Returns old size.
 -text.size(25);
 -osize = text.size(20) --returns 25

text.draw(x, y, text, [alignment], [alignmentwidth]);

 Draws text to the memory buffer at the position (x,y) with optional
 alignment("right","center","left") with an optional alignmentwidth.
 -text.draw(0,0,"hello");
 -text.draw(0,0,"Hello","center",400);


Audio table

[edit]

audio.mute(b);

 If called with the parameter 1 then it mutes the volume. When
 called with 0 it unmutes it.

audio.channel([channel]): integer;

 Get or set the channel. If no parameter then return current
 channel. 1 is speaker. 0 is headphone. 

audio.beep(freq,dur);

 Generates and plays a tone with a frequency of freq and a
 duration of dur(in ms). Play is asynchronous but is unstoppable,
 even with a second call.
 -audio.beep(1000,60000);

audio.volume(n): integer;

 Sets the audio volume from 0 to 25. Returns the current audio
 volume.

Accelerometer table

[edit]

accelerometer.get_samplerate(): integer;

 Returns the current number of ms between two accelerometer readings.

accelerometer.get_senddatatype(): string;

 Returns a string that describes the data collected during accelerometer readings.
 Results:
   "xyz" = the acceleration in the x, y, and z directions
   "orientation" = the current orientation of the device
   "all" = both "xyz" and "orientation"

accelerometer.getdata(type): [integer], [integer], [integer], [integer];

 Returns based on the parameter type string. All acceleration results are
 between -15.0 and 15.0(approx). 
   "x" = acceleration in the x direction
   "y" = acceleration in the y direction
   "z" = acceleration in the z direction
   "xyz" = acceleration in the x, y, and z direction
   "orientation" = the current orientation of the device
   "all" = both "xyz" and "orientation"
 The type string must match or be included in the call to get_senddatatype()
 The orientation of the device can return:
   "1" = 0 degrees(landscape/normal)
   "2" = 180 degrees
   "3" = 90 degrees
   "4" = 270 degrees
   "5" = screen is facing up
   "6" = screen is facing down
 File:Xyz zfi2 accelerometer.png

accelerometer.close(): integer;

 Closes the accelerometer and stops taking readings. Must be called
 before application exits or player enters idle shutdown. Your player
 will crash otherwise!

accelerometer.set_samplerate(ms): integer;

 Sets the number of ms between two accelerometer readings. Must be between
 100-1000. Returns 0 if successful.

accelerometer.set_senddatatype(type): integer;

 Sets what data is collected during accelerometer readings.
 type:
   "xyz" = the acceleration in the x, y, and z directions
   "orientation" = the current orientation of the device
   "all" = both "xyz" and "orientation"

accelerometer.open(): integer;

 Must be called to use the accelerometer. Returns 0 if successful.
 Shove it in a loop for safe keeping.
 -while (accelerometer.open() ~= 0) do
    os.sleep(5);
  end;

IO table

[edit]

io.close([fileobj]);

 Closes the file specified in the fileobj. Without a parameter
 it closes the default file.

io.flush();

 Flushes the default file output buffer.

io.input([filename] [fileobj]): fileobj;

 When filename is given it opens the filename and sets it as the
 default file. When a fileobj is given it sets fileobj as the
 default file. When no parameters it returns the current default
 file.

io.lines([filename]): function;

 Opens the given filename in read mode and returns an iterator
 function that returns a new line from the file. If no filename
 is given it uses the default file.
 -for line in io.lines(filename) do

io.open(filename, [mode]): fileobj, string;

 Opens a file in mode(read only default). Returns fileobj or nil
 plus error message. Mode can be:
 "r": read mode
 "w": write mode
 "a": append mode
 "r+": update mode, data is preserved
 "w+": update mode, data is erased
 "a+": update mode, data is preseved, writing at end of file only
 "b": binary mode, used in conjunction with other modes

io.output([filename] [fileobj]): fileobj;

 Sets default output file. See io.input().

io.popen(prog, [mode]): fileobj;

 Seems to be unsupported on the X-Fi 2
 Starts program prog and returns fileobj that you use
 to read data from the program. "r"/"w" only. See io.open().

io.read(format): variant;

 Reads the input file according to a given format.
 "*n": reads a number
 "*a": reads the whole file
 "*l": reads the next line
 integer: reads a string with up to number of characters

io.tmpfile(): fileobj;

 Returns a fileobj for a temporary file.

io.type(obj): string;

 Checks whether obj is a valid file handle. Returns one of the
 following:
 "file": open file obj
 "closed file": closed file obj
 nil: not a file obj

io.write(a, [b], [c], [...]);

 Writes the value of each of the arguments to the output file.
 Arguments must be strings or numbers.

io.stderr(): fileobj;

 File object that allows you to write directly to the error stream.
 -io.stderr:write(message);

io.stdin(): fileobj;

 Same as io.stderror() only for the input file.

io.stdout(): fileobj;

 Same as io.stderror() only for the output file.

Coroutine table

[edit]

coroutine.create(func): threadobj;

 Creates a new coroutine with the main function func.

coroutine.resume(threadobj, [val1], [val2], [...]): boolean, threadobj;

 Starts/Continues a coroutine from the threadobj. On start, valX are
 sent as arguments to the function. On return, valX are results from
 coroutine.yield().

coroutine.running(): threadobj;

 Returns the running coroutine, or nil when called by main thread.

coroutine.status(threadobj): string;

 Returns the status of coroutine from the threadobj. Results can be:
 "running": coroutine is running(that is, it called status)
 "suspended": coroutine is suspended or hasn't been started
 "normal": active but not running(it called another coroutine)
 "dead" if the coroutine has finished or stopped with an error

coroutine.wrap(func): function;

 Creates a new coroutine with the main function func. Returns
 a function that acts as coroutine.resume() for the created
 coroutine.

coroutine.yield([val1], [val2], [...]);

 Suspends execution of the coroutine. All valX are passed
 as extra results to coroutine.resume().


Math table

[edit]

math.abs(n): integer;

 Returns the absolute value of n.

math.acos(n): float;

 Returns the inverse cosine of n.

math.asin(n): float;

 Returns the inverse sine of n.

math.atan(n): float;

 Returns the inverse tangent of n.

math.atan2(n1, n2): float;

 Returns the inverse tangent of n1 divided by n2.

math.ceil(f): integer;

 Returns the number rounded up.

math.floor(f): integer;

 Returns the number rounded down.

math.cos(integer): float;

 Returns the cosine of n.

math.sin(integer): float;

 Returns the sine of n.

math.tan(integer): float;

 Returns the tangent of n.

math.cosh(integer): float;

 Returns the hyperbolic cosine of n.

math.sinh(integer): float;

 Returns the hyperbolic sine of n.

math.tanh(integer): float;

 Returns the hyperbolic tangent of n.

math.deg(f): float;

 Converts f from radians to degrees.

math.rad(f): float;

 Converts f from degrees to radians.

math.exp(n): float;

 Returns the e^n.

math.log(n): float;

 Inverse of math.exp().

math.log10(n): float;

 Returns the base 10 logarithm of a given number.

math.pow(x, y): float;

 Returns x raised to the yth power. The operator ^ does the same
 thing.
 -math.pow(2,5) = 2^5

math.min(n1, [n2], [n3], [...]): float;

 Returns the smallest number from the list of arguments.

math.min(n1, [n2], [n3], [...]): float;

 Returns the largest number from the list of arguments.

math.modf(f): integer, float;

 Returns the integral and fractional parts of f.

math.sqrt(n): float;

 Returns the square root of a given positive number.

math.randomseed(n);

 Sets the seed for the random number generator.

math.random([lower],[upper]): float;

 Based on the arguments it does three things:
 Given none: Generates a number between 0 and 1
 Given upper: Generates a number between 1 and upper
 Given both: Generates a number between loer and upper

math.frexp(f): float, integer;

 Splits and returns the number value into a normalized fraction
 and an exponent. Two values are returned: the first is a value
 always in the range 1/2 (inclusive) to 1 (exclusive) and the
 second is an exponent.

math.ldexp(f, n): float;

 Reverse of math.frexp().

math.huge(): integer;

 Constant and not a function. Returns infinity.

math.pi(): float;

 Constant and not a function. Returns PI.


Debug table

[edit]

debug.debug();

 Enters an interactive mode with the user, running each
 string that the user enters. Using simple commands and other
 debug facilities, the user can inspect global and local variables,
 change their values, evaluate expressions, and so on. A line
 containing only the word cont finishes this function, so that the
 caller continues its execution.

debug.getfenv(o): envirornmentobj;

 Returns the environment of object o.

debug.gethook([thread]): function, object, integer;

 Returns the current hook function, current hook mask, current hook
 count.

debug.getinfo([thread], function, [what]): table;

 Returns a table with information about a function.

debug.getlocal([thread], level, local): string, variant;

 Returns the name and the value of the local variable with index
 local of the function at level "level" of the stack.

debug.getmetatable(o): metatable;

 Returns the metatable of the given object o.

debug.getregistry(): table;

 Returns the registry table.

debug.getupvalue(func, up): string, variant;

 Returns the name and the value of the upvalue with index up
 of the function func.

debug.setenv(o, t): object;

 Sets the enviornment of the given object o to the given table
 t. Returns o.

debug.sethook([thread], hook, mask, count);

 Sets the given function as a hook. The string mask and the number
 count describe when the hook will be called. Mask can have the
 following:
 "c": the hook is called every time Lua calls a function
 "r": the hook is called every time Lua returns from a function
 "l": the hook is called every time Lua enters a new line of code
 With a count other than zero, the hook is called after every
 count intstructions.
 With no arguments it turns off the hook.

debug.setlocal([thread], level, local, value): string;

 Assigns the value "value" to the local variable with the index
 local of the function at level "level" of the stack. Returns the
 name of the local variable.

debug.setmetatable(o, t);

 Sets the metatable for the given object o to the given table t.

debug.setupvalue(func, up, value): string;

 Assigns the value "value" to the upvalue with index up of the
 function func. Returns the name of the upvalue.

debug.traceback([thread], [message], [level]): string;

 Returns a string with a traceback of the vall stack. The optional
 message string is appended at the beginning of the traceback. An
 optional level number tells at which level to start the traceback.


Table table

[edit]

table.concat(t, [sep], [i], [j]): string;

 Given table t, in which all elements are strings or numbers, will
 concat them to a string with a seperator of sep starting,
 optionally, from i to j.

table.insert(t, [pos], [value]);

 Inserte element value at position pos in table t. Default value for
 pos is the last element of the table.

table.maxn(t): integer;

 Returns the largest positive numerical index of the given table, or
 zero if the table has no positive numerical indices.

table.remove(t, [pos]): variant;

 Removes from tablt t the element at position pos. Returns the value
 of the removed element. The default for pos is the last element.

table.sort(table, [comp]);

 Sorts the table in a given order, in-place, from table[1] to
 table[n]. If comp is given it must be a function that recieves
 two table elements, and returns true when the first is less
 than the second.

table.setn(t, n): variant;

 Updates the size of the table t with n. Returns n

table.getn(t): variant;

 Returns the size of a table, when seen as a list. If the table has
 an n field with a numeric value, this value is the size of the
 table. Otherwise, the size is the largest numerical index with a
 non-nil value in the table.

table.foreachi(t, f): variant, variant;

 Depricated, use ipairs()

table.foreach(t, f): variant, variant;

 Depricated, use pairs()


Misc functions

[edit]

assert(v, [message]);

 Issues an error when the value of its arguement v is false.
 Message is the error message.

collectgarbage(opt, [arg]);

 A generic interface to the garbage collector. Performs according
 to the opt given:
 "stop": Stops the garbage collector
 "restart": Restarts the garbage collector
 "collect": Performs a full garbage collectiong cycle
 "count": Returns the total memory in use by Lua(in kb)
 "step": Performs a garbage collection step. The set size is
         controlled by arg.
 "setpause": Sets arg as the new value for the pause for the
             collector
 "setstepmul": Sets arg as the new value for the step multiplier.

dofile(filename): [variant1], [variant2], [...];

 Opens the file named filename and executs its contents as a lua
 chunk. Returns all values returned by the chunk.

error(message);

 Terminates the last protected function called and returns message
 as the error message.

getfenv([f]): environmentobj;

 Returns the current enviroment in use by the function.

getmetatable(obj): metatable;

 Returns the metatable for the given object obj.

ipairs(t): function, table, integer;

 Returns three values: an iterator function, the table t, and
 0.
 -for i,v in ipairs(t) do body end;

load(func): function;

 Loads a chunk using function func to get its pieces.

loadfile(filename): function;

 Same as load but gets the chunk from the filename.

loadstring(s): function;

 Same as load but gets the chunk from the string s.

next(t, [index]): integer, variant);

 Returns the next index and value of the given table t.

pairs(t): function, table, nil;

 See ipairs. Uses next() as the iterator function.

pcall(f, [arg1], [arg2], [...]): boolean, [var1], [var2], [...];

 Calls function f with given arguments in a protected mode.
 Returns a status boolean and the results of the call if successful.

print([...]);

 Recieves any number of arguments and prints their values to stdout
 using tostring() to convert them to strings.

rawequal(v1, v2): boolean;

 Checks whether v1 is equal to v2.

rawget(t, i): variant;

 Returns the value of table t at index i.

rawset(t, i, v): table;

 Sets the table t index i to value v. Returns t.

select(index, [...]): [...];

 If index is a number, returns all arguments after argument number
 index. Otherwise, index must be the string "#", and select returns
 the total number of extra arguments it received.

setfenv(f, t);

 Sets the enviroment to be used by the given function f.

setmetatable(t, mt): table;

 Sets the metatable mt to the given table t. Returns t.

tonumber(e, [base]): integer;

 Trys to convert e to a number. Optional base can be any integer
 from 2 and 36.

tostring(e): string;

 Takes e of any type and converts it to a string in a reasonable
 format.

type(v): string;

 Returns the type of its only argument, coded as a string. The
 possible results of this function are "nil" (a string, not the
 value nil), "number", "string", "boolean", "table", "function",
 "thread", and "userdata".

unpack(l, [i], [j]): [...];

 Returns the elements from the given table l. Optionally
 starting at index i to index j.

xpcall(f, err);

 Similar to pcall() but you can set a new error handler.

require procedure(loadfilepath);

 Roughly, require does the same job as dofile, but with two
 important differences. First, require searches for the file in a
 path; second, require controls whether a file has already been run
 to avoid duplicating the work. Because of these features, require
 is the preferred function in Lua for loading libraries.

module procedure(v, [opt]);

 Creates a module. If there is a table in package.loaded[name], this
 table is the module. Otherwise, if there is a global table t with
 the given name, this table is the module. Otherwise creates a new
 table t and sets it as the value of the global name and the value
 of package.loaded[name]. This function also initializes t._NAME
 with the given name, t._M with the module (t itself), and
 t._PACKAGE with the package name (the full module name minus last
 component; see below). Finally, module sets t as the new
 environment of the current function and the new value of
 package.loaded[name], so that require returns t. If name is a
 compound name (that is, one with components separated by dots),
 module creates (or reuses, if they already exist) tables for each
 component. For instance, if name is a.b.c, then module stores the
 module table in field c of field b of global a. This function can
 receive optional options after the module name, where each option
 is a function to be applied over the module.

gcinfo(): integer;

 Deprecated, use collectgarbage("count").

newproxy([boolean], [userdata]): userdata;

 Creates a zero-length userdata with an optional metatable.
 Experimental, undocumented and unsupported function in the Lua base
 library. It can be used to create a zero-length userdata, with a
 optional proxy.