<?xml-stylesheet type="text/xsl" href="api.xsl"?>
<!--
 *  Created by Nicholas Van Brunt on 3/19/09.
 *  Copyright 2009 Physle. All rights reserved.
 -->
<api>
<package name="Physle global functions">
	<function name="define">
		<in name="properties" type="table"/>
		<text>Defines a type for use with the put function using a table describing the type's properties.</text>
		<note>The sim uses the properties.name field to identify and create objects of the defined type so this field is required and
		must be unique.</note> 
	</function>
	<function name="put">
		<in name="type" type="string"/>
		<in name="x" type="number"/>
		<in name="y" type="number"/>
		<out name="handle" type="handle"/>
		<text>Puts an object of type in the sim at x,y and returns a handle which can be used to retrieve an interface to the object.</text>
		<note>Position 0,0 is located at the upper left hand corder of the sim and default view.</note>
	</function>
	<function name="get">
		<in name="handle" type="handle"/>
		<out name="object" type="object"/>
		<text>Retrieves an object using handle which can use the ':' operator to call its methods.</text>
	</function>
	<function name="png">
		<in name="path" type="string"/>
		<in name="flags" type="number"/>
		<out name="texture" type="number"/>
		<text>Loads a .png image at path with optional flags and returns a numeric texture id which can be used 
		anywhere a texture is expected.</text>
		<note>Images of even sizes generally work better for textures.  Only RGB and RGBA formats are currently supported.</note> 
	</function>
	<function name="animate">
		<in name="textures" type="table"/>
		<out name="frame1" type="number"/>
		<text>Receives an array of textures starting at element [1], and links them together in an animation.  
		Returns the first texture in the array which can be used anywhere a texture is expected.</text>
		<note>Animate works by linking textures. To create a looping texture, set the last texture in the 
		array to the first (or any previous) texture.  Also note that a texture has only 1 link.</note>
	</function>
	<function name="msec">
		<out name="msec" type="number"/>
		<text>Returns the system uptime in msecs (.001 secs).</text>
	</function>
	<function name="delay">
		<in name="msecs" type="number"/>
		<in name="func" type="function"/>
		<text>Executes a function in msecs.  Function should take a data table and return no values.</text>
	</function>
	<function name="hook">
		<in name="input" type="number"/>
		<in name="event" type="number"/>
		<in name="func" type="function"/>
		<text>Executes a function when event is generated by input.  Event will be ON_UP, ON_DOWN, ON_MOVE or ON_DRAG. Input is
		the id of the input.  For a standard mouse/keyboard platform the primary mouse button will be zero, keyboard
		buttons will correspond to their ascii equivalent. System keys may vary between platform but KEY_UP, KEY_LEFT, KEY_RIGHT, 
		and KEY_DOWN variables are provided for consistent access to arrow keys across platforms.</text>
		<note>The string.byte function will provide the input number for keys in many cases.  On move may not be available
		on some platforms (e.g. touch screen devices).</note>
	</function>
	<function name="wav">
		<in name="path" type="string"/>
		<in name="loop" type="boolean"/>
		<out name="channel" type="number"/>
		<text>Loads a .wav sound at path and returns the mixer channel it was loaded to which can be used
		in mixer functions.  If optional second argument loop is set to true the sound will be looped.</text>
		<note>Only uncompressed 8 and 16 bit wav files are currently supported.</note> 
	</function>
