Loving Cube Engine API documentation

Introduction and table of contents - The init file - The Main object - Importing new textures - Importing 3D meshes - New data types - List of instantiable objects - List of static objects


The Main object

To setup the game, you must create a lua table named "Main" with the following methods:

Called whenever the mouse is moved on the screen. (x,y) are the pixel coordinates of the mouse and is_mouse_pressed is true if the mouse was pressed while moving.
MethodDescription
init()Called when the application starts. Use it for example to load misc sprites and models.
manage()Called regularly. Use it for example to manage game elements.
draw2D()Called regularly. Use it for example to draw specific 2d sprites.
draw3D()Called regularly. Use it for example to draw specific 3d models.
onKeyPressed(int key)Called whenever the user pressed a keyboard key. key parameter may be:
  • the character of the key from A to Z, for example "a". Beware that this may be "a" or "A" depending whether caps lock is enabled or not.
  • the string "FX", X being the function key between 1 and 12, for example getKey("F5") for F5 key
  • "RIGHT", "LEFT", "UP", "DOWN" being each of the arrow keys
  • For each other key, the string "ASCII:X", X being the numerical decimal ascii code, for example getKey("ASCII:9") for tabulation
onMousePressed(string mouse_button, Int2 pos)Called whenever the user started clicking with the mouse.
  • mouse_button is either "LEFT_BUTTON", "MIDDLE_BUTTON", "RIGHT_BUTTON", "LEFT_BUTTON_PLUS_WHEEL_UP", "LEFT_BUTTON_PLUS_WHEEL_UP" (or an empty string for any other button if such button exists).
  • (x,y) are the pixel coordinates of the mouse at the moment of the click was made.
onMouseReleased(string mouse_button, Int2 pos)Called whenever the user finished clicking with the mouse.
  • mouse_button is either "LEFT_BUTTON", "MIDDLE_BUTTON", "RIGHT_BUTTON", "LEFT_BUTTON_PLUS_WHEEL_UP", "LEFT_BUTTON_PLUS_WHEEL_UP" (or an empty string for any other button if such button exists).
  • (x,y) are the pixel coordinates of the mouse at the moment the click was released.
onMouseMoved(bool is_mouse_pressed, Int2 pos)
onMouseWheelChanged(int wheel_delta, Int2 pos)Called whenever the user scrolled with the mouse wheel. wheel_delta is the wheel delta, most of the time 120, or a multiple of 120. (x,y) are the pixel coordinates of the mouse at the moment the wheel was moved.
onSemanticZoom(number value)Called on a tablet when the user used two fingers to zoom/unzoom. value is the zoom intensity. (Only available if this is a Windows Store app)
uninit()Called when application stops. Use it for example to unload misc sprites and models.