This file is automatically generated, do not edit!
*** CONSTANTS ***

blend mode constants
BLEND
REPLACE
RGB_ONLY
ALPHA_ONLY
ADD
SUBTRACT
MULTIPLY
AVERAGE
INVERT
primitive constants
LINE_MULTIPLE
LINE_STRIP
LINE_LOOP
sound effect constants
SE_SINGLE
SE_MULTIPLE
sfxr wave type constants
SQUAREWAVE
SAWTOOTH
SINEWAVE
NOISE
windowstyle constants
EDGE_LEFT
EDGE_TOP
EDGE_RIGHT
EDGE_BOTTOM
particle system constants
PS_PARENT
PS_CHILD
PS_SHAPE_NULL
PS_SHAPE_RECTANGLE
PS_SHAPE_ELLIPSE
PS_ORIENTATION_EXPLICIT
PS_ORIENTATION_IMPLICIT

*** KEY_CONSTANTS ***

KEY_ESCAPE
KEY_F1
KEY_F2
KEY_F3
KEY_F4
KEY_F5
KEY_F6
KEY_F7
KEY_F8
KEY_F9
KEY_F10
KEY_F11
KEY_F12
KEY_TILDE
KEY_0
KEY_1
KEY_2
KEY_3
KEY_4
KEY_5
KEY_6
KEY_7
KEY_8
KEY_9
KEY_MINUS
KEY_EQUALS
KEY_BACKSPACE
KEY_TAB
KEY_A
KEY_B
KEY_C
KEY_D
KEY_E
KEY_F
KEY_G
KEY_H
KEY_I
KEY_J
KEY_K
KEY_L
KEY_M
KEY_N
KEY_O
KEY_P
KEY_Q
KEY_R
KEY_S
KEY_T
KEY_U
KEY_V
KEY_W
KEY_X
KEY_Y
KEY_Z
KEY_SHIFT
KEY_CAPSLOCK
KEY_NUMLOCK
KEY_SCROLLOCK
KEY_CTRL
KEY_ALT
KEY_SPACE
KEY_OPENBRACE
KEY_CLOSEBRACE
KEY_SEMICOLON
KEY_APOSTROPHE
KEY_COMMA
KEY_PERIOD
KEY_SLASH
KEY_BACKSLASH
KEY_ENTER
KEY_INSERT
KEY_DELETE
KEY_HOME
KEY_END
KEY_PAGEUP
KEY_PAGEDOWN
KEY_UP
KEY_RIGHT
KEY_DOWN
KEY_LEFT
KEY_NUM_0
KEY_NUM_1
KEY_NUM_2
KEY_NUM_3
KEY_NUM_4
KEY_NUM_5
KEY_NUM_6
KEY_NUM_7
KEY_NUM_8
KEY_NUM_9
MOUSE_LEFT
MOUSE_MIDDLE
MOUSE_RIGHT
MOUSE_WHEEL_UP
MOUSE_WHEEL_DOWN
JOYSTICK_AXIS_X
JOYSTICK_AXIS_Y
JOYSTICK_AXIS_Z
JOYSTICK_AXIS_R
PLAYER_1
PLAYER_2
PLAYER_3
PLAYER_4
PLAYER_KEY_MENU
PLAYER_KEY_UP
PLAYER_KEY_DOWN
PLAYER_KEY_LEFT
PLAYER_KEY_RIGHT
PLAYER_KEY_A
PLAYER_KEY_B
PLAYER_KEY_X
PLAYER_KEY_Y

*** MAP_ENGINE_CONSTANTS ***

COMMAND_WAIT
COMMAND_ANIMATE
COMMAND_FACE_NORTH
COMMAND_FACE_NORTHEAST
COMMAND_FACE_EAST
COMMAND_FACE_SOUTHEAST
COMMAND_FACE_SOUTH
COMMAND_FACE_SOUTHWEST
COMMAND_FACE_WEST
COMMAND_FACE_NORTHWEST
COMMAND_MOVE_NORTH
COMMAND_MOVE_EAST
COMMAND_MOVE_SOUTH
COMMAND_MOVE_WEST
SCRIPT_ON_CREATE
SCRIPT_ON_DESTROY
SCRIPT_ON_ACTIVATE_TOUCH
SCRIPT_ON_ACTIVATE_TALK
SCRIPT_COMMAND_GENERATOR
SCRIPT_ON_ENTER_MAP
SCRIPT_ON_LEAVE_MAP
SCRIPT_ON_LEAVE_MAP_NORTH
SCRIPT_ON_LEAVE_MAP_EAST
SCRIPT_ON_LEAVE_MAP_SOUTH
SCRIPT_ON_LEAVE_MAP_WEST

*** version functions ***

  double GetVersion()
     - Returns the current version of Sphere as a floating point number
       (e.g. 1.0 or 1.1)

  string GetVersionString()
     - Returns the current Sphere version string

*** configuration ***

  int GetGlobalConfiguration(int item)
     - Get some global configuration options.
       Parameter 'select' can be one of these: 0: language, 1: sound, 2: networking, 3: platform
       return values for language:
         0: default
         1: English
         2: German
         3: French
         4: Dutch
         5: Japanese
         6: Chinese_simplified
         7: Russian
         8: Spanish
         9: Indonesian
       return values for sound:
         0: Sound Auto
         1: Sound On
         2: Sound Off
       return values for networking:
         0: No networking allowed
         1: Networking is allowed
       return values for platform:
         0: Mac
         1: Win32
         2: Linux
     @see GetPlayerKey for keyboard player configuration

*** script functions ***

  void EvaluateScript(string name)
     - Reads the script in and uses it as if it were a part of the current script.
       ex: EvaluateScript("myscript.js");

  void EvaluateSystemScript(string name)
     - Reads in one of the preset system scripts for use in the current script
       ex: EvaluateSystemScript("menu.js");

  void RequireScript(string name)
     - Reads the script in and uses it as if it were a part of the current script.
       But only if the script has not already been evaluated.
       ex: RequireScript("myscript.js");

  void RequireSystemScript(string name)
     - Reads in one of the preset system scripts for use in the current script.
       But only if the script has not already been evaluated.
       ex: RequireSystemScript("menu.js");

  void GarbageCollect()
     - invokes the JavaScript garbage collector
       if given a parameter, then Sphere will decide if GC is required.

*** misc functions ***

  void CreateStringFromCode(int code)
     - creates a single-character string based on the code passed in, i.e. 65 is "A"
       Do not use this function, use String.fromCharCode(code) instead...
       e.g. String.fromCharCode(65) == "A"

*** engine functions ***

  array GetGameList()
     - Returns array of game objects
       - game.name Name of game
       - game.directory Directory (project name) where game is stored
       - game.author Who wrote it?
       - game.description Bite-sized summary of game.

  void ExecuteGame(string directory)
     - executes the game in sphere/games/<directory>. This function
       actually exits the first game and loads the one in 'directory'.
       When the second game returns, the original is loaded again.
       (Note that this is unlike Sphere 0.97, which returned directly
       from ExecuteGame when the other game finished.)

  void Exit()
     - Exits the Sphere engine unconditionally

  void Abort(string message)
     - Exits the Sphere engine unconditionally,
       displays the 'message' to the user
       If you end the message with a newline it wont display the file/line
       where the Abort occured.
       e.g. Abort("Mistake here")
       vs. Abort("Game over!\n");

  void RestartGame()
     - restarts the current game