</package>
<package name="Physle type properties">
	<field name="name" type="string">
		<text>The name of and primary means of identifying a type.  This field is required and must be unique.</text>
	</field>
	<field name="extends" type="string">
		<text>The name of the type's parent.  If extends is set, any fields left unset will default to the
		value of the parent's field.</text>
	</field>
	<field name="model" type="string">
		<text>The physics model of the type 'active', 'static', or 'passive'.  Active objects are affected by
		all of the sim's forces, static objects generate collisions but are not affected by gravity.  Passive objects
		do not generate collisions and are not effected by gravity but can still respond to contact, touch, etc.
		This field is required.
		</text>
	</field>
	<field name="shape" type="string">
		<text>The shape of the type 'circle', 'rectangle', 'polygon' or 'line'. 
		This field is required and rectangles must define width and height fields, circles must define a radius field,
		polygons and lines must define a verts field.</text>
		<note>Objects of shape 'line' default to a static model and do not generate collisions with other lines.</note>
	</field>
	<field name="offshape" type="table">
		<text>X, Y offset to place a shape on its rigid body (defaults to 0,0).</text>
	</field>
	<field name="radius" type="number">
		<text>The radius of a circle type.</text>
	</field>
	<field name="width" type="number">
		<text>The width of a rectangle type.</text>
	</field>
	<field name="height" type="number">
		<text>The height of a rectangle type.</text>
	</field>
	<field name="verts" type="table">
		<text>In the case of polygons verts is an array of numbers which define a convex hull with a counterclockwise winding.
		In the case of lines verts defines an arrangement of sequential line segments.</text>
	</field>
	<field name="texture" type="number">
		<text>A numeric texture Id retrieved from an image loader function.  This texture will be an object's default
		texture when it is created.</text>
	</field>
	<field name="offtexture" type="table">
		<text>X, Y offset to draw textures to a view (defaults to 0,0).</text>
	</field>
	<field name="parallax" type="table">
		<text>X, Y offset to draw textures based on a view's focus (defaults to 1,1).</text>
		<note>This is only available for passive objects and is used to give the illusion of depth for background textures.</note>
	</field>
	<field name="mass" type="number">
		<text>The mass of the type.</text>
		<note>Mass is only relevant to objects using an active model.  Static and passive objects always have infinite mass.</note>
	</field>
	<field name="elastic" type="number">
		<text>The elasticity of the type in the range of 0.0 - 1.0  A value of 0 will produce no bounce and a value of 1 will produce a perfect bounce.</text>
	</field>
	<field name="friction" type="number">
		<text>The friction coefficient of the type in the range of 0.0 - 1.0. A value of 0.0 is frictionless</text>
	</field>
	<field name="maxspeed" type="table">
		<text>The maximum x and y speed the type can move.  This defaults to a number high enough to be non-restrictive in most cases.</text>
	</field>
	<field name="fixed" type="boolean">
		<text>Fixed objects do not rotate.  This defaults to false.</text>
	</field>	
	<field name="vars" type="table">
		<text>A lua table containing key/value pairs for user variables.</text>
	</field>						   
	<function name="collides">
		<in name="self" type="object"/>
		<in name="other" type="object"/>
		<out name="collision" type="boolean"/>
		<text>If defined, this function will determine if the object self will produce a collision with the other object when they contact each other.
		If the contact should produce a collision this function should return true, otherwise it should return false.</text>
		<note>This function will be called VERY OFTEN so it should be optimized or used sparingly.</note>
	</function>		
	<function name="onput">
		<in name="self" type="object"/>
		<in name="data" type="table"/>
		<text>An event handler function triggered when an object is created with put().</text>
	</function>
	<function name="onleave">
		<in name="self" type="object"/>
		<in name="data" type="table"/>
		<text>An event handler function triggered when an object leaves the area defined by space.setsize().</text>
	</function>
	<function name="onarrive">
		<in name="self" type="object"/>
		<in name="data" type="table"/>
		<text>An event handler function triggered when an object arrives at a point set by movesto().</text>
	</function>
	<function name="onrelease">
		<in name="self" type="object"/>
		<in name="data" type="table"/>
		<text>An event handler function triggered when an object is no longer in contact with other objects.</text>
	</function>
	<function name="oncontact">
		<in name="self" type="object"/>
		<in name="data" type="table"/>
		<text>An event handler function triggered when an object has contacted another object.</text>
	</function>		
	<function name="ontouch">
		<in name="self" type="object"/>
		<in name="data" type="table"/>
		<text>An event handler function triggered when an object has been touched by a user.</text>
	</function>								   
	<function name="onuntouch">
		<in name="self" type="object"/>
		<in name="data" type="table"/>
		<text>An event handler function triggered when an object is no longer touched by a user.</text>
	</function>								   
	<function name="onfree">
		<in name="self" type="object"/>
		<in name="data" type="table"/>
		<text>An event handler function triggered when an object is destroyed.  Use with caution.</text>
	</function>								   
