Created
August 23, 2014 11:56
-
-
Save pajlada/438fdde9f4c742f9af06 to your computer and use it in GitHub Desktop.
Principia LuaScript on_input
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function on_input(type, data) | |
end | |
Type can be: | |
INPUT_KEY_DOWN | |
INPUT_KEY_UP | |
INPUT_POINTER_DOWN | |
INPUT_POINTER_UP | |
Data is a table, containing data depending on the input type. | |
For types INPUT_POINTER_DOWN and INPUT_POINTER_UP, these are the data members: | |
data.pid = The pointer ID of the press | |
data.x = The X coordinate where the pointer event occured. | |
data.y = The Y coordinate where the pointer event occured. | |
The X/Y coordinates are relative to the player screen. | |
x, y = world:get_world_point(data.x, data.y) can be used to convert screen-coordinates to world-coordinates. | |
For types INPUT_KEY_DOWN and INPUT_KEY_UP, this is the data structure: | |
data.keycode = Current key pressed | |
These are the valid values for data.keycode: | |
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_1 | |
KEY_2 | |
KEY_3 | |
KEY_4 | |
KEY_5 | |
KEY_6 | |
KEY_7 | |
KEY_8 | |
KEY_9 | |
KEY_0 | |
KEY_ENTER | |
KEY_ESC | |
KEY_BACKSPACE | |
KEY_TAB | |
KEY_SPACE | |
KEY_RIGHT | |
KEY_LEFT | |
KEY_DOWN | |
KEY_UP |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment