Lutro - Documentation

love

When beginning to write games using Lutro, the most important parts of the API are the callbacks: love.load to do one-time setup of your game, love.update which is used to manage your game's state frame-to-frame, and love.draw which is used to render the game state onto the screen.

More interactive games will override additional callbacks in order to handle input from the user, and other aspects of a full-featured game.

Lutro provides default placeholders for these callbacks, which you can override inside your own code by creating your own function with the same name as the callback.

love.load

love.load is called once in the lifetime of the application, at the very beginning. Use this to load assets and initialize your game.

Example:
function love.load()
  whale = love.graphics.newImage("whale.png")
  x = 0
end

love.update

love.update is called once per frame, 60 times per second. Use this to execute your game logic.

Arguments:
dt
The time elapsed since last frame. By default 1.0/60.0
Example:
function love.update(dt)
  x = x + 1
end

love.draw

love.draw is also called once per frame, 60 times per second. Use this to draw your game graphics.

Example:
function love.draw()
  love.graphics.draw(whale, x, 32)
end

love.gamepadpressed

love.gamepadpressed is called when a player pressed one of the joypad buttons.

Example:
function love.gamepadpressed(i, k)
  print("player pressed", i, k)
end

love.gamepadreleased

Same as love.gamepadpressed but called when a button is released.

love.serialize

This is an optional callback. When the libretro frontend calls love.serialize, your game can return a serialized game state in the form of a string. Think of this as savestates in an emulator.

Example:
function love.serialize(size)
  local gamestate = {}
  gamestate.x = x
  return json:encode(gamestate)
end

love.unserialize

This is an optional callback. When the libretro frontend calls love.unserialize, your game will receive a game state serialized as a string. Think of this as savestates in an emulator. It's up to the game developer how to implement proper unserialization.

Example:
function love.unserialize(data, size)
  if data == nil then return end
  local gamestate = json:decode(data)
  x = gamestate.x
end

love.serializeSize

This is called when the libretro frontend wants to know the size of your game savestate. Choosing a large and constant value is fine.

Example:
function love.serializeSize()
  return 1024*8
end

love.reset

This is called when the libretro frontend wants to reset the game. In this callback, you can free resources and reinitialize your game to start over.

Example:
function love.reset()
  gamestate = {}
  love.load()
end