|
LifeLua 21-08-2025
Documentation for LifeLua, a Lua interpreter for the PS Vita
|
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.
main.lua.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.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.
A LifeLua app is usually one loop that runs once per frame: read the controls, draw everything, then show the frame.
More examples are in the Examples tab, and the sample folder of the source code has a full showcase app.
The libraries are listed in the Libraries tab. Every function is shown like this:
nil means it returns nothing, any means the type can vary.number, string, boolean, table, function, or one of LifeLua's own types like image or color.SCE_CTRL_CROSS) are constants: global variables holding numbers, ready to use.image.display(img, 0, 0) can be written as img:display(0, 0).| 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.
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.
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) |
print() writes to the debug console, which isn't visible on the PS Vita's screen. Use draw.text() to show values while testing.ux0:data/ (e.g. ux0:data/myapp/), and create it with io.newfolder() first.To get the newest features before a release, you can compile LifeLua yourself. See the README for the steps.
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.
LifeLua is licensed under the GPLv3 license.
Source code: https://github.com/HarommelRabbid/LifeLua