LifeLua 21-08-2025
Documentation for LifeLua, a Lua interpreter for the PS Vita
Loading...
Searching...
No Matches
LifeLua Documentation

LifeLua is a Lua interpreter for the PS Vita, based on LuaJIT 2.1. You write your app in Lua and LifeLua runs it, with libraries for drawing, images, sound, controls, files, networking, system dialogs and more.

Getting started

  1. Install the LifeLua VPK on your PS Vita.
  2. Write your app in a file called main.lua.
  3. Put main.lua in LifeLua's app folder, ux0:app/LIFELUAJT/ (that's app0: from inside the app), together with any images, sounds or fonts it uses.
  4. Start LifeLua from the LiveArea. It runs main.lua.

If main.lua is missing or has an error, LifeLua shows the error message on screen with three options: press Cross to run main.lua again, Square to start an FTP server (so you can upload a fixed main.lua from a computer without leaving the app) or Circle to close LifeLua. This makes it quick to fix mistakes and try again.

Your first app

A LifeLua app is usually one loop that runs once per frame: read the controls, draw everything, then show the frame.

local white = color.new(255, 255, 255)
local x, y = 480, 272
while true do
controls.update() -- read the buttons
if controls.check(SCE_CTRL_UP) then y = y - 4 end
if controls.check(SCE_CTRL_DOWN) then y = y + 4 end
if controls.check(SCE_CTRL_LEFT) then x = x - 4 end
if controls.check(SCE_CTRL_RIGHT) then x = x + 4 end
if controls.pressed(SCE_CTRL_START) then os.exit() end
draw.text(10, 10, "Move the circle with the D-pad, press Start to exit", white)
draw.circle(x, y, 20, white)
draw.swapbuffers() -- show the frame
end
SceCtrlButtons SCE_CTRL_UP
D-pad up.
Definition lj_controls.h:29
SceCtrlButtons SCE_CTRL_START
Start button.
Definition lj_controls.h:47
SceCtrlButtons SCE_CTRL_RIGHT
D-pad right.
Definition lj_controls.h:32
SceCtrlButtons SCE_CTRL_LEFT
D-pad left.
Definition lj_controls.h:31
SceCtrlButtons SCE_CTRL_DOWN
D-pad down.
Definition lj_controls.h:30

More examples are in the Examples tab, and the sample folder of the source code has a full showcase app.

How to read this documentation

The libraries are listed in the Libraries tab. Every function is shown like this:

nil image.display(image image, number x, number y, color tint)
  • The first word is what the function returns. nil means it returns nothing, any means the type can vary.
  • The words before each parameter name are the Lua types it expects: number, string, boolean, table, function, or one of LifeLua's own types like image or color.
  • Parameters marked (optional) can be left out, starting from the end. Their default value is written next to them.
  • Names in CAPITALS (like SCE_CTRL_CROSS) are constants: global variables holding numbers, ready to use.
  • Functions whose first parameter is an object (an image, a color, an audio, ...) can also be called as methods, so image.display(img, 0, 0) can be written as img:display(0, 0).

Libraries

Library What it's for
draw Drawing text and shapes, showing each frame
color Creating and mixing colors
image Loading, drawing, editing and saving images, QR codes
font Loading fonts for text
controls Buttons, analog sticks, touch screens, motion sensors
audio Music and sounds
video Playing videos
camera The front and back cameras
imgui Windows, menus, buttons and other UI widgets
timer Measuring time
os System dialogs (keyboard, messages), apps, battery, power, system info
io Files, folders (copying, deleting), archives, hashes
network Wi-Fi, downloads, FTP server
json / toml Reading and writing JSON, reading TOML
sqlite3 SQLite databases
thread Running code at the same time as your main loop
string / table / math Extra functions added to Lua's standard libraries

All of the standard Lua 5.1 libraries are available too (string, table, math, io, os, ...), plus LuaJIT's bit, ffi and jit libraries. They are documented in the Lua 5.1 manual and on the LuaJIT website. The luautf8 library by starwing is also included, as utf8, for working with UTF-8 text.

LifeLua's types

Besides Lua's own types, LifeLua functions use these objects:

Type Made with Represents
color color.new(), tocolor() A color with red, green, blue and alpha
image image.load(), image.new(), image.screen(), image.qr() An image that can be drawn on the screen
font font.load() A font for draw.text()
audio audio.load() A sound or a song
timer timer.new() A stopwatch
thread thread.new() A function running at the same time as the main code
sqlite3 sqlite3.open() An open database
jsonnull json.null JSON's null value

They are freed automatically when they're no longer used, like any other Lua value.

Callbacks

Some functions wait until they're done (like a download or a system dialog), so your main loop doesn't run in the meantime. To show progress or keep drawing during that time, define a global function with one of these names. LifeLua calls it for you:

Function name Called during Parameters
LifeLuaNetworkDownload network.download(), network.get() downloaded bytes, written bytes, total size, piece size, written piece size
LifeLuaArchiveExtracting io.extract() file name, file number, file size
LifeLuaDeleting io.delete() path, is a folder, number
LifeLuaCopying io.copy() source path, destination path, copied bytes, file size, number
LifeLuaIMEDialog, LifeLuaMessageDialog, ... The os dialogs none (see the list in os)

Tips

  • print() writes to the debug console, which isn't visible on the PS Vita's screen. Use draw.text() to show values while testing.
  • Load images, sounds and fonts once, before your main loop, not inside it: loading every frame is slow and wastes memory.
  • Save your app's files in its own folder in ux0:data/ (e.g. ux0:data/myapp/), and create it with io.newfolder() first.
  • Lua lists start at index 1, and LifeLua's lists (touch points, folder contents, combo box items, ...) do too.

Compiling LifeLua

To get the newest features before a release, you can compile LifeLua yourself. See the README for the steps.

About this documentation

This documentation was largely rewritten with the help of AI (Claude by Anthropic), checked against LifeLua's source code. If you find something that doesn't match how LifeLua behaves, please open an issue.

License

LifeLua is licensed under the GPLv3 license.


Source code: https://github.com/HarommelRabbid/LifeLua