Meteor Scripting Functions
Input
vector2 mousePos()
Get the mouse screen position in pixels

Example
print("Mouse is at " + mousePos());

See also
mouseWithin

bool mouseWithin(float x1, float xy, float x2, float x2)
Determine if a mouse button is within a rectangle.

Example
if(mouseWithin(0, 0, SCREEN_W -1, SCREEN_H * 0.5))
    print("Mouse is in top half of screen");

See also
mousePos

bool mouseButtonDown(int buttonIndex)
Determine if a mouse button is held down.

Example
if(mouseButtonDown(1))
    print("Left mouse button is down");

Comments
buttonIndex can be either: 1 (LEFT), 2 (RIGHT), 3 (MIDDLE)

See also
mouseButtonClicked

bool mouseButtonClicked(int buttonIndex)
Determine if a mouse button was clicked (pressed and released).

Example
if(mouseButtonClicked(1))
    print("Left mouse button is clicked");

Comments
buttonIndex can be either: 1 (LEFT), 2 (RIGHT), 3 (MIDDLE)

See also
mouseButtonDown

bool keyDown(int key)
Determine if a keyboard key is being held down.

Example
void onUpdate(float deltaTime)
{
    if(gameHasFocus())
    {
        if(keyDown(KEY_Z))
            print("Z key is down");
    }
}

Comments
Keys values List:
KEY_NONE

KEY_A to KEY_Z
KEY_0 to KEY_9
KEY_PAD_0 to KEY_PAD_9
KEY_F1 to KEY_F12

KEY_ESCAPE or KEY_ESC
KEY_TILDE
KEY_PLUS
KEY_MINUS
KEY_EQUALS
KEY_BACKSPACE
KEY_TAB
KEY_ENTER
KEY_SEMICOLON
KEY_QUOTE
KEY_BACKSLASH
KEY_BACKSLASH2
KEY_COMMA
KEY_FULLSTOP or KEY_PERIOD
KEY_SLASH
KEY_SPACE

KEY_INSERT
KEY_DELETE
KEY_HOME
KEY_END
KEY_PGUP
KEY_PGDN
KEY_LEFT
KEY_RIGHT
KEY_UP
KEY_DOWN

KEY_PAD_MINUS
KEY_PAD_PLUS
KEY_PAD_DELETE
KEY_PAD_ENTER

KEY_PAUSE

KEY_LSHIFT
KEY_RSHIFT
KEY_LCTRL
KEY_RCTRL
KEY_ALT
KEY_ALTGR
KEY_MENU

See also
keyPressed clearPressedKeys waitForKeyRelease

bool keyPressed(int key)
Determine if a keyboard key was pressed.

Example
void onUpdate(float deltaTime)
{
    if(gameHasFocus())
    {
        if(keyPressed(KEY_Z))
            print("Z key was pressed");
    }
}

See also
keyDown clearPressedKeys waitForKeyRelease

void clearPressedKeys()
Clears the pressed keys buffer.

Example
clearPressedKeys();

See also
keyDown keyPressed waitForKeyRelease

void waitForKeyRelease(int key)
Waits a short time for key to be released.

Example
waitForKeyRelease(KEY_Z);

Comments
The delay is minimal so the game is not held up.
Do not call every frame.

See also
keyDown keyPressed clearPressedKeys


Index