</package>
<package name="Physle object methods">
	<function name="self.type">
		<in name="self" type="object"/>
		<out name="type" type="string"/>
		<text>Returns the object's type.</text>
	</function>
	<function name="self.shape">
		<in name="self" type="object"/>
		<out name="shape" type="string"/>
		<text>Returns the object's shape.</text>
	</function>
	<function name="self.model">
		<in name="self" type="object"/>
		<out name="model" type="table"/>
		<text>Returns a table describing object's model.</text>
		<note>The model field of the table contains the name of the model.
		If the model is 'active', mass, inertia, elastic and friction will be returned.
		If the model is 'static', elastic and friction will be returned.</note>
	</function>
	<function name="self.getxy">
		<in name="self" type="object"/>
		<out name="x" type="number"/>
		<out name="y" type="number"/>
		<text>Returns the coordinates of an object.</text>
	</function>
	<function name="self.setxy">
		<in name="self" type="object"/>
		<in name="x" type="number"/>
		<in name="y" type="number"/>
		<text>Sets the coordinates of an object to x,y.</text>
	</function>
	<function name="self.gettex">
		<in name="self" type="object"/>
		<out name="tex" type="number"/>
		<text>Returns the texture ID of an object or zero for none.</text>
	</function>
	<function name="self.settex">
		<in name="self" type="object"/>
		<in name="tex" type="number"/>
		<text>Sets the texture of an object to tex.</text>
	</function>
	<function name="self.rotation">
		<in name="self" type="object"/>
		<out name="angle" type="number"/>
		<text>Returns the rotation of an object.</text>
	</function>
	<function name="self.rotate">
		<in name="self" type="object"/>
		<in name="angle" type="number"/>
		<text>Sets the rotation of an object.</text>
	</function>
	<function name="self.speed">
		<in name="self" type="object"/>
		<out name="speed" type="number"/>
		<text>Returns the speed of a moving object.</text>
	</function>
	<function name="self.direction">
		<in name="self" type="object"/>
		<out name="direction" type="number"/>
		<text>Returns the direction of a moving object.</text>
	</function>
	<function name="self.span">
		<in name="self" type="object"/>
		<in name="x" type="number"/>
		<in name="y" type="number"/>
		<out name="span" type="number"/>
		<text>Returns the distance between an object's center and a point.</text>
	</function>
	<function name="self.angle">
		<in name="self" type="object"/>
		<in name="x" type="number"/>
		<in name="y" type="number"/>
		<out name="angle" type="number"/>
		<text>Returns the angle between an object's center and a point.</text>
	</function>
	<function name="self.move">
		<in name="self" type="object"/>
		<in name="speed" type="number"/>
		<in name="angle" type="number"/>
		<text>Move the object at speed towards angle.</text>
	</function>
	<function name="self.moves">
		<in name="self" type="object"/>
		<in name="speed" type="number"/>
		<in name="angle" type="number"/>
		<text>Moves the object at speed towards angle until stop or the moves function is called.</text>
		<note>If a target has been set with movesto it will be removed.</note>
	</function>
	<function name="self.movesto">
		<in name="self" type="object"/>
		<in name="speed" type="number"/>
		<in name="x" type="number"/>
		<in name="y" type="number"/>
		<text>Moves the object at speed towards x,y until stop or moves is called,  another target is set,
		or the object arrives at the target. If an event handler for onarrive is set for the object, that handler 
		will be called when the object reaches point x,y.
		</text>
	</function>
	<function name="self.stop">
		<in name="self" type="object"/>
		<text>Stops a moving object and clears any target set with movesto.</text>
	</function>
	<function name="self.setvar">
		<in name="self" type="object"/>
		<in name="key" type="string"/>
		<in name="value" type="any"/>
		<text>Set a user defined instance variable which was declared in type.vars.</text>
	</function>
	<function name="self.getvar">
		<in name="speed" type="number"/>
		<in name="key" type="string"/>
		<text>Get a user defined instance variable which was declared in type.vars.</text>
	</function>
	<function name="self.contacts">
		<in name="self" type="object"/>
		<out name="contacts" type="table"/>
		<text>Returns an array of handles for objects which are currently in contact with the self object.</text>
	</function>
	<function name="self.free">
		<in name="self" type="object"/>
		<text>Deletes an object.</text>
	</function>