*** graphics functions ***

  void FlipScreen()
     - displays the contents from the video buffer onto the screen.
       Then the video buffer is cleared.
       You *need* to call this to make anything
       you've drawn in code to appear on the screen.

  void SetClippingRectangle(int x, int y, int w, int h)
     - Sets a clipping rectangle of width w and height h at (x, y) into the
       video buffer. Anything drawn outside the rectangle is not drawn into
       the video buffer.

  object GetClippingRectangle()
     - Returns a rectangle object representing the clipping rectangle.
       i.e.
       var clip = GetClippingRectangle();
           clip.x
           clip.y
           clip.width
           clip.height

  void ApplyColorMask(color_object c)
     - fills the whole screen with the color specified. Note that the color
       passed must have an alpha that is less than 255. Otherwise, it'll
       just make the screen solidly that color.
       ApplyColorMask tints the screen's current state
       (meaning you'll have to call it every frame
        if you want the effect to be permanent)

  void SetFrameRate(int fps)
     - allows you to set the maximum frames rendered per second that
       the engine is allowed to draw at most. Set to 0 in order to
       unthrottle the graphics renderer. Keep in mind that this
       is not for the map engine, which uses the fps specified in the
       MapEngine() call. This function only controls standard drawing
       functions and FlipScreen() outside of the map engine. In short,
       don't use this function if you plan to be doing rendering in your
       own scripts in the map engine.

  int GetFrameRate([boolean calculate])
     - Returns the current fps set by SetFrameRate...
     (note: this is not the same as the map engine frame rate)

  void SetMapEngineFrameRate(int fps)
     - Sets the max frame rate (in frames per second) that the map engine will go at

  int GetMapEngineFrameRate()
     - Returns the current map engine frames per second rate set by either MapEngine(map, fps) or SetMapEngineFrameRate(fps)

  int GetScreenWidth()
     - returns the width of the engine screen

  int GetScreenHeight()
     - returns the height of the engine screen

  void Point(int x, int y, color_object c)
     - plots a point onto the video buffer at (x, y) with the color

  void PointSeries(array arr, color_object c)
     - plots a series of points onto the video buffer with the color

  void Line(int x1, int y1, int x2, int y2, color_object c)
     - draws a line from (x1, y1) to (x2, y2) with the color

  void GradientLine(int x1, int y1, int x2, int y2, color_object c1, color_object c2)
     - Draws a line from (x1, y1) to (x2, y2) with a color fade from color1
       to color2

  void LineSeries(array arr, color_object c [, int type])
     - Draws a series of lines with the color
     - type = 0 = LINE_MULTIPLE: line list
     - type = 1 = LINE_STRIP: line strip
     - type = 2 = LINE_LOOP: line loop

  void BezierCurve(color_object c, double step, int x1, int y1, int x2, int y2, int x3, int y3 [, int x4, int y4])
     - draws a Bezier curve from A(x1, y1) to C(x3, y3) with B(x2, y2) and D(x4, y4) as control points

  void Triangle(int x1, int y1, int x2, int y2, int x3, int y3, color_object c)
     - Draws a filled triangle with the points (x1, y1), (x2, y2), (x3, y3),
       with the color c

  void GradientTriangle(int x1, int y1, int x2, int y2, int x3, int y3, color_object c1, color_object c2, color_object c3)
     - Draws a gradient triangle with the points (x1, y1), (x2, y2), (x3, y3),
       with each point (c1 = color of (x1, y1), c2 = color of (x2, y2), c3 = color
       of (x3, y3)) having a color to generate the gradient of the triangle

  int PolygonCollision(array arrA, array arrB [, int if (argc > 2) offsetAx, int if (argc > 3) offsetAy, int if (argc > 4) offsetBx, int if (argc > 5) offsetBy])
     - Determines if two polygons are colliding
       It returns 0 when there is no collision, a positive number if a vertex of A
       collides with B and a negative number is a vertex of B collides with A.
       1 and -1 is the first point in the array, and so on. Because the first element
       in an array is zero, you need to substract or add 1 to get the element number.

  void Polygon(array arr, color_object c [, int invert, int offsetX, int offsetY])
     - Draws a color-filled polygon using the array of objects
       (each object must have a 'x' and 'y' property).
       If invert is true, all points in the bounding box of the polygon, but
       not in the polygon will be colored.

  void OutlinedRectangle(int x, int y, int w, int h, color_object c [, int size])
     - Draws an outlined rectangle at (x, y) of width w and height h and size size, filled with color c.

  void Rectangle(int x, int y, int w, int h, color_object c)
     - Draws a rectangle at (x, y) of width w and height h, filled with color c.

  void GradientRectangle(int x, int y, int w, int h, color_object c1, color_object c2, color_object c3, color_object c4)
     - Draws a gradient rectangle at (x,y) with the height h and width w.
       Each corner of a rectangle (c_ul = color of upper left corner,
       c_ur = color of upper right corner, c_lr = color of lower right corner,
       c_ll = color of lower left corner) accepts a color information to
       generate the gradient of the rectangle.

  void OutlinedEllipse(int x, int y, int rx, int ry, color_object c)
     - Draws an outlined ellipse at (x, y) with radius rx and ry

  void FilledEllipse(int x, int y, int rx, int ry, color_object c)
     - Draws a filled ellipse at (x, y) with radius rx and ry

  void OutlinedComplex(int r_x, int r_y, int r_w, int r_h, int circ_x, int circ_y, int circ_r, color_object color [, int antialias])
     - Draws a filled rectangle at (r_x, r_y) with width r_w and height r_h and a circle cut out
     of it at (circ_x, circ_y) with a radius of circ_r.

  void FilledComplex(int r_x, int r_y, int r_w, int r_h, int circ_x, int circ_y, int circ_r, double angle, double frac_size, int fill_empty, color_object color1, color_object color2)
     - Draws a filled rectangle at (r_x, r_y) with width r_w and height r_h and a circle
     at (circ_x, circ_y) with a radius of circ_r (fractioned, if defined)

  void GradientComplex(int r_x, int r_y, int r_w, int r_h, int circ_x, int circ_y, int circ_r, double angle, double frac_size, int fill_empty, color_object color1, color_object color2, color_object color3)
     - Draws a filled rectangle at (r_x, r_y) with width r_w and height r_h and a gradient circle
     at (circ_x, circ_y) with a radius of circ_r (fractioned, if defined)

  void OutlinedCircle(int x, int y, int r, color_object c [, int antialias])
     - Draws an outlined circle at (x, y) with radius r, filled with color c.

  void FilledCircle(int x, int y, int r, color_object c [, int antialias])
     - Draws a filled circle at (x, y) with radius r, filled with color c.

  void GradientCircle(int x, int y, int r, color_object c1, color_object c2 [, int antialias])
     - Draws a gradient circle at (x, y) with radius r, filled with internal color c1 and external color c2.

*** input ***

  boolean AreKeysLeft()
     - returns true or false depending if the there are keys from the key
       input queue.

  int GetKey()
     - returns the first key in the queue. If there are no keys in the queue,
       Sphere will wait until there is a key in the queue.

  boolean GetToggleState(int key)
     - checks if Caps Lock, Num Lock or Scroll Lock are active.
       Allowed key values are:
         KEY_CAPSLOCK
         KEY_NUMLOCK
         KEY_SCROLLOCK (note: only two Ls)

  boolean IsKeyPressed(int key)
     - checks if the key has been pressed.
       Returns true if 'key' is pressed....

  boolean IsAnyKeyPressed()
     - checks if any key is pressed at the time.

  string GetKeyString(int key, boolean shift)
     - converts the key into a string, KEY_A will become "a", etc.
     - if shift is true, returns uppercase/special value of key
     - control keys return ""

  int GetPlayerKey(int player, int key)
     - returns the key constant associated with the configurable player key of 'player'.
       Allowed player values are 0 - 3 or:
         PLAYER_1
         PLAYER_2
         PLAYER_3
         PLAYER_4
       Allowed player_key_constant values are:
         PLAYER_KEY_MENU
         PLAYER_KEY_UP
         PLAYER_KEY_DOWN
         PLAYER_KEY_LEFT
         PLAYER_KEY_RIGHT
         PLAYER_KEY_A
         PLAYER_KEY_B
         PLAYER_KEY_X
         PLAYER_KEY_Y

  void SetMousePosition(int x, int y)
     - Sets the x and y of the mouse cursor

  int GetMouseX()
     - returns the x location of the mouse cursor within the engine screen

  int GetMouseY()
     - returns the y location of the mouse cursor within the engine screen

  int IsMouseButtonPressed(int button)
     - returns true if the button is pressed
       allowed button values are: MOUSE_LEFT, MOUSE_RIGHT, MOUSE_MIDDLE

  int GetMouseWheelEvent()
     - returns the first key in the queue for mouse wheel events

  int GetNumMouseWheelEvents()
     - returns the size of the queue for mouse wheel events

  int GetNumJoysticks()
     - returns the number of joysticks available on the system

  int GetNumJoystickAxes(int joy)
     - returns the number of axes available on this joystick

  double GetJoystickAxis(int joy, int axis)
     - returns the current position of the 'axis' axis of the joystick 'joy'
       in normalized coordinates from -1 to 1
       Axis values can be: JOYSTICK_AXIS_X, JOYSTICK_AXIS_Y, JOYSTICK_AXIS_Z, JOYSTICK_AXIS_R

  int GetNumJoystickButtons(int joy)
     - returns the number of buttons available on this joystick

  boolean IsJoystickButtonPressed(int joy, int but)
     - returns true if the button on joystick 'joy' is pressed

*** time ***

  int GetTime()
     - returns the number of milliseconds since some arbitrary time.
       ex:
        var start = GetTime();
        while (GetTime() < start + 1000) {}

*** particle engine ***

  ParticleSystemParent_object CreateParticleSystemParent()
     - returns a new particle system parent object

  ParticleSystemChild_object CreateParticleSystemChild(int size)
     - returns a new particle system child object

*** networking ***

  string GetLocalName()
     - returns a string with the local name of your computer

  string GetLocalAddress()
     - returns a string with the IP address of your computer

  socket_object OpenAddress(string name, int port)
     - attempts to open a connection to the computer specified with 'address' on 'port'
       returns a socket object

  socket_object ListenOnPort(int port)
     - listens for connections on port, returns a socket object if successful

*** byte_arrays ***

  byte_array_object CreateByteArray(int size)
     - returns a ByteArray object of 'size' bytes

  byte_array_object CreateByteArrayFromString(string str)
     - returns a ByteArray object from string 'string'

  string CreateStringFromByteArray(byte_array_object array)
     - returns a ByteArray object from string 'string'

*** colors ***

  color_object CreateColor(int r, int g, int b [, int a])
     - returns a color object with the color r is Red, g is Green, b is Blue,
       and a is alpha (translucency of the color).
       Note + alpha of 0 = transparent, alpha of 255 = opaque
            + alpha is optional, and defaults to 255 if not specified

  void BlendColors(color_object a, color_object b)
     - returns a color object that is the blended color of color c1 and c2

  color_object BlendColorsWeighted(color_object a, color_object b, double w1, double w2)
     - blends two colors together, allowing you to specify the amount of each color
       ex:
       BlendColorsWeighted(a, b, 1, 1) // equal amounts (like BlendColors())
       BlendColorsWeighted(a, b, 1, 2) // 33% a, 66% b

*** mapengine ***

  void MapEngine(string map, int fps)
     - starts the map engine with the map specified and runs at 'fps' frames per second

  void ChangeMap(string map)
     - changes current map
     (This clears any pending delay scripts...)

  string GetCurrentMap()
     - Returns the current map, e.g. "noisyforest.rmp"

  void ExitMapEngine()
     - Exits the map engine. Note: This tells the map engine to shut
       down. This does not mean the engine shuts down immediately. You
       must wait for the original call to MapEngine() to return before you
       can start a new map engine.

  boolean IsMapEngineRunning()
     - Returns true if the map engine is running, false if not

  void UpdateMapEngine()
     - updates map engine (state of entities, color masks, etc.)

  void CallMapScript(int which)
     - calls a map's script from code
     the six events are:
       SCRIPT_ON_ENTER_MAP
       SCRIPT_ON_LEAVE_MAP
       SCRIPT_ON_LEAVE_MAP_NORTH
       SCRIPT_ON_LEAVE_MAP_EAST
       SCRIPT_ON_LEAVE_MAP_SOUTH
       SCRIPT_ON_LEAVE_MAP_WEST

  void SetDefaultMapScript(int which, string script)
     - set the default script that the map engine should call before calling the map's specific script
     (The default map script is called, then the map specific script is called.)
     The events are the same from CallMapScript.
     The map engine doesn't have to be on to set a default script.

  void RenderMap()
     - Renders the map into the video buffer

  void SetColorMask(color_object color, int num_frames)
     - applies a color mask to things drawn by the map engine for 'num_frames' frames

  void SetDelayScript(int num_frames, string script)
     - in 'num_frames' frames, runs 'script'
       ex: SetDelayScript(60, "ChangeMap('forest.rmp')");
       this tells the map engine to change to forest.rmp after 60 frames

  void CallDefaultMapScript(int which)
     - call the default map script
       The events are the same from CallMapScript.
       The map engine doesn't have to be on to call a default script.

