game.lua - Protovision/io-lua GitHub Wiki
Your game is required to have a file called game.lua. By defining any of the following callback functions, your game will be notified of certain events.
Initialization callback
function init()
end
If you define this function, the game engine will call it exactly once when the game starts.
Update callback
function update()
end
If you define this function, the game engine will call it at every game frame.
Keyboard callback
function keyboard(key, status)
end
If you define this function, the game engine will call it every time the user presses or releases a key. key will be the key code constant (e.g. KEY_A, KEY_B, KEY_C; see base/scripts/constants.lua for more). All ascii keys will match their ascii values, so you may use string.char on them to convert them to strings. The value of status will be either PRESSED or RELEASED.
Mousebutton callback
function mousebutton(x, y, button, status)
end
If you define this function, the game engine will call it every time the user clicks or releases a mouse button. x and y will be the coordinates if where the cursor was, button will be (BUTTON_LEFT, BUTTON_MID, or BUTTON_RIGHT), status will be PRESSED or RELEASED.
Shutdown callback
function shutdown()
end
If you define this function, the game engine will call it before the game exits.