</package>
<package name="Physle sim functions">
	<function name="sim.setg">
		<in name="x" type="number"/>
		<in name="y" type="number"/>
		<text>Sets the sim's horizontal and vertical gravity to x,y.</text>
	</function>
	<function name="sim.getg">
		<out name="x" type="number"/>
		<out name="y" type="number"/>
		<text>Returns the sim's gravity.</text>
	</function>
	<function name="sim.setcp">
		<in name="cp" type="number"/>
		<text>Sets the sim's contact persistance to cp.</text>
	</function>
	<function name="sim.getcp">
		<out name="cp" type="number"/>
		<text>Returns the sim's contact persistance.</text>
	</function>
	<function name="sim.setdamp">
		<in name="damping" type="number"/>
		<text>Sets the sim's viscous damping.  Expects a floating point in the range of 0.0 - 1.0</text>
	</function>
	<function name="sim.getdamp">
		<out name="damping" type="number"/>
		<text>Returns the sim's viscous damping.</text>
	</function>
	<function name="sim.sethash">
		<in name="dim" type="number"/>
		<text>Sets the size of the sim's hash cells. 
		Setting dim to the average objects size is likely to give the best performance.</text>
	</function>
	<function name="sim.gethash">
		<out name="dim" type="number"/>
		<text>Returns the size of the sim's hash cells.</text>
	</function>
	<function name="sim.setstep">
		<in name="size" type="number"/>
		<in name="steps" type="number"/>
		<text>Sets size and number of steps the sim will take per cycle.</text>
		<note>A higher step size will result in more accurate simulation but slower processing.</note>
	</function>
	<function name="sim.getstep">
		<out name="size" type="number"/>
		<out name="steps" type="number"/>
		<text>Returns size and number of steps the sim will take per cycle.</text>
	</function>
	<function name="sim.setsize">
		<in name="width" type="number"/>
		<in name="height" type="number"/>
		<text>Sets the size of the sim to width and height.</text>
		<note>This function is closely related to the onleave event handler which is triggered 
		when an object leaves the sims boundaries.</note>
	</function>
	<function name="sim.getsize">
		<out name="width" type="number"/>
		<out name="height" type="number"/>
		<text>Returns the size of the sim.</text>
	</function>
	<function name="sim.degrees">
		<in name="angles" type="boolean"/>
		<text>Passing true to degrees will cause the sim to take and return all angles in degrees.
		Radians are used by default and used if false is passed to degrees.</text>
		<note>Degrees can be converted to radians using Lua's math.rad function and 
		radians can be converted to degrees using the math.deg function. The Lua's trigonometry 
		functions (math.sin, math.cos, etc.) take and return radians.</note>
	</function>
	<function name="sim.join">
		<in name="data" type="table"/>
		<out name="joint" type="handle"/>
		<text>Connects two objects with a pin joint.  The joint is described in a data table which
		must contain handle1 and handle2 fields to the respective objects.  The table may also
		contain offx1, offy1, offx2, offy2 fields which define the offset of the joint.  The
		defaults of these fields is zero.</text>
		<note>The join and unjoin functions may be depreciated as the underlying
		physics engine moves towards a more flexible concept of constraints.</note>
	</function>
	<function name="sim.unjoin">
		<in name="joint" type="handle"/>
		<text>Removes a joint.</text>
	</function>
	<function name="sim.query">
		<in name="..." type="any"/>
		<out name="result" type="table"/>
		<text>Queries the sim and returns a table of resulting object handles.  Arguments may be
		x and y which returns handles to any object containing that point or 
		a type name which returns handles for any object of that type.  If no arguments are
		passed query will return a handle to every object in the sim.</text>
	</function>
	<function name="sim.count">
		<in name="type" type="string"/>
		<out name="amount" type="number"/>
		<text>If the optional type argument is used, count returns the number of objects of that type
		in the sim.  Otherwise, count returns the total number of objects in the sim.</text>
	</function>
	<function name="sim.pause">
		<in name="paused" type="boolean"/>
		<text>Pauses or un-pauses the sim.</text>
	</function>
	<function name="sim.paused">
		<out name="paused" type="boolean"/>
		<text>Returns true if the sim is paused or false if not.</text>
	</function>
	<function name="sim.reset">
		<in name="types" type="boolean"/>
		<text>Frees all of the objects in the sim.  If types is true, also removes all declared types.</text>
	</function>
</package>
<package name="Physle view functions">
	<function name="view.size">
		<out name="width" type="number"/>
		<out name="height" type="number"/>
		<text>Returns the size of the view.</text>
	</function>
	<function name="view.setpan">
		<in name="x" type="number"/>
		<in name="y" type="number"/>
		<text>Sets view's pan to x, y. Also removes objects from focus.</text>
	</function>
	<function name="view.getpan">
		<out name="x" type="number"/>
		<out name="y" type="number"/>
		<text>Returns the current pan of the view.</text>
	</function>
	<function name="view.getfocus">
		<out name="focus" type="object"/>
		<text>Returns the object in focus or nil if no object has focus.</text>
	</function>
	<function name="view.setfocus">
		<in name="focus" type="object"/>
		<text>Sets the view's focus to object following any of the object's movement.</text>
	</function>
	<function name="view.getbgcolor">
		<out name="red" type="number"/>
		<out name="green" type="number"/>
		<out name="blue" type="number"/>
		<text>Returns the view's background color.</text>
		<note>Color values range from 0 to 255</note>
	</function>
	<function name="view.setbgcolor">
		<in name="red" type="number"/>
		<in name="green" type="number"/>
		<in name="blue" type="number"/>
		<text>Sets the view's background color.</text>
		<note>Color values range from 0 to 255</note>
	</function>
	<function name="view.control">
		<in name="properties" type="table"/>
		<out name="control" type="object"/>
		<text>Takes a table containing the properties of a GUI control
		and returns a control object defined by those properties.
		</text>
	</function>