*** layers ***

  int GetNumLayers()
     - get number of layers on map
     - in the following functions, layer 0 is the bottommost layer.
     - layer 1 is the next one up, etc.

  int GetLayerWidth(int layer)
     - get width of 'layer'

  int GetLayerHeight(int layer)
     - get height of 'layer'

  void SetLayerWidth(int layer, int width)
     - set width of 'layer'

  void SetLayerHeight(int layer, int height)
     - set height of 'layer'

  string GetLayerName(int layer)
     - returns the name of 'layer'

  boolean IsLayerVisible(int layer)
     - returns true if the layer is visible

  void SetLayerVisible(int layer, boolean visible)
     - shows 'layer' if visible == true, and hides it if visible == false
       e.g. SetLayerVisible(0, !IsLayerVisisble(0)); will toggle layer zero's visibility

  boolean IsLayerReflective(int layer)
     - returns true if the layer is reflective

  void SetLayerReflective(int layer, boolean reflective)
     - sets whether layer should be reflective

  void SetLayerScaleFactorX(int layer_index, double factor_x)
     - Sets the x zoom/scale factor for the layer 'layer_index' to 'factor_x'
       e.g. SetLayerScaleFactor(0, 0.5) will make the layer zoom out to half the normal size
     @see SetPersonScaleFactor

  void SetLayerScaleFactorY(int layer_index, double factor_y)
     - Sets the y zoom/scale factor for the layer 'layer_index' to 'factor_y'
       e.g. SetLayerScaleFactor(0, 2) will make the layer zoom in to twice the normal size
     @see SetPersonScaleFactor

  double GetLayerAngle(int layer_index)
     - Gets the angle (in radians) for the layer 'layer_index'
       e.g. var angle = GetLayerAngle(0) will get the angle for the first layer
       An angle of 0.0 is not rotated at all.
     @see SetLayerAngle

  void SetLayerAngle(int layer_index, double angle)
     - Sets the angle (in radians) for the layer 'layer_index' to 'angle'
       e.g. SetLayerAngle(0, Math.PI) will make the layer rotate slightly
     @see GetLayerAngle

*** tiles ***

  int GetNumTiles()
     - return number of tiles in map

  void SetTile(int x, int y, int layer, int tile)
     - changes tile on map to 'tile'

  int GetTile(int x, int y, int layer)
     - returns tile on map

  string GetTileName(int tile_index)
     - returns the name of the tile 'tile_index'

  int GetTileWidth()
     - returns width in pixels of tiles on current map

  int GetTileHeight()
     - returns height in pixels of tiles on current map

  image_object GetTileImage(int tile)
     - returns the image of the tile 'tile_index'

  void SetTileImage(int tile, image_object image)
     - sets the tile 'tile_index' to the image 'image_object'

  surface_object GetTileSurface(int tile)
     - returns the surface of the tile 'tile_index'

  void SetTileSurface(int tile, surface_object surface)
     - sets the tile 'tile_index' to the surface 'surface_object'

  int GetTileDelay(int tile)
     - gets the animation delay of the tile 'tile'
       If it returns 0, the tile is not animated

  void SetTileDelay(int tile, int delay)
     - sets the animation delay of the tile 'tile' to 'delay'
       A delay of 0 is considered not animated

  int GetNextAnimatedTile(int tile)
     - gets the next tile in the animation sequence of 'tile'
       Note that if the return value is 'tile' the tile is not animated.

  void SetNextAnimatedTile(int current_tile, int next_tile)
     - sets the next tile in the animation sequence of 'tile' to 'new_tile'
       SetNextAnimatedTile(tile, tile) turns off the tile animation for 'tile'

  void ReplaceTilesOnLayer(int layer, int old_tile, int new_tile)
     - Replaces all 'oldtile' tiles with 'newtile' on layer 'layer'

*** triggers ***

  boolean IsTriggerAt(int location_x, int location_y, int layer)
     - Returns true if there is a trigger at map_x, map_y on layer. map_x
       and map_y are in map (per-pixel) coordinates.
       (Currently the layer parameter is ignored, although it still must be valid.)

  void ExecuteTrigger(int location_x, int location_y, int layer)
     - activates the trigger positioned on map_x, map_y, layer if one exists.
       map_x and map_y are in map (per-pixel) coordinates.

  int GetTriggerX(int trigger_index)
     [DISABLED]- returns the x value of the trigger in map (per-pixel) coordinates

  int GetTriggerY(int trigger_index)
     [DISABLED]- returns the x value of the trigger in map (per-pixel) coordinates

  int GetNumTriggers()
     [DISABLED]- returns the amount of triggers that there is

  int GetCurrentTrigger()
       it will return the index of the trigger for which the current script
       is running
*** zones ***

  boolean AreZonesAt(int location_x, int location_y, int layer)
     - returns true if there are any zones at map_x, map_y on layer
       (Currently the layer parameter is ignored, although it still must be valid.)

  void ExecuteZones(int location_x, int location_y, int layer)
     - executes all the zones that map_x, map_y, layer is within
       map_x and map_y are in map (per-pixel) coordinates.
       (Currently the layer parameter is ignored, although it still must be valid.)

  void ExecuteZoneScript(int zone)
     - executes the script for the zone 'zone'

  int GetNumZones()
     - returns the amount of zones that there is

  int GetCurrentZone()
     - best when called from inside a ZoneScript handler
       it will return the index of the zone for which the current script
       is running

  int GetZoneX(int zone)
     - gets the x value of zone 'zone'

  int GetZoneY(int zone)
     - gets the y value of zone 'zone'

  int GetZoneWidth(int zone)
     - gets the width value of zone 'zone'

  int GetZoneHeight(int zone)
     - gets the height value of zone 'zone'

  int GetZoneLayer(int zone)
     - gets the layer value of zone 'zone'

  void SetZoneLayer(int zone, int layer)
     - sets the layer value of zone 'zone'

  void SetZoneDimensions(int zone, int x, int y, int width, int height)
     - sets the dimensions of zone 'zone'

*** obstruction segments functions ***

  int GetNumObstructionSegments([int layer])
     - Returns the number of obstruction segments on the map...