</package>
<package name="Physle control properties">

	<field name="text" type="string">
		<text>The text displayed by the control.</text>
	</field>
	<field name="font" type="number">
		<text>The font the control uses to display text.</text>
		<note>This is an ASCII bitmap font texture which contians all 128 characters
		in eight rows equally spaced from each other and aligned to the center of the cell.</note>
	</field>
	<field name="monospace" type="boolean">
		<text>If set to true font characters will be drawn in monospace.  The default is false.</text>
	</field>
	<field name="x" type="number">
		<text>The x position of the control.</text>
	</field>
	<field name="y" type="number">
		<text>The y position of the control.</text>
	</field>
	<field name="bgtex" type="number">
		<text>The background texture for the control.</text>
	</field>
	<field name="width" type="number">
		<text>The width of the control.</text>
		<note>Must be wider than the width of the text.</note>
	</field>
	<field name="height" type="number">
		<text>The height of the control.</text>
		<note>Must be wider than the width of the text.</note>
	</field>
	<field name="resizes" type="boolean">
		<text>Resizes the control if text width exceeds current width. The default is true.</text>
	</field>
	<field name="marginleft" type="number">
		<text>Left margin of text.</text>
	</field>
	<field name="margintop" type="number">
		<text>Top margin of text.</text>
	</field>
	<field name="marginright" type="number">
		<text>Right margin of text.</text>
	</field>
	<field name="marginbottom" type="number">
		<text>Bottom margin of text.</text>
	</field>
	<function name="ontouch">
		<in name="self" type="object"/>
		<text>A function which is called when the control is touched.</text>
	</function>
	<function name="onuntouch">
		<in name="self" type="object"/>
		<text>A function which is called when a touch is released while over the control.</text>
	</function>
	<function name="ontouchout">
		<in name="self" type="object"/>
		<text>A function which is called when a touch leaves the area of a control while the control is touched.</text>
	</function>


</package>
<package name="Physle control methods">
	<function name="self.gettext">
		<in name="self" type="object"/>
		<out name="text" type="string"/>
		<text>Returns the control's text.</text>
	</function>
	<function name="self.settext">
		<in name="self" type="object"/>
		<in name="text" type="string"/>
		<text>Sets the control's text.</text>
	</function>
	<function name="self.getcolor">
		<in name="self" type="object"/>
		<out name="red" type="number"/>
		<out name="green" type="number"/>
		<out name="blue" type="number"/>
		<text>Returns the color of the control's text.</text>
		<note>Color values range from 0 to 255</note>
	</function>
	<function name="self.setcolor">
		<in name="self" type="object"/>
		<in name="red" type="number"/>
		<in name="green" type="number"/>
		<in name="blue" type="number"/>
		<text>Sets the color of the control's text.</text>
		<note>Color values range from 0 to 255</note>
	</function>
	<function name="self.getbgtex">
		<in name="self" type="object"/>
		<out name="tex" type="number"/>
		<text>Returns the texture used for the control's background.</text>
	</function>
	<function name="self.setbgtex">
		<in name="self" type="object"/>
		<in name="tex" type="number"/>
		<text>Sets the texture used for the control's background.</text>
	</function>
	<function name="self.getmargin">
		<in name="self" type="object"/>
		<out name="margins" type="table"/>
		<text>Returns the margins in a table with keys 'right', 'left', 'top', and 'bottom'.</text>
	</function>
	<function name="self.setmargin">
		<in name="self" type="object"/>
		<in name="margins" type="table"/>
		<text>Sets the margins in a table with keys 'right', 'left', 'top', and 'bottom'.</text>
	</function>
	<function name="self.hidden">
		<in name="self" type="object"/>
		<out name="hidden" type="boolean"/>
		<text>Returns true if the control is hidden and false if it is not hidden.</text>
	</function>
	<function name="self.hide">
		<in name="self" type="object"/>
		<text>Hides the control.</text>
		<note>If a control is hidden it will not respond to touches.</note>
	</function>
	<function name="self.show">
		<in name="self" type="object"/>
		<text>Shows a hidden control.</text>
	</function>
</package>
<package name="Physle mixer functions">
	<function name="mixer.playing">
		<in name="channel" type="number"/>
		<out name="playing" type="boolean"/>
		<text>Returns true if the sound loaded to channel is playing.</text>
	</function>
	<function name="mixer.play">
		<in name="channel" type="number"/>
		<in name="oncomplete" type="function"/>
		<text>Plays the sound loaded to channel.  If the optional oncomplete is
		passed this function will be called when the sound completes playing. </text>
		<note>oncomplete can not be used with looped sounds.</note>
	</function>
	<function name="mixer.stop">
		<in name="channel" type="number"/>
		<text>Stops the sound loaded to channel.</text>
	</function>
	<function name="mixer.getgain">
		<in name="channel" type="number"/>
		<out name="gain" type="number"/>
		<text>Returns the gain (loudness) of channel.</text>
	</function>
	<function name="mixer.setgain">
		<in name="channel" type="number"/>
		<in name="gain" type="number"/>
		<text>Sets the gain (loudness) of channel.</text>
	</function>
	<function name="mixer.length">
		<in name="channel" type="number"/>
		<out name="msecs" type="number"/>
		<text>Returns the length of the sound loaded to channel.</text>
	</function>
</package>
<package name="Lua global functions">
	<function name="print">
		<in name="..." type="string"/>
		<text>Receives any number of arguments, and prints their values to stdout.</text>
		<note>The print implementation in Physle also pipes stdout to the view buffer so it displays in the Physle view.
		As of version 3.2._ arguments must be of type string or number. Tables and functions will not have tostring() 
		called on them by default.</note> 
	</function>
	<function name="dofile">
		<in name="path" type="string"/>
		<out name="..." type="any"/>
		<text>Loads and executes a Lua file at path.</text>
	</function>
	<function name="tostring">
		<in name="value" type="any"/>
		<out name="string" type="string"/>
		<text>Receives an argument of any type and converts it to a string in a reasonable format.</text>
	</function>
	<function name="tonumber">
		<in name="value" type="any"/>
		<in name="base" type="number"/>
		<out name="number" type="number"/>
		<text>Tries to convert value to a number with an optional base defaulting to 10. 
		In bases above 10 letters are used to represent number above 9.</text>
	</function>
	<function name="type">
		<in name="value" type="any"/>
		<out name="type" type="string"/>
		<text>Returns the type of value as a string. The possible results of this function are 
		'nil', 'number', 'string', 'boolean', 'table', 'function', 'userdata'. </text>
	</function>
	<function name="pairs">
		<in name="table" type="table"/>
		<out name="key" type="any"/>
		<out name="value" type="any"/>
		<text>Iterates over all key-value pairs of table using for..in.  E.g. for k,v in pairs(t) do ... end.</text>
	</function>
	<function name="ipairs">
		<in name="table" type="table"/>
		<out name="index" type="number"/>
		<out name="value" type="any"/>
		<text>Iterates over all index-value pairs of table using for..in.  E.g. for i,v in ipairs(t) do ... end.</text>
	</function>
</package>
<package name="Lua table functions">
	<function name="table.concat">
		<in name="array" type="table"/>
		<in name="sep" type="string"/>
		<in name="i" type="number"/>
		<in name="j" type="number"/>
		<text>Given an array where all elements are strings or numbers, concat
		returns all values in a single string seperated by sep. Optionally concat
		will take the index i to start and the index j on which to stop.  The
		default for i is 1 and the defualt for j is the length of the array</text>
		<out name="values" type="string"/>
	</function>
	<function name="table.insert">
		<in name="table" type="table"/>
		<in name="pos" type="number"/>
		<in name="value" type="any"/>
		<text>Inserts value at optional 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.</text>
		<note>This function is unusual in that the optional argument pos is not at the end
		of the argument list.</note>
	</function>
	<function name="table.maxn">
		<in name="table" type="table"/>
		<text>Returns the largest positive numerical index of the given table, or 
		zero if the table has no positive numerical indices.</text>
	</function>
	<function name="table.remove">
		<in name="table" type="table"/>
		<in name="pos" type="number"/>
		<out name="value" type="any"/>
		<text>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.</text>
	</function>
	<function name="table.sort">
		<in name="table" type="table"/>
		<in name="compare" type="function"/>
		<text>Sorts table elements using the compare function.</text>
		<note>The compare function must be a function that receives two table elements, 
		and returns true when the first is less than the second.</note>
	</function>