*** input ***

  void BindKey(int key, string on_down, string on_up)
     BindKey(key, onkeydown, onkeyup)
     - runs the 'onkeydown' script when the 'key' is pressed down and runs
       'onkeyup' when the 'key' is released
       ex: BindKey(KEY_SPACE, "mode = 'in';", "mode = 'out';");
       ex: BindKey(KEY_CTRL, "OnKeyPressed(KEY_CTRL)", "OnKeyReleased(KEY_CTRL)");
       refer to keys.txt for a list of key names

  void UnbindKey(int key)
     - unbinds a bound key

  void BindJoystickButton(int joystick, int button, string on_down, string on_up)
     - runs the 'on_down' script when the joystick 'button' is pressed down and runs
       'on_up' when the joystick button is released

  void UnbindJoystickButton(int joystick, int button)
     UnbindJoystickButton(joystick, button)
     - unbinds a bound joystick button

  void AttachInput(string person)
     - makes the 'person_entity' respond to the input
       (up = KEY_UP, down = KEY_DOWN, left = KEY_LEFT, right = KEY_RIGHT)
     @see AttachPlayerInput

  void DetachInput()
     - releases input from the attached person entity
     @see DetachPlayerInput

  boolean IsInputAttached()
     - returns true if a person is attached to the input
     @see IsPlayerInputAttached

  string GetInputPerson()
     - returns a string with the name of the person who currently holds input

  void AttachPlayerInput(string name, int player_index)
     - makes the 'person_entity' respond to the input
       Keys vary based on player_index (0,1,2 or 3)
       for now, only the up/down/left/right keys work. keyA, keyB, keyX and keyY are inoperative.

  void DetachPlayerInput(string name)
     - releases input from the attached player entity

  void SetUpdateScript(string script)
     - calls 'script' after each frame (don't draw stuff in here!)

  void SetRenderScript(string script)
     - calls 'script' after all map layers are rendered

  void SetLayerRenderer(int layer, string script)
     - calls the rendering 'script' after 'layer' has been rendered.
       Only one rendering script can be used for each layer of the map

  void SetLayerMask(int layer, color_object mask)
     - set the mask of 'layer' to 'mask'
       e.g. SetLayerMask(0, CreateColor(255, 0, 0, 128)); will make the layer semi red

  color_object GetLayerMask(int layer)
     - get the mask currently being used by 'layer'

*** camera functions ***

  void AttachCamera(string person)
     - Attaches the camera view to specified person

  void DetachCamera()
     - Detaches camera so it can be controlled directly

  boolean IsCameraAttached()
     - returns true if the camera is attached to a person, false if the
       camera is floating

  string GetCameraPerson()
     - returns a string with the name of the person whom the camera
       is attached to

  void SetCameraX(int x)
     - sets the x location of the camera object on the map
       (the center of the screen if possible)

  void SetCameraY(int y)
     - sets the y location of the camera object on the map
       (the center of the screen if possible)

  int GetCameraX()
     - returns the x location of the camera object on the map
       (the center of the screen if possible)

  int GetCameraY()
     - returns the y location of the camera object on the map
       (the center of the screen if possible)

  int MapToScreenX(int layer, int mx)
     - returns screen coordinates of position on map

  int MapToScreenY(int layer, int my)
     - returns screen coordinates of position on map

  int ScreenToMapX(int layer, int sx)
     - returns map coordinates of position on screen

  int ScreenToMapY(int layer, int sy)
     - returns map coordinates of position on screen

*** person functions ***

  array GetPersonList()
     - returns an array of strings representing the current person entities
       (unnamed persons will not be in this list)

  boolean DoesPersonExist(string name)
     - Searches for person 'name' in the current person list and returns true if found.

  void CreatePerson(string name, string spriteset, boolean destroy_with_map)
     - returns a person object with 'name' from 'spriteset'. If Sphere is
       unable to open the file, the engine will give an error message and
       exit. destroy_with_map is a boolean (true/false value), which the
       spriteset is destroyed when the current map is changed if the flag
       is set to true.

  void DestroyPerson(string name)
     - destroys the person with the name

  void SetPersonX(string name, int x)
     - sets the x position of the person on the map

  void SetPersonY(string name, int y)
     - sets the y position of the person on the map

  void SetPersonOffsetX(string name, int offx)
     - sets the horizontal offset of the person on the map

  void SetPersonOffsetY(string name, int offy)
     - sets the vertical offset of the person on the map

  void SetPersonXYFloat(string name, double x, double y)
     - sets the position of the person with floating point accuracy

  void SetPersonLayer(string name, int layer)
     - sets the position of the person on the map

  int GetPersonX(string name)
     - gets the position of the person on the map
       The position is based on the middle of the spriteset's base
       rectangle.

  int GetPersonY(string name)
     - gets the position of the person on the map
       The position is based on the middle of the spriteset's base
       rectangle.

  int GetPersonOffsetX(string name)
     - gets the position of the person on the map
       The position is based on the middle of the spriteset's base
       rectangle.

  int GetPersonOffsetY(string name)
     - gets the position of the person on the map
       The position is based on the middle of the spriteset's base
       rectangle.

  double GetPersonXFloat(string name)
     - gets the position of the person on the map
       The position is based on the middle of the spriteset's base
       rectangle.

  double GetPersonYFloat(string name)
     - gets the position of the person on the map
       The position is based on the middle of the spriteset's base
       rectangle.

  int GetPersonLayer(string name)
     - gets the position of the person on the map

  void IgnorePersonObstructions(string name, boolean ignoring)
     - Sets whether 'person' should ignore other spriteset bases

  boolean IsIgnoringPersonObstructions(string name)
     - Returns true if 'person' is ignoring person obstructions, else false

  void IgnoreTileObstructions(string name, boolean ignoring)
     - Sets whether 'person' should ignore tile obstructions

  boolean IsIgnoringTileObstructions(string name)
     - Returns true if 'person' is ignoring tile obstructions, else false

  array GetPersonIgnoreList(string name)
     - Returns a list of people that 'name' is ignoring

  void SetPersonIgnoreList(string name, array array [, string ignore_list[i]])
     - Tells 'name' to ignore everyone in list
       e.g. SetPersonIgnoreList("White-Bomberman", ["bomb", "powerup"]);
       Tells White-Bomberman to not be obstructed by bombs or powerups

  void FollowPerson(string person, string leader, int pixels)
     - makes the sprite 'name' follow 'pixels' pixels behind sprite 'leader'.
       If this function is called like:
       FollowPerson(name, "", 0),
       the person will detach from anyone it is following.

  void SetPersonDirection(string name, string direction)
     - sets which direction to show

  string GetPersonDirection(string name)
     - gets which direction is being shown

  void SetPersonFrame(string name, int frame [, boolean resetFrameDelay])
     - sets which frame to show
       It will retain the frame delay count of the previous frame, unless
       the third optional parameter is false

  int GetPersonFrame(string name)
     - gets which frame is being shown

  void SetPersonFrameNext(string name, int frame)
     - sets the remaining frame delay for the current frame

  int GetPersonFrameNext(string name)
     - gets the remaining frame delay for the current frame
     @see GetPersonSpriteset

  void SetPersonFrameRevert(string name, int frames)
     - sets the delay between when the person last moved and returning to
       first frame. 0 disables this behaviour.

  int GetPersonFrameRevert(string name)
     - gets the delay between when the person last moved and returning to
       first frame. 0 disables this behaviour.

  void SetPersonSpeed(string name, double speed)
     - sets the speed at which a person moves at

  void SetPersonSpeedXY(string name, double x, double y)
     - sets the speed at which a person moves at

  double GetPersonSpeedX(string name)
     - gets the speed at which a person moves at

  double GetPersonSpeedY(string name)
     - gets the speed at which a person moves at

  int GetPersonVector(string name, boolean historical)
     - gets the unitarian directional vector as a single number: x+(y<<2)
       The directional vector is 0 when the person is not moving, use
       historical to retrieve the previous value
       Convert Vector to direction:
       function V2D(v){
         switch(v){
             case -5: return 'northwest'; break;
             case -4: return 'north'; break;
             case -3: return 'northeast'; break;
             case -1: return 'west'; break;
             case 1: return 'east'; break;
             case 3: return 'southwest'; break;
             case 4: return 'south'; break;
             case 5: return 'southeast'; break;
             default: return '';
         }
       }
       Convert Vector to coordinates:
       function V2C(v){var y=(1+v>>2)&-1;return {x:v-(y<<2),y:y};}

  void SetPersonScaleFactor(string name, double scale_w, double scale_h)
     - rescales the sprite to a certain scale specified by scale_w and scale_h.
       Scaling is determined by floating point numbers like, 1.5 would scale
       the person to 1.5 times its normal size based on his original sprite
       size.

  void SetPersonScaleAbsolute(string name, int width, int height)
     - rescales the sprite to width pixels and height pixels.

  object GetPersonData(string name)
     - gets a data object assiocated with the person 'name'
       There are certain default properties/values filled in by the engine, they are:
       num_frames - the number of frames for the person's current direction
       num_directions - the number of directions for the person
       width - the width of the spriteset's current frame
       height - the height of the spriteset's current frame
       leader - the person that this person is following, or "" if no-one...
       destroy_with_map - if the person is destroyed with the map or not
       obs_person - obstructed person index (-1 if not obstructed)
       Any other properties are free for you to fill with values
       e.g. var data = GetPersonData("Jimmy");
       var num_frames = data["num_frames"];
       note: Objects can not be stored, only numbers, booleans and strings.

  void SetPersonData(string name, object data_object [, string data.name])
     - sets the 'data' object associated with the person 'name'
       e.g.
       var data = GetPersonData("Jimmy");
       data["talked_to_jimmy"] = true;
       SetPersonData("Jimmy", data);
       note: Objects can not be stored, only numbers, booleans and strings.

  string GetPersonValue(string name, string key)
     - get a single person value. Example: GetPersonValue("Jimmy", "num_frames");
     @see GetPersonData

  void SetPersonValue(string name, string key)
     - set a person value. You can set boolean, numeric and string values
       SetPersonValue("Jimmy", "talked_to_jimmy", true);

  spriteset_object GetPersonSpriteset(string name)
     - returns the person's spriteset.
       Although you can't add/delete directions, or add/delete frames you can change
       all properties. You can create a new spriteset using @see CreateSpriteset
       ss.images[] - An array of images
       ss.base.x1, ss.base.y1, ss.base.x2, ss.base.y2 - The _real_ obstruction base
       ss.directions[0].name - the name of direction 0
       ss.directions[0].frames[0].index - the index to images for the first frame
       ss.directions[0].frames[0].delay - the delay showing that frame
     @see CreateSpriteset

  void SetPersonSpriteset(string name, spriteset_object spriteset)
     - set's the person's spriteset to spriteset
       e.g. SetPersonSpriteset("Jimmy", LoadSpriteset("jimmy.running.rss"));

  spriteset_base_object GetPersonBase(string name [, boolean real])
     - returns the person's base obstruction object. The values are sensitive to scaling,
       unless you set 'real' to true.
       The object contains the following properties: x1, x2, y1 and y2 (base coordinates)
       You also can use GetPersonSpriteset and fetch the .base properties of it.
     @see GetPersonSpriteset

  void SetPersonBase(string name, int x1, int y1, int x2, int y2)
     - Sets the person's base obstruction object.
       Note: If the person is zoomed, you still need to define the base as if the person
       was not scaled, and use SetPersonScaleFactor(person,GetPersonScaleFactor(person));
       to update the base.

  double GetPersonAngle(string name)
     - returns the person's angle that is used

  void SetPersonAngle(string name, double angle)
     - sets the angle which the person should be drawn at
       Note:
         Zero is no rotation, and angles are in radians.
         It does not rotate the spritesets obstruction base.

  void SetPersonMask(string name, color_object mask)
     - sets a color multiplier to use when drawing sprites. if the color is
       RGBA:(255, 0, 0, 255), only the red elements of the sprite are drawn.
       If the color is RGBA:(255, 255, 255, 128), the sprite is drawn at
       half transparency.

  color_object GetPersonMask(string name)
     - returns the person's current mask

  boolean IsPersonVisible(string name)
     - returns the person's visible status

  void SetPersonVisible(string name, boolean visible)
     - sets the person's visible status, true = visible, false = not visible
       e.g. SetPersonVisible(GetCurrentPerson(), !IsPersonVisible(GetCurrentPerson()));

  void SetPersonScript(string name, int which, string script)
     - sets 'script' as the thing 'name' does in a certain event
       the five events are
       SCRIPT_ON_CREATE
       SCRIPT_ON_DESTROY
       SCRIPT_ON_ACTIVATE_TOUCH
       SCRIPT_ON_ACTIVATE_TALK
       SCRIPT_COMMAND_GENERATOR
       (SCRIPT_COMMAND_GENERATOR will be called when the command queue for
        the person runs out (for random movement thingies, etc))

  string GetPersonScript(string name, int which)
     - Gets 'script' as the thing 'name' does in a certain event
       the five events are
       SCRIPT_ON_CREATE
       SCRIPT_ON_DESTROY
       SCRIPT_ON_ACTIVATE_TOUCH
       SCRIPT_ON_ACTIVATE_TALK
       SCRIPT_COMMAND_GENERATOR
       (SCRIPT_COMMAND_GENERATOR will be called when the command queue for
        the person runs out (for random movement thingies, etc))

  void SetDefaultPersonScript(int which, string script)
     - sets 'script' as the thing that everyone does in a certain event
       the five events are see above

  void CallPersonScript(string name, int which)
     - calls a person's script from code
       'which' constants are the same as for SetPersonScript()

  string GetCurrentPerson()
     - best when called from inside a PersonScript handler
       it will return the name of the person for whom the current script
       is running

  void QueuePersonCommand(string name, int command, boolean immediate)
     - adds a command to the person's command queue
       the commands are:
       COMMAND_WAIT
       COMMAND_FACE_NORTH
       COMMAND_FACE_NORTHEAST
       COMMAND_FACE_EAST
       COMMAND_FACE_SOUTHEAST
       COMMAND_FACE_SOUTH
       COMMAND_FACE_SOUTHWEST
       COMMAND_FACE_WEST
       COMMAND_FACE_NORTHWEST
       COMMAND_MOVE_NORTH
       COMMAND_MOVE_EAST
       COMMAND_MOVE_SOUTH
       COMMAND_MOVE_WEST
       (note: these *might* change in a future release
        'immediate', if true, will execute the command go right away
        if false, it will wait until the next frame)

  void QueuePersonScript(string name, string script, boolean immediate)
     - adds a script command to the person's queue

  void ClearPersonCommands(string name)
     - clears the command queue of sprite with the 'name'

  boolean IsCommandQueueEmpty(string name)
     - returns true if the person 'name' has an empty command queue

  int GetObstructingTile(string name, int x, int y)
     - returns -1 if name isn't obstructed by a tile at x, y,
     - returns the tile index of the tile if name is obstructed at x, y

  string GetObstructingPerson(string name, int x, int y)
     - returns "" if name isn't obstructed by person at x, y,
     - returns the name of the person if name is obstructed at x, y
       To check if more persons obstruct, move the first one away.

  boolean IsPersonObstructed(string name, int x, int y)
     - returns true if person 'name' would be obstructed at (x, y)

  void SetTalkActivationKey(int key)
     - set key used to activate talk scripts

  int GetTalkActivationKey()
     - get key used to activate talk scripts

  int GetTalkActivationButton()
     - get button used to activate talk scripts

  void SetTalkActivationButton(int button)
     - set button used to activate talk scripts

  void SetTalkDistance(int pixels)
     - set distance to check for talk script activation

  int GetTalkDistance()
     - get distance to check for talk script activation

  spriteset_object LoadSpriteset(string filename)
     - returns a spriteset object from 'filename'. If Sphere is unable to open
       the file, the engine will give an error message and exit.

  spriteset_object CreateSpriteset(int frame_width, int frame_height, int num_images, int num_directions, int num_frames)
     - returns a new spriteset.

*** Sound related functions ***

  sound_object LoadSound(string filename [, boolean streaming])
     - returns a sound object from 'filename'. If Sphere is unable to open
       the file, the engine will give an error message and exit. If the optional
       argument 'streaming' is true or unspecified, the sound is streamed from the
       hard drive. Otherwise, it's loaded into memory.

  soundeffect_object LoadSoundEffect(string filename [, int type])
     - returns a sound effect object from 'filename'. If Sphere is unable to open
       the file, the engine will give an error message and exit.
       There are two types of sound effects: SE_SINGLE and SE_MULTIPLE.
       SE_SINGLE sound effects only allow the sound to be played once at a time.
       SE_MULTIPLE sound effects always open a new stream to the audio device
       for each time it is played (cleaning up or reusing old streams if possible).

  sound_object CreateSound(byte_array_object array [, boolean streaming])
     - returns a sound from bytearray.

  soundeffect_object CreateSoundEffect(byte_array_object ba)
     - returns a soundeffect from bytearray.

  sfxr_object CreateSfxr()
     - returns an Sfxr object. The parameters are optional and can be set later on.
       bitrate, samplerate, soundvolume, wavetype, basefrequency, minfrequency,
       frequencyslide, frequencyslidedelta, squareduty, squaredutysweep, vibratodepth,
       vibratospeed, attack, sustain, detay, release, filter, lowpassfiltercutoff,
       lowpassfiltercutoffsweep, filterresonance, highpassfiltercutoff, highpassfiltercutoffsweep,
       phaseroffset, phaseroffsetsweep, repeatspeed, arpeggio, arpeggiospeed

  string BgmName()
     - Returns the name of the current map background music (could be a m3u list)

  int BgmValid()
     - Returns the type of the current map background music: 0: none 1: midi 2: wav/mp3/it/xm

  boolean BgmPlay()
     - Starts the current map background music. If it is already playing, or doesnt exist, it does nothing.
       Returns true if the music is playing

  boolean BgmStop()
     - Stops the current map background music. If it is already stopped, or doesnt exist, it does nothing.
       Returns true if the music is stopped

  boolean BgmIsPlaying()
     - Tells us if the background music is playing

  boolean BgmReset()
     - Rewind the background music. (Can be slow on streamed music)

  boolean BgmSetRepeat(boolean onoff)
     - Enable/Disable Loop the current background music (it is repeated by default)
       Returns true if it succeeded setting the boolean value.

  boolean BgmGetRepeat()
     - Returns true if the current background music is looped. False if not.

  void BgmSetVolume(int volume)
     - Sets the volume of the current background music. The volume can be 0 to 255.
     - no effect on MIDIs

  int BgmGetVolume()
     - Gets the volume of the current background music. The volume can be 0 to 255.
     - no effect on MIDIs

  void BgmSetPan(int pan)
     - pan can be from -255 to 255. -255 = left, 255 = right. pan defaults to 0 (center).
     - no effect on MIDIs

  int BgmGetPan()
     - returns the current pan of the sound (-255 to 255)
     - no effect on MIDIs

  void BgmSetPitch(double pitch)
     - pitch ranges from 0.5 to 2.0. 0.5 is an octave down (and half as fast)
       while 2.0 is an octave up (and twice as fast). pitch defaults to 1.0
     - no effect on MIDIs

  double BgmGetPitch()
     - returns the current pitch
     - no effect on MIDIs

  boolean BgmIsSeekable()
     - returns true if the background music is seekable

  int BgmGetLength()
     - returns the length the background music. Music must be seekable.

  void BgmSetPosition(int pos)
     - sets the position of the sound
       if the sound isn't seekable, this does nothing

  boolean BgmGetPosition()
     - gets the position of the sound
       if the sound isn't seekable, this does nothing

*** Font functions ***

  font_object GetSystemFont()
     - returns a font object of the font that the engine currently uses.

  font_object LoadFont(string filename)
     - returns a font object from 'filename'. If Sphere is unable to open
       the file, the engine will give an error message and exit.

*** windowstyle functions ***

  windowstyle_object GetSystemWindowStyle()
     - returns a windowstyle object of the windowstyle that the engine currently
       uses.

  windowstyle_object LoadWindowStyle(string filename)
     - returns a windowstyle object from 'filename'. If Sphere is unable to open
       the file, the engine will give an error message and exit.

  image_object GetSystemArrow()
     - returns an image object of the System Arrow that the engine currently uses.

  image_object GetSystemUpArrow()
     - returns an image object of the System Arrow(up) that the engine currently
       uses.

  image_object GetSystemDownArrow()
     - returns an image object of the System Arrow(down) that the engine
       currently uses.

*** image functions ***

  image_object LoadImage(string filename)
     - returns an image object from 'filename'. If Sphere is unable to open or
       read the image, the engine will give an error message and exit. The
       image type that the engine supports are either PCX, BMP, JPG, and PNG.

  image_object GrabImage(int x, int y, int w, int h)
     - returns an image object from a section of the video buffer
       defined by the parameters

  surface_object CreateSurface(int w, int h, color_object c)
     - returns a surface object with width x height, filled with color

  surface_object LoadSurface(string filename)
     - returns a surface object with an image with the 'filename'

  surface_object GrabSurface(int x, int y, int w, int h)
     - returns a surface object captured from an area of the video buffer,
       at (x, y) with the width w and height h.
     @see GrabImage

  colormatrix_object CreateColorMatrix(int rn, int rr, int rg, int rb, int gn, int gr, int gg, int gb, int bn, int br, int bg, int bb)
     - Creates a colormatrix that is used to transform the colors
       contained in a pixel with the following formula:
         newcolor.red = rn + (rr * oldcolor.red + rg * oldcolor.green + rb * oldcolor.blue) / 255;
         newcolor.green = gn + (gr * oldcolor.red + gg * oldcolor.green + gb * oldcolor.blue) / 255;
         newcolor.blue = bn + (br * oldcolor.red + bg * oldcolor.green + bb * oldcolor.blue) / 255;
     @see surface.applyColorFX
     @see surface.applyColorFX4

*** animation functions ***

  animation_object LoadAnimation(string filename)
     - Returns an animation object with the filename. If Sphere is unable to
       open the file, the engine will give an error message and exit. Sphere
       supports animation formats of .flic, .fli, .flc and .mng, .jng

*** File related functions ***

  boolean Rename(string old_path, string new_path)
     - rename or move a file or directory

  boolean CreateDirectory(string directory)
     - create a new directory

  boolean RemoveDirectory(string directory)
     - remove the specified directory

  boolean RemoveFile(string filename)
     - remove the specified file.
       This start from your game directory, so if you want to delete a logfile:
       RemoveFile('logs/mylog.log');

  array GetDirectoryList([string directory])
     - directory = directory in which to enumerate directories,
       current game's directory if not specified
     - returns an array of strings, which contains the directory names that resides
       in the 'directory' directory of the game.

  array GetFileList([string directory])
     - directory = directory in which to enumerate files, "save" if not specified
     - returns an array of strings, which contains the filenames that resides
       in the 'directory' directory of the game.

  file_object OpenFile(string filename)
     - returns a file object with the filename. The file is created/loaded
       from the "save" directory of the game. Note that any changes in the keys
       will not be saved until the file object is destroyed.

  rawfile_object OpenRawFile(string filename [, boolean writeable])
     - opens a file with the filename.
       Unless writeable is true, the file *must* exist and reside
       in the "other" directory of the game otherwise Sphere will give an error.
       If the file is opened successfully, the function will return a rawfile
       object. If the optional argument 'writeable' is true,
       the contents of the file will be destroyed,
       and you will be able to write to the file.

  log_object OpenLog(string filename)
     - opens a log file for use under the filename. If Sphere is unable to open
       the file for logging, the engine will give an error message and exit.
       If Sphere is successful in opening the file, it will return a log object
       for use.
       ex: var myLog = OpenLog("game.log");

  object GetMapEngine()
     - Gets the currently open mapengine object...

  string HashFromFile(string filename)
     - generates an MD5 of the specified raw file, which, by backtracking
       with a ../ may refer to any file within the game directory structure.
       The result is a 32 character string containing the hexadecimal
       representation of the resulting 128-bit MD5 fingerprint. Identical
       files produce the same MD5 hash so it is an effective way to determine
       if a file has become corrupt or altered

  string HashByteArray(byte_array_object array)
     - generates an MD5 fingerprint as a hexadecimal string whose output
       is the same as the RSA reference implementation of RFC 1321 which
       means that the unix md5 command will return the same string for the
       identical input. The resulting string contains the hexadecimal
       representation of the MD5 fingerprint for the specified byte
       array object

  int DeflateFile(string filename_source, string filename_dest [, int compressionlevel])
     - Decompress a file to another file using deflate
       The default base directory is other/, use ../ to reach other directories.
       compressionlevel must be between 0 and 9, and is 6 by default
       Returns zero on succes, nonzero if it failed.
       The return numbers are (the constants are not defined in Sphere):
       Z_OK 0
       Z_STREAM_END 1
       Z_NEED_DICT 2
       Z_ERRNO (-1)
       Z_STREAM_ERROR (-2)
       Z_DATA_ERROR (-3)
       Z_MEM_ERROR (-4)
       Z_BUF_ERROR (-5)
       Z_VERSION_ERROR (-6)

  int InflateFile(string filename_source [, string filename_dest])
     - Decompress a file to another file using deflate
       The default base directory is other/, use ../ to reach other directories.
       Returns zero on succes, nonzero if it failed. (same codes as DeflateFile)

  array DeflateByteArray(byte_array_object ba [, int compressionlevel, int maxsize])
     - Compress a bytearray and return a deflated version.
       compressionlevel must be between 0 and 9, and is 6 by default.
       You can limit the maximum allowed size with maxsize.
       Returns null on failure.
       Note: for small strings, the compressed version could actually be bigger.

  byte_array_object InflateByteArray(byte_array_object ba [, int maxsize])
     - Decompress a bytearray and return an inflated version.
       You can limit the maximum allowed size with maxsize, if you don't
       it will set an estimation for you, which could be too low.
       Returns null on failure.

PARTICLEBODY
PARTICLEINITIALIZER
  void ParticleInitializer.getAgingParams()
     - returns an wrapper object filled with aging initialization parameters
     - following signature is possible:
       {min: -, max: -}

  void ParticleInitializer.setAgingParams(object params)
     - accepts a wrapper object filled with aging initialization parameters to set
     - the same parameters are accepted as returned by getAgingParams()
     - parameters which should not be set, can be omitted

  void ParticleInitializer.getPosParams([int shape])
     - returns a wrapper object filled with position initialization parameters
     - if 'shape' is not specified, the parameters for the current shape are returned,
       or if 'shape' is specified, the parameters belonging to the 'shape' are returned
     - following signatures are possible:
         {shape: PS_SHAPE_NULL}
         {shape: PS_SHAPE_RECTANGLE,
              x: {min: -, max: -},
              y: {min: -, max: -}}
         {shape: PS_SHAPE_ELLIPSE,
          angle: {min: -, max: -},
              a: {min: -, max: -},
              b: {min: -, max: -}}

  void ParticleInitializer.setPosParams(object params)
     - accepts a wrapper object filled with position initialization parameters to set
     - the same parameters are accepted as returned by getPosParams()
     - parameters which should not be set, can be omitted
     - if 'shape' is omitted, the parameters are assumed to belong to the current shape

  void ParticleInitializer.getVelParams()
     - returns a wrapper object filled with velocity initialization parameters
     - following signature is possible:
           {mode: -,
            angle: {min: -, max: -},
                a: {min: -, max: -},
                b: {min: -, max: -}}
       mode can be either PS_ORIENTATION_EXPLICIT or PS_ORIENTATION_IMPLICIT

  void ParticleInitializer.setVelParams(object params)
     - accepts a wrapper object filled with position initialization parameters to set
     - the same parameters are accepted as returned by getVelParams()
     - parameters which should not be set, can be omitted

PARTICLEUPDATER
-
PARTICLERENDERER
PARTICLECALLBACK
PARTICLEDESCENDANTS
  int ParticleDescendants.size()
     -

  void ParticleDescendants.unique()
     -

  void ParticleDescendants.apply()
     -

  void ParticleDescendants.sort()
     -

  boolean ParticleDescendants.contains(int id)
     -

  boolean ParticleDescendants.containsGroup(int group)
     -

  ParticleDescendants ParticleDescendants.get(int id)
     -

  array ParticleDescendants.getGroup(int group)
     -

  ParticleDescendants ParticleDescendants.extract(int id)
     -

  array ParticleDescendants.extractGroup(int group)

  void ParticleDescendants.remove(int id)
     -

  void ParticleDescendants.removeGroup(int group)
     -

  void ParticleDescendants.clear()
     -

PARTICLESYSTEMPARENT
-
  void ParticleSystemParent.update()
     - ask particle system to update

  void ParticleSystemParent.render()
     - ask particle system to render

  void ParticleSystemParent.adopt()
     - adopt the particle_system

  void ParticleSystemParent.host()
     - host the particle_system, hosted systems' bodies are neither initialized nor updated

  boolean ParticleSystemParent.isDead()
     - return true, if the system is dead

  void ParticleSystemParent.kill()
     - kills the system, this will trigger the on_death callback, if set

  void ParticleSystemParent.revive()
     - revives the system, this will trigger the on_birth callback, if set

PARTICLESWARMRENDERER
-
PARTICLESWARM
  int ParticleSwarm.size()
     -
     -

  int ParticleSwarm.capacity()
     -

  void ParticleSwarm.grow()
     -

  void ParticleSwarm.shrink()
     -

  void ParticleSwarm.resize(int new_size)
     -

  void ParticleSwarm.reserve(int new_capacity)
     -

  void ParticleSwarm.clear()
     -

PARTICLESYSTEMCHILD
-
  void ParticleSystemChild.update()
     -

  void ParticleSystemChild.render()
     -

  ParticleSystemChild_object ParticleSystemChild.clone()
     -

  boolean ParticleSystemChild.isDead()
     -

  void ParticleSystemChild.kill()
     -

  void ParticleSystemChild.revive()
     -

SOCKET
  boolean socket.isConnected()
     - returns true if the socket is connected

  int socket.getPendingReadSize()
     - returns the size of the next array to be read in the socket

  byte_array_object socket.read(int size)
     - reads from the socket, returns a ByteArray object
       or returns null if it fails
       e.g.
       var data = socket.read(size);
       if (data != null) {
         // do stuff with data
       }

  void socket.write(byte_array_object array)
     - writes a ByteArray object into the socket

  void socket.close()
     - closes the socket object, after this, the socket cannot be used.

LOG
  void log.write(string text)
     - writes a string of text under the current block.
       ex: myLog.write("Starting system...");

  void log.beginBlock(string name)
     - creates a "block" which is indent inside the log with the name as the
       title of the block. Any subsequent write commands will go under the newly
       created block.
       ex: myLog.beginBlock("Video Information");

  void log.endBlock()
     - closes the current log block.

COLOR
color.red
color.green
color.blue
color.alpha
- Colors must be between 0 and 255. And are automatically clamped.
  string color.toJSON()
     - exports the Color to a string, used internally by JSON
       This string can be eval()'ed to recreate the color

SPRITESET
spriteset.images
spriteset.directions[].name
spriteset.directions[].frames[].index
spriteset.directions[].frames[].delay
spriteset.base.x1
spriteset.base.y1
spriteset.base.x2
spriteset.base.y2
  void spriteset.save(string filename)
     - saves the spriteset object to 'filename'

  spriteset_object spriteset.clone()
     - returns a copy of the spriteset object

SOUND
  void sound.play([boolean bool repeat])
     - plays the sound. repeat is a boolean (true/false), that indicates if
       the sound should be looped

  void sound.pause()
     - pauses playback. call play() again to resume playback.

  void sound.stop()
     - stops playback

  void sound.reset()
     - resets playback
     - no effect on MIDIs

  void sound.setRepeat(boolean repeat)
     - sets if the sound should be repeated

  boolean sound.getRepeat()
     - returns true if sound is set to repeat, otherwise false

  void sound.setVolume(int volume)
     - sets the volume for the sound (0-255)
     - no effect on MIDIs

  int sound.getVolume()
     - returns the sound's volume (0-255)
     - no effect on MIDIs

  void sound.setPan(int pan)
     - pan can be from -255 to 255. -255 = left, 255 = right. pan defaults to 0 (center).
     - no effect on MIDIs

  int sound.getPan()
     - returns the current pan of the sound
     - no effect on MIDIs

  void sound.setPitch(double pitch)
     - pitch ranges from 0.5 to 2.0. 0.5 is an octave down (and half as fast)
       while 2.0 is an octave up (and twice as fast). pitch defaults to 1.0
     - no effect on MIDIs

  double sound.getPitch()
     - returns the current pitch
     - no effect on MIDIs

  boolean sound.isPlaying()
     - returns true if the sound is currently playing

  boolean sound.isSeekable()
     - returns true if the sound is seekable
       Not all sound types are seekable, Ogg is.

  int sound.getPosition()
     - returns the position of the sound
       returns zero if the sound isn't seekable

  void sound.setPosition(int pos)
     - sets the position of the sound
       if the sound isn't seekable, this does nothing

  int sound.getLength()
     - gets the length of the sound

  sound_object sound.clone()
     - creates a copy of the sound object (currently doesn't really work)

SOUNDEFFECT
  void soundeffect.play()
     - plays the sound effect.
       If the sound effect is of type SE_SINGLE, this plays the sound
       if it isn't playing yet, and starts it again if it is.
       If the sound effect is of type SE_MULTIPLE, play() simply starts
       playing the sound again.

  void soundeffect.stop()
     - stops playback
       If the sound is of type SE_SINGLE, stop the sound.
       If it is of type SE_MULTIPLE, stop all playing instances of the sound.

  void soundeffect.setVolume(int volume)
     - sets the volume for the sound effect (0-255)

  int soundeffect.getVolume()
     - returns the sound effect's volume (0-255)

  void soundeffect.setPan(int pan)
     - pan can be from -255 to 255. -255 = left, 255 = right. pan defaults to 0 (center).

  int soundeffect.getPan()
     - returns the current pan of the sound effect

  void soundeffect.setPitch(double pitch)
     - pitch ranges from 0.5 to 2.0. 0.5 is an octave down (and half as fast)
       while 2.0 is an octave up (and twice as fast). pitch defaults to 1.0

  double soundeffect.getPitch()
     - returns the current pitch

SFXR
  boolean sfxr.saveWav(string filename)
     - saves the sfxr as a wav file
       It will use the ./sounds/ directory by default

  boolean sfxr.reset()
     - resets all the values of the sfxr object

  soundeffect_object sfxr.getSoundEffect([int type])
     - Creates a soundeffect. The parameter can be SE_MULTIPLE or SE_SINGLE

  int sfxr.calcSampleSize()
     - Get the sample size

  void sfxr.setMasterVolume(double volume)
     - Set the master volume of the sfxr object

  double sfxr.getMasterVolume()
     - Get the master volume of the sfxr object

  double sfxr.getSoundVolume()
     - Get the volume of the sfxr object

  void sfxr.setSoundVolume(double v)
     - Set the volume of the sfxr object

  int sfxr.getBitrate()
     - Get the bitrate of the sfxr object
       This value can be 8 or 16

  void sfxr.setBitrate(int v)
     - Set the bitrate of the sfxr object
       This value can be 8 or 16

  int sfxr.getSampleRate()
     - Get the samplerate of the sfxr object

  void sfxr.setSampleRate(int v)
     - Set the sample rate of the sfxr object
       For example: 44100, 22500, 11000 or 8000.
       Changing the samplerate effectively changes the pitch

  int sfxr.getWaveType()
     - Get the wave type of the sfxr object

  void sfxr.setWaveType(int wavetype)
     - Set the wave type of the sfxr object
       Valid values are: SQUAREWAVE, SAWTOOTH, SINEWAVE and NOISE

  double sfxr.getBaseFrequency()
     - Get the base frequency of the sfxr object

  void sfxr.setBaseFrequency(double v)
     - Set the base frequency of the sfxr object
       This is for sliding the sound in pitch
       Value must be between 0 and 1

  double sfxr.getMinFrequency()
     - Get the minimal frequency of the sfxr object

  void sfxr.setMinFrequency(double v)
     - Set the minimal frequency of the sfxr object
       Value must be between 0 and 1

  double sfxr.getFrequencySlide()
     - Get the frequency slide of the sfxr object

  void sfxr.setFrequencySlide(double v)
     - Set the frequency slide of the sfxr object
       Value must be between -1 and 1

  double sfxr.getFrequencySlideDelta()
     - Get the frequency slide delta of the sfxr object

  void sfxr.setFrequencySlideDelta(double v)
     - Set the frequency slide delta of the sfxr object
       Value must be between -1 and 1

  double sfxr.getSquareDuty()
     - Get the square duty of the sfxr object

  void sfxr.setSquareDuty(double v)
     - Set the square duty of the sfxr object
       Value must be between 0 and 1

  double sfxr.getSquareDutySweep()
     - Get the square duty sweep of the sfxr object

  void sfxr.setSquareDutySweep(double v)
     - Set the square duty sweep of the sfxr object
       Value must be between 0 and 1

  double sfxr.getVibratoDepth()
     - Get the vibrato depth of the sfxr object

  void sfxr.setVibratoDepth(double v)
     - Set the vibrato depth of the sfxr object
       Value must be between 0 and 1

  double sfxr.getVibratoSpeed()
     - Get the vibrato speed of the sfxr object

  void sfxr.setVibratoSpeed(double v)
     - Set the vibrato speed of the sfxr object
       Value must be between 0 and 1

  double sfxr.getVibratoDelay()
     - Get the vibrato delay of the sfxr object

  void sfxr.setVibratoDelay(double v)
     - Set the vibrato delay of the sfxr object
       Value must be between 0 and 1

  double sfxr.getAttack()
     - Get the attack envelope of the sfxr object

  void sfxr.setAttack(double v)
     - Set the attack envelope of the sfxr object
       Value must be between 0 and 1

  double sfxr.getSustain()
     - Get the sustain envelope of the sfxr object

  void sfxr.setSustain(double v)
     - Set the sustain envelope of the sfxr object
       Value must be between 0 and 1

  double sfxr.getDecay()
     - Get the decay envelope of the sfxr object

  void sfxr.setDecay(double v)
     - Set the decay envelope of the sfxr object
       Value must be between 0 and 1

  double sfxr.getRelease()
     - Get the release envelope of the sfxr object

  void sfxr.setRelease(double v)
     - Set the release envelope of the sfxr object
       Value must be between 0 and 1

  boolean sfxr.getFilter()
     - Get the filter of the sfxr object

  void sfxr.setFilter(boolean isOn)
     - Set the filter of the sfxr object
       Not sure what this does

  double sfxr.getLowPassFilterCutoff()
     - Get the low pass filter cutoff of the sfxr object

  void sfxr.setLowPassFilterCutoff(double v)
     - Set the low pass filter cutoff of the sfxr object
       Value must be between 0 and 1

  double sfxr.getLowPassFilterCutoffSweep()
     - Get the low pass filter cutoff sweep of the sfxr object

  void sfxr.setLowPassFilterCutoffSweep(double v)
     - Set the low pass filter cutoff sweep of the sfxr object
       Value must be between -1 and 1

  double sfxr.getFilterResonance()
     - Get the filter resonance of the sfxr object

  void sfxr.setFilterResonance(double v)
     - Set the filter resonance of the sfxr object
       Value must be between 0 and 1

  double sfxr.getHighPassFilterCutoff()
     - Get the high pass filter cutoff of the sfxr object

  void sfxr.setHighPassFilterCutoff(double v)
     - Set the high pass filter cutoff of the sfxr object
       Value must be between 0 and 1

  double sfxr.getHighPassFilterCutoffSweep()
     - Get the high pass filter cutoff sweep of the sfxr object

  void sfxr.setHighPassFilterCutoffSweep(double v)
     - Set the high pass filter cutoff sweep of the sfxr object
       Value must be between -1 and 1

  double sfxr.getPhaserOffset()
     - Get the phaser offset of the sfxr object

  void sfxr.setPhaserOffset(double v)
     - Set the phaser offset of the sfxr object
       Value must be between -1 and 1

  double sfxr.getPhaserOffsetSweep()
     - Get the phaser offset sweep of the sfxr object

  void sfxr.setPhaserOffsetSweep(double v)
     - Set the phaser offset sweep of the sfxr object
       Value must be between -1 and 1

  double sfxr.getRepeatSpeed()
     - Get the repeat speed of the sfxr object

  void sfxr.setRepeatSpeed(double v)
     - Set the repeat speed of the sfxr object
       Value must be between 0 and 1

  double sfxr.getArpeggio()
     - Get the arpeggio of the sfxr object

  void sfxr.setArpeggio(double v)
     - Set the arpeggio of the sfxr object
       Value must be between 0 and 1

  double sfxr.getArpeggioSpeed()
     - Get the arpeggio speed of the sfxr object

  void sfxr.setArpeggioSpeed(double v)
     - Set the arpeggio speed of the sfxr object
       Value must be between -1 and 1

  sfxr_object sfxr.clone()
     - creates a copy of the sfxr object

  string sfxr.toJSON()
     - exports the Sfxr to a string, used internally by JSON
       This string can be eval()'ed to recreate the sfxr.
       note the float roundup: For .setBaseFrequency(0.123456789) the functions
       .getBaseFrequency() returns 0.123456789104328156 and toJSON returns 0.123457

FONT
  void font.setColorMask(color_object mask)
     - Sets the color mask for a font
     @see ApplyColorMask

  color_object font.getColorMask()
     - Gets the color mask being used by the font object

  void font.drawText(int x, int y, string text)
     - draws 'text' at x, y with the font

  void font.drawZoomedText(int x, int y, double scale, string text)
     - draws scaled text (1.0 = normal) with (x,y) as the upper left corner

  void font.drawTextBox(int x, int y, int w, int h, int offset, string text)
     - draws a word-wrapped text at (x, y) with the width w and height h. The
       offset is the number of pixels which the number of pixels from y which
       the actual drawing starts at.
     Note: 'text' can have the following special characters within it:
       \n - newline
       \t - tab
       \" - double quote
       \' - single quote
      For example: font_object.drawTextBox(16, 16, 200, 200, 0, "Line One\nLine Two");

  array font.wordWrapString(string string, int width)
     - Splits a string into an array of lines as if it were wrapped using
       font_object.drawTextBox().

  int font.getHeight()
     - returns the height of the font, in pixels

  int font.getStringWidth(string text)
     - returns the width of a given string, in pixels

  int font.getStringHeight(string text, int width)
     - returns the height of the string as if it was drawn by drawTextBox

  font_object font.clone()
     - returns a copy of the font object

  boolean font.save(string filename)

  image_object font.getCharacterImage(int index)

  void font.setCharacterImage(int index, image_object image)

WINDOWSTYLE
  void windowstyle.drawWindow(int x, int y, int w, int h)
     - draws the window at (x, y) with the width and height of w and h.
       Note that window corners and edges are drawn outside of the width
       and height of the window.

  void windowstyle.setColorMask(color_object color)
     - sets the color mask for a windowstyle
     @see ApplyColorMask

  color_object windowstyle.getColorMask()
     - gets the color mask being used by the windowstyle object

  boolean windowstyle.save(string filename)
     - [DISABLED] save the windowstyle object (this just returns false...)

  windowstyle windowstyle.clone()
     - [DISABLED] clone the windowstyle object

  int windowstyle.getBorder(int index)
     - get the border size in pixels for the windowstyle object.
       You can use EDGE_LEFT, EDGE_TOP, EDGE_RIGHT and EDGE_BOTTOM as parameters.
       Note that the corner sizes are ignored.

IMAGE
image.width
image.height
  void image.blit(int x, int y [, int int blendmode])
     - draws the image onto the video buffer at x,y

  void image.blitMask(int x, int y, color_object col [, int blendmode, int mask_blendmode])
     - draws the image into the video buffer, except that the color passed
       as 'mask' tints the image

  void image.rotateBlit(int x, int y, double radians [, int blendmode])
     - draws the image into the video buffer, except that the image is rotates
       in anti-clockwise in radians, which have a range of 0-2*pi.
       (x,y) is the center of the blit.

  void image.rotateBlitMask(int x, int y, double radians, color_object color [, int blendmode, int mask_blendmode])
     - rotateBlit + mask

  void image.zoomBlit(int x, int y, double factor [, int blendmode])
     - draws the image into the video buffer with zooming, with the scaling
       depending on factor. Normally a factor of 1 will blit a normal looking
       image. Between 0 and 1 will shrink the image. Any values greater than 1
       will stretch the size of the image.

  void image.zoomBlitMask(int x, int y, double factor, color_object color [, int blendmode, int mask_blendmode])
     - zoomBlit + mask

  void image.transformBlit(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4 [, int blendmode])
     - draws the image into the video buffer with "transformation", where
       (x1, y1) is the upper left corner, (x2, y2) the upper right corner,
       (x3, y3) is the lower right corner, and (x4, y4) is the lower left
       corner.

  void image.transformBlitMask(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4, color_object mask [, int blendmode, int mask_blendmode])
     - transformBlit + blitMask

  surface_object image.createSurface()
     - returns a new surface object from the image

  image image.clone()
     - returns a image object, which is a copy of this image object

SURFACE
surface.width
surface.height
  void surface.applyColorFX(int x, int y, int w, int h, colormatrix_object cm)
     - Apply the colormatrix to the pixels contained in x, y, w, h
     @see CreateColorMatrix

  void surface.applyColorFX4(int x, int y, int w, int h, colormatrix_object c1, colormatrix_object c2, colormatrix_object c3, colormatrix_object c4)
     - Apply 4 color matrixes. Each corner has a seperate color matrix.
     @see CreateColorMatrix

  void surface.blit(int x, int y)
     - draws the surface to the video buffer at (x,y)

  void surface.blitSurface(surface_object surface, int x, int y)
     - draws 'surface' onto the surface_object at (x, y)

  void surface.blitMaskSurface(surface_object surface, int x, int y, color_object mask)
     - draws 'surface' onto the surface_object at (x, y), except that the color passed
       as 'mask' tints 'surface'

  void surface.rotateBlitSurface(surface_object surface, int x, int y, double angle)
     - draws 'surface' onto the surface_object at (x, y), except that 'surface' is rotated
       anti-clockwise in radians, with -2*PI <= angle <= 2*PI

  void surface.rotateBlitMaskSurface(surface_object surface, int x, int y, double angle, color_object mask)
     - rotateBlitSurface + blitMaskSurface

  void surface.zoomBlitSurface(surface_object surface, int x, int y, double factor)
     - draws 'surface' onto the surface_object at (x, y) with zooming, with the scaling
       depending on factor. Normally a factor of 1 will draw a normal looking
       'surface' and between 0 and 1 will shrink it. Any values greater than 1
       will stretch it's size.

  void surface.zoomBlitMaskSurface(surface_object surface, int x, int y, double factor, color_object mask)
     - zoomBlitSurface + blitMaskSurface

  void surface.transformBlitSurface(surface_object surface, int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4)
     - draws 'surface' onto the surface_object with "transformation", where
       (x1, y1) is the upper left corner, (x2, y2) the upper right corner,
       (x3, y3) is the lower right corner, and (x4, y4) is the lower left
       corner.

  void surface.transformBlitMaskSurface(surface_object surface, int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4, color_object mask)
     - transformBlitSurface + blitMaskSurface

  void surface.blitImage(image_object image_object, int x, int y)
     - [DISABLED] draws 'image' onto the surface_object at (x, y)

  image_object surface.createImage()
     - returns an image object from the surface object

  void surface.setBlendMode(int mode)
     - pass it one of the following constants:
      - BLEND: DestColor = (DestColor * (255 - SrcAlpha) / 255) + ((SrcColor * SrcAlpha) / 255)
      - ADD: DestColor = DestColor + ((SrcColor * SrcAlpha) / 255)
      - SUBTRACT: DestColor = DestColor - ((SrcColor * SrcAlpha) / 255)
      - MULTIPLY: DestColor = DestColor * ((SrcColor * SrcAlpha) / 255) / 255
      - AVERAGE: DestColor = DestColor + ((SrcColor * SrcAlpha) / 255) / 2
      - INVERT: DestColor = DestColor * (255 - ((SrcColor * SrcAlpha) / 255)) / 255
      - REPLACE: DestColor = SrcColor
      - RGB_ONLY: DestRGB = SrcRGB
      - ALPHA_ONLY: DestAlpha = SrcAlpha

  color_object surface.getPixel(int x, int y)
     - returns the color of the pixel at (x,y)

  void surface.setPixel(int x, int y, color_object c)
     - sets the pixel at (x,y) to 'color'

  void surface.setAlpha(int alpha [, boolean if (argc >= 2) all])
     - sets the alpha of the surface
     Set the second parameter to false to skip transparent pixels

  void surface.replaceColor(color_object oldColor, color_object newColor)
     - replace all pixels of the color oldColor in the surface with newColor

  Object surface.findColor(color_object aColor)
     - Tells us if the color aColor is in the surface.
       Returns an object containing x and y elements.

  void surface.floodFill(int x, int y, color_object aColor)
     - Flood Fills the area with a color

  void surface.pointSeries(array arr, color_object c)
     - draws a series of points onto the surface
     @see PointSeries

  void surface.line(int x1, int y1, int x2, int y2, color_object c)
     - draws a line onto the surface starting from (x1, y1) to (x2, y2) with
       the color

  void surface.gradientLine(int x1, int y1, int x2, int y2, color_object c1, color_object c2)
     - draws a gradient line onto the surface starting from (x1, y1) to (x2, y2)
     @see GradientLine

  void surface.lineSeries(array arr, color_object c [, int type])
     - draws a series of lines onto the surface
     @see LineSeries

  void surface.bezierCurve(color_object c, double step, int x1, int y1, int x2, int y2, int x3, int y3 [, int x4, int y4])
     - draws a Bezier Curve onto the surface
     @see BezierCurve

  void surface.outlinedRectangle(int x, int y, int w, int h, color_object c [, int size])
     - draws an outlined rectangle onto the surface
     @see OutlinedRectangle

  void surface.rectangle(int x, int y, int w, int h, color_object c)
     - draws a filled rectangle onto the surface from (x, y) to (x+w, y+h)
       with 'color'

  void surface.triangle(int x1, int y1, int x2, int y2, int x3, int y3, color_object c)
     - draws a filled triangle with the points (x1, y1), (x2, y2), (x3, y3),
       with 'color'

  void surface.gradientRectangle(int x, int y, int w, int h, color_object c1, color_object c2, color_object c3, color_object c4)
     - draws a filled gradient rectangle onto the surface from (x, y) to (x+w, y+h)
     @see GradientRectangle

  void surface.gradientTriangle(int x1, int y1, int x2, int y2, int x3, int y3, color_object c1, color_object c2, color_object c3)
     - draws a filled gradient triangle with the points (x1, y1), (x2, y2), (x3, y3),
     @see GradientTriangle

  void surface.polygon(array arr, color_object c [, int invert])
     - draws a filled polygon onto the surface
     @see Polygon

  void surface.outlinedEllipse(int x, int y, int rx, int ry, color_object c)
     - draws an outlined ellipse onto the surface
     @see OutlinedEllipse

  void surface.filledEllipse(int x, int y, int rx, int ry, color_object c)
     - draws a filled ellipse onto the surface
     @see FilledEllipse

  void surface.outlinedCircle(int x, int y, int r, color_object c [, int antialias])
     - draws an outlined circle onto the surface
     @see OutlinedCircle

  void surface.filledCircle(int x, int y, int r, color_object c [, int antialias])
     - draws a filled circle onto the surface
     @see FilledCircle

  void surface.gradientCircle(int x, int y, int r, color_object c1, color_object c2 [, int antialias])
     - draws a gradient circle onto the surface
     @see GradientCircle

  surface surface.rotate(double radians, boolean autosize)
     - rotates the surface anti-clockwise with the range 0 - 2*pi. The resize
       flag is a boolean to tell the engine to resize the surface if needed
       to accomodate the rotated image.
       this function returns the rotated object with the new .width and .height.

  surface surface.resize(int w, int h)
     - resizes the surface images. This does not stretch or shrink the image
       inside the surface.
       this function returns the resized object with the new .width and .height.

  surface surface.rescale(int w, int h)
     - stretches or shrinks the surface to the new width w and height h
       this function returns the rescaled object with the new .width and .height.

  void surface.flipHorizontally()
     - flips the surface horizontally

  void surface.flipVertically()
     - flips the surface vertically

  surface surface.clone()
     - returns a surface object, which is a copy of this surface object

  surface_object surface.cloneSection(int x, int y, int w, int h)
     - returns a new surface object with the height and width of h and w, with
       part of image at (x,y) from the surface_object with the width w and
       height h.

  void surface.applyLookup(int x, int y, int w, int h, array rlookup, array glookup, array blookup, array alookup)
     The lookup parameters are arrays of 256 elements containg the new pixel values.
     e.g. var invert_lookup = [255, 254, 253, 252, 251, ..., 4, 3, 2, 1, 0];

  void surface.drawText(font_object font_obj, int x, int y, string text)
     - draws 'text' at x, y with the font onto the surface_object

  void surface.drawZoomedText(font_object font_obj, int x, int y, double scale, string text)
     - draws scaled text (1.0 = normal) with (x,y) as the upper left corner
       onto the surface_object

  void surface.drawTextBox(font_object font_obj, int x, int y, int w, int h, int offset, string text)
     - draws a word-wrapped text at (x, y) onto the surface_object with the width w and height h.
       The offset is the number of pixels which the number of pixels from y which
       the actual drawing starts at.
       See font_object.drawTextBox for more detail.

  boolean surface.save(string filename)
     - saves the surface_object as a png image using the filename 'filename'

COLORMATRIX
colormatrix.rn
colormatrix.rr
colormatrix.rg
colormatrix.rb
colormatrix.gn
colormatrix.gr
colormatrix.gg
colormatrix.gb
colormatrix.bn
colormatrix.br
colormatrix.bg
colormatrix.bb
  string colormatrix.toJSON()
     - exports the ColorMatrix to a string, used internally by JSON
       This string can be eval()'ed to recreate the colormatrix

ANIMATION
animation.width
animation.height
animation.done
  int animation.getNumFrames()
     - returns the number of frames the animation contains.

  int animation.getTicks()
     - returns the amount of ticks

  int animation.getPlaytime()
     - returns the total playtime, if defined.
       (FLC's dont have this property, MNG's do)

  int animation.getDelay()
     - returns the delay between frames, in milliseconds

  void animation.readNextFrame()
     - readies the next frame for drawing

  void animation.drawFrame(int x, int y)
     - draws the current frame into the video buffer

  void animation.drawZoomedFrame(int x, int y, double factor)
     - draws the current frame into the video buffer with a specified
       zoom scale

FILE
  void file.write(string key, any_type default_value)
     - writes a value (string, number, boolean) to the file under the key name

  any_type file.read(string key, any_type default_value)
     - reads a value from the key
       the value type returned depends on the default value.
       + if the default is a number, read will return a number.
       + if the default is a text or string, read will return a string.
       + if the default is a boolean, read will return a boolean
       + if the key is not present in the file, it will return the default value.

  int file.getNumKeys()
     - returns the number of keys in the file

  string file.getKey(int index)
     - returns a string of the key at 'index'

  void file.flush()
     - writes the file to disk immediately... this way you don't have
       to wait for it to save when the file object is garbage collected

  void file.close()
     - closes the file object, after this, the file_object cannot be used anymore.

RAWFILE
  void rawfile.setPosition(int position)
     - sets the position that the file will be read from

  int rawfile.getPosition()
     - returns the current position which the data is read from

  int rawfile.getSize()
     - returns the number of bytes in the file

  array rawfile.read(int size)
     - reads the number of bytes that is specified by num_bytes. It will create
       and return an array of data the rawfile object has read. The array of
       data are numbers representation of each byte (0-255). Note that if the
       number of bytes that will be read, exceeds the filesize from the current
       position, it will only return an array of data of that is
       actually read. The returned object is a ByteArray, so you can do
       the same things with it as you can with any other ByteArray.

  void rawfile.write(byte_array_object data)
     - writes the byte array to the file at the current position
       The file must have been opened as writeable for this to work.

  void rawfile.close()
     - closes the rawfile object, after this, the rawfile_object cannot be used anymore.

BYTEARRAY
bytearray[index]
bytearray.length
  byte_array_object bytearray.concat(byte_array_object byte_array_to_append)
     - returns bytearray with bytearray_to_append attached to the end of it

  byte_array_object bytearray.slice(int start_slice [, int end_slice])
     - returns a slice of the bytearray starting at start, and ending at end
       or the end of the bytearray if end is omitted.
       If end is a negative number, the end point is started from the end of the bytearray.

MAPENGINE
  void mapengine.save(string filename)
     -

  void mapengine.layerAppend(int layer_width, int layer_height, int tile_index)
     - Adds a new layer filled with tile index
       The mapengine must be running.

TILESET
  void tileset.appendTiles(int num_tiles)
     - [INTERNAL] appends num_tiles tiles to the tileset

  void tileset.save(string filename)
     - [INTERNAL] saves the tileset from the current map to ./maps/<filename>