</package>
<package name="Lua math library">
	<field name="math.huge" type="number">
		<text>A number larger than or equal to any other numerical value.</text>
	</field>
	<field name="math.pi" type="number">
		<text>Pi.</text>
	</field>
	<function name="math.abs">
		<in name="singed" type="number"/>
		<out name="unsigned" type="number"/>
		<text>Returns the absolute value of signed number.</text>
	</function>
	<function name="math.acos">
		<in name="number" type="number"/>
		<out name="acos" type="number"/>
		<text>Returns the arc cosine of number (in radians).</text>
	</function>
	<function name="math.asin">
		<in name="number" type="number"/>
		<out name="asin" type="number"/>
		<text>Returns the arc sine of number (in radians).</text>
	</function>
	<function name="math.atan">
		<in name="number" type="number"/>
		<out name="atan" type="number"/>
		<text>Returns the arc tangent of number (in radians).</text>
	</function>
	<function name="math.atan2">
		<in name="x" type="number"/>
		<in name="y" type="number"/>
		<out name="atan" type="number"/>
		<text>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.) </text>
	</function>
	<function name="math.ceil">
		<in name="float" type="number"/>
		<out name="integer" type="number"/>
		<text>Returns the smallest integer larger than or equal to the floating
		point number float.</text>
	</function>
	<function name="math.cos">
		<in name="number" type="number"/>
		<out name="cos" type="number"/>
		<text>Returns the cosine of number (in radians).</text>
	</function>
	<function name="math.cosh">
		<in name="number" type="number"/>
		<out name="cosh" type="number"/>
		<text>Returns the hyperbolic cosine of number (in radians).</text>
	</function>
	<function name="math.deg">
		<in name="radians" type="number"/>
		<out name="degrees" type="number"/>
		<text>Returns the angle given in radians, in degrees.</text>
	</function>
	<function name="math.exp">
		<in name="number" type="number"/>
		<out name="exp" type="number"/>
		<text>Returns the exp of number.</text>
	</function>
	<function name="math.floor">
		<in name="float" type="number"/>
		<out name="integer" type="number"/>
		<text>Returns the largest integer smaller than or equal to the floating
		point number float.</text>
	</function>
	<function name="math.fmod">
		<in name="x" type="number"/>
		<in name="y" type="number"/>
		<out name="fmod" type="number"/>
		<text>Returns the remainder of the division of x by y that rounds the 
		quotient towards zero. </text>
	</function>
	<function name="math.frexp">
		<in name="number" type="number"/>
		<out name="frexp" type="number"/>
		<text>Returns the frexp of number.</text>
	</function>
	<function name="math.ldexp">
		<in name="number" type="number"/>
		<out name="ldexp" type="number"/>
		<text>Returns the ldexp of number.</text>
	</function>
	<function name="math.log">
		<in name="number" type="number"/>
		<out name="log" type="number"/>
		<text>Returns the natural logarithm of number.</text>
	</function>
	<function name="math.log10">
		<in name="number" type="number"/>
		<out name="log10" type="number"/>
		<text>Returns the base-10 logarithm of number.</text>
	</function>
	<function name="math.max">
		<in name="..." type="number"/>
		<out name="max" type="number"/>
		<text>Returns the maximum value among its arguments. </text>
	</function>
	<function name="math.min">
		<in name="..." type="number"/>
		<out name="min" type="number"/>
		<text>Returns the minimum value among its arguments. </text>
	</function>
	<function name="math.modf">
		<in name="number" type="number"/>
		<out name="integral" type="number"/>
		<out name="fractional" type="number"/>
		<text>Returns the integral and the fractional part of number.</text>
	</function>
	<function name="math.pow">
		<in name="number" type="number"/>
		<in name="power" type="number"/>
		<out name="pow" type="number"/>
		<text>Returns number^power.</text>
	</function>
	<function name="math.rad">
		<in name="degrees" type="number"/>
		<out name="radians" type="number"/>
		<text>Returns the angle given in degrees, in radians.</text>
	</function>
	<function name="math.random">
		<in name="m" type="number"/>
		<in name="n" type="number"/>
		<out name="random" type="number"/>
		<text>When called without arguments, returns a uniform pseudo-random 
		real number in the range [0,1).  When called with an integer number m, 
		math.random returns a uniform pseudo-random integer in the range 
		[1, m]. When called with two integer numbers m and n, math.random 
		returns a uniform pseudo-random integer in the range [m, n]. </text>
	</function>
	<function name="math.randomseed">
		<in name="number" type="number"/>
		<text>Sets the "seed" for the pseudo-random generator: equal seeds 
		produce equal sequences of numbers </text>
	</function>
	<function name="math.sin">
		<in name="number" type="number"/>
		<out name="sin" type="number"/>
		<text>Returns the sine of number (in radians).</text>
	</function>
	<function name="math.sinh">
		<in name="number" type="number"/>
		<out name="sinh" type="number"/>
		<text>Returns the hyperbolic sine of number (in radians).</text>
	</function>
	<function name="math.sqrt">
		<in name="number" type="number"/>
		<out name="sqrt" type="number"/>
		<text>Returns the square root of number.</text>
	</function>
	<function name="math.tan">
		<in name="number" type="number"/>
		<out name="sqrt" type="number"/>
		<text>Returns the tangent of number (assumed to be in radians).</text>
	</function>
	<function name="math.tanh">
		<in name="number" type="number"/>
		<out name="sqrt" type="number"/>
		<text>Returns the hyperbolic tangent of number (assumed to be in radians).</text>
	</function>
</package>
<package name="Lua string functions">
	<function name="string.byte">
		<in name="character" type="string"/>
		<text>
		Returns the internal numerical codes of the character.</text>
		<note>Numerical codes are not necessarily portable across platforms.</note>
		<out name="code" type="number"/>
	</function>
	<function name="string.char">
		<in name="..." type="number"/>
		<text>
		Receives zero or more integers. Returns a string with length equal to the number of 
		arguments, in which each character has the internal numerical code equal to its 
		corresponding argument. </text>
		<note>Numerical codes are not necessarily portable across platforms.</note>
		<out name="characters" type="string"/>
	</function>
	<function name="string.find">
		<in name="string" type="string"/>
		<in name="pattern" type="string"/>
		<in name="init" type="number"/>
		<in name="plain" type="boolean"/>
		<text>
		Looks for the first match of pattern in the string. If it finds a match, then 
		find returns the indices where this occurrence starts and ends; otherwise, 
		it returns nil. A third, optional numerical argument init specifies where to 
		start the search; its default value is 1 and can be negative. 
		A value of true as a fourth, optional argument plain turns off the pattern 
		matching facilities, so the function does a plain "find substring" operation, 
		with no characters in pattern being considered "magic". </text>
		<note>If plain is given, then init must be given as well.
		If the pattern has captures, then in a successful match the captured values 
		are also returned, after the two indices. </note>
		<out name="indices" type="number"/>
	</function>
	<function name="string.format">
		<in name="format" type="string"/>
		<in name="..." type="any"/>
		<out name="output" type="string"/> 
		<text>Returns a formatted version of its variable number of arguments following the 
		description given in its first argument (which must be a string). The format 
		string follows the same rules as the printf family of standard C functions.</text>
	</function>
	<function name="string.gmatch">
		<in name="string" type="string"/>
		<in name="pattern" type="string"/>
		<out name="iterator" type="function"/>
		<text>Returns an iterator function that, each time it is called, returns the 
		next captures from pattern over string.	e.g. for w in string.gmatch("hello world", "%a+") do...</text>
	</function>
	<function name="string.gsub">
		<in name="string" type="string"/>
		<in name="pattern" type="string"/>
		<in name="repl" type="number"/>
		<in name="one" type="boolean"/>
		<out name="string" type="string"/>
		<out name="matches" type="number"/>
		<text>Returns a copy of string in which occurrences of the pattern have been replaced 
		by a replacement string specified by repl, which can be a string, a table, or a function. 
		gsub also returns, as its second value, the total number of matches that occurred. 
		If the optional one argument is set to true, only the first match will be replaced.</text>
	</function>
	<function name="string.len">
		<in name="string" type="string"/>
		<text>Returns the length of string.</text>
		<out name="size" type="number"/>
	</function>
	<function name="string.lower">
		<in name="string" type="string"/>
		<out name="lowercased" type="string"/>
		<text>Receives a string and returns a copy of this string with all uppercase 
		letters changed to lowercase.</text>
	</function>
	<function name="string.match">
		<in name="string" type="string"/>
		<in name="pattern" type="string"/>
		<in name="init" type="string"/>
		<out name="result" type="string"/>
		<text>Looks for the first match of pattern in the string. If it finds one, then match returns 
		the captures from the pattern; otherwise it returns nil. If pattern specifies no captures, 
		then the whole match is returned. A third, optional numerical argument init specifies where 
		to start the search; its default value is 1 and can be negative.</text>
	</function>
	<function name="string.rep">
		<in name="string" type="string"/>
		<in name="count" type="number"/>
		<out name="string" type="string"/>
		<text>Returns a string that is the concatenation of count copies of the string.</text>
	</function>
	<function name="string.reverse">
		<in name="string" type="string"/>
		<out name="reversed" type="string"/>
		<text>Returns string reversed. </text>
	</function>
	<function name="string.sub">
		<in name="string" type="string"/>
		<in name="i" type="number"/>
		<in name="j" type="number"/>
		<out name="substring" type="string"/>
		<text>Returns the substring of string that starts at i and continues until j; i and j 
		can be negative. If j is absent, then it is assumed to be equal to -1 
		(which is the same as the string length).
		</text>
	</function>
	<function name="string.upper">
		<in name="string" type="string"/>
		<out name="uppercased" type="string"/>
		<text>Receives a string and returns a copy of this string with all lowercase 
		letters changed to uppercase</text>
	</function>
</package>
</api>