lpp-vita temp documentation
Note: This is a temporary documentation for lpp-vita. In future, we will make a Doxygen-style documentation. Use the Search function (CTRL + F) to find function/module you want to see.

Standard LUA Library
math Library - Arithmetical functions.

Official documentation: Read Now


Environment Variables
SCE_CTRL_CROSS - Key CROSS value in u32 format for Controls functions.
SCE_CTRL_SQUARE - Key SQUARE value in u32 format for Controls functions.
SCE_CTRL_CIRCLE - Key CIRCLE value in u32 format for Controls functions.
SCE_CTRL_TRIANGLE - Key TRIANGLE value in u32 format for Controls functions.
SCE_CTRL_START - Key START value in u32 format for Controls functions.
SCE_CTRL_SELECT - Key SELECT value in u32 format for Controls functions.
SCE_CTRL_RTRIGGER - Key RIGHT TRIGGER value in u32 format for Controls functions.
SCE_CTRL_LTRIGGER - Key LEFT TRIGGER value in u32 format for Controls functions.
SCE_CTRL_UP - Key UP value in u32 format for Controls functions.
SCE_CTRL_DOWN - Key DOWN value in u32 format for Controls functions.
SCE_CTRL_LEFT - Key LEFT value in u32 format for Controls functions.
SCE_CTRL_RIGHT - Key RIGHT value in u32 format for Controls functions.
SET - Seek SET value in u32 format for I/O functions.
CUR - Seek CUR (Current) value in u32 format for I/O functions.
END - Seek END value in u32 format for I/O functions.
FREAD - Attribute for I/O functions for opening a file with Read attribute.
FWRITE - Attribute for I/O functions for opening a file with Write attribute.
FCREATE - Attribute for I/O functions for opening a file with Create/Write attributes.
FRDWR - Attribute for I/O functions for opening a file with Read/Write attributes.
LOOP - Attribute for Audio functions for looping feature.
NO_LOOP - Attribute for Audio functions for non-looping feature.
RUNNING - Attribute for Keyboard state when running.
FINISHED - Attribute for Keyboard state when correctly finished.
CANCELED - Attribute for Keyboard state when aborted.
MODE_TEXT - Attribute for normal text Keyboard mode.
MODE_PASSWORD - Attribute for password Keyboard mode.
TYPE_DEFAULT - Attribute for default Keyboard type.
TYPE_LATIN - Attribute for Latin encoding Keyboard type.
TYPE_NUMBER - Attribute for numeric Keyboard type.
TYPE_EXT_NUMBER - Attribute for extended numeric Keyboard type.
FIRST_CTRL - Attribute for first controller usage.
SECOND_CTRL - Attribute for second controller usage.


I/O Module
s64 io.open(string file,int attribute) - Open a file.

Sample usage: fileStream = io.open("cache0:/file.txt",FCREATE)
string io.read(s64 filestream,u64 size) - Read from an opened file.

Sample usage: text = io.read(fileStream,10)
void io.write(s64 filestream,string text,u64 size) - Write a text in an opened file.

Sample usage: io.write(fileStream,"Text written with LPP", 21)
u64 io.size(s64 filestream) - Get size of an opened file.

Sample usage: size = io.size(fileStream)
u64 io.seek(s64 filestream,u32 pos,u8 type) - Move pointer in an opened file.

Sample usage: size = io.seek(fileStream, 0, END) -- Move to the end of the file
void io.close(s64 filestream, [bool extdata_file]) - Close an opened file.

Sample usage: io.close(fileStream)


System Module
void System.exit(void) - Exit homebrew and returns to Main Menu.

Sample usage: System.exit()
void System.deleteFile(string path) - Delete a file.

Sample usage: System.deleteFile("cache0:/file.txt")
void System.deleteDirectory(string path) - Delete a directory.

Sample usage: System.deleteDirectory("cache0:/dir")
void System.rename(string path,string path2) - Move or rename a file/directory.

Sample usage: System.rename("cache0:/file.txt","cache0:/file.sh")
void System.createDirectory(string path) - Create a directory.

Sample usage: System.createDirectory("cache0:/test_dir")
table System.listDirectory(string path) - List a directory.

Sample usage: list_dir = System.listDirectory("cache0:/test_dir/")
bool System.doesFileExist(string path) - Check if a file exists.

Sample usage: System.doesFileExist("cache0:/test.txt")
void System.wait(int microseconds) - Wait for an amount of microseconds.

Sample usage: System.wait(800000)
bool System.isBatteryCharging() - Check if battery is currently under charge.

Sample usage: if System.isBatteryCharging() then ... end
int System.getBatteryPercentage() - Returns battery lifetime percentage.

Sample usage: percentage = System.getBatteryPercentage()
int System.getBatteryLifetime() - Returns battery lifetime in seconds.

Sample usage: lifetime = System.getBatteryLifetime()
void System.powerTick() - Prevents PSVITA to go in standby mode.

Sample usage: System.powerTick()
int System.getCpuSpeed() - Gets current CPU clock rate.

Sample usage: freq = System.getCpuSpeed()
void System.setCpuSpeed(int freq) - Sets current CPU clock rate.

Sample usage: System.setCpuSpeed(444)
void System.launchEboot(string filename) - Launch an homebrew in BIN format.

Sample usage: System.launchEboot("app0:/eboot_lpp.bin)
void System.extractFromZIP(string zip_file,string file,string path_to_extract,[string password]) - Extract a file from a ZIP file.

Sample usage: System.extractFromZIP("ux0:/file.zip","image.jpg","ux0:/file")
void System.extractZIP(string file,string path_to_extract,[string password]) - Extract a ZIP file.

Sample usage: System.extractZIP("ux0:/file.zip","ux0:/file")
int,int,int System.getTime(void) - Get console time.

Sample usage: h,m,s = System.getTime()
int,int,int,int System.getDate(void) - Get console date.

Sample usage: day_value,day,month,year = System.getDate() [day_value: 5 = Friday, 6 = Saturday...]
int System.getLanguage(void) - Get PSVITA system language.

Sample usage: language = System.getLanguage()
string System.getUsername(void) - Returns PSN user username.

Sample usage: user = System.getUsername()
string System.extractSFO(string filename) - Extracts info from an SFO file descriptor.

Sample usage: data = System.extractSFO("app0:/sce_sys/param.sfo") [data.title, data.titleid, data.category, data.version]


Color Module
u32 Color.new(int r, int g, int b,[int a]) - Create a new RGB or RGBA color.

Sample usage: red = Color.new(255,0,0)
int Color.getR(u32 color) - Get R value of a color.

Sample usage: red_value = Color.getR(Color.new(255,0,0))
int Color.getG(u32 color) - Get G value of a color.

Sample usage: green_value = Color.getG(Color.new(255,0,0))
int Color.getB(u32 color) - Get B value of a color.

Sample usage: blue_value = Color.getB(Color.new(255,0,0))
int Color.getA(u32 color) - Get A value of a color.

Sample usage: alpha_value = Color.getA(Color.new(255,0,0))


Screen Module
void Screen.clear() - Clear screen.

Sample usage: Screen.clear()
void Screen.flip(void) - Flip screen.

Sample usage: Screen.flip()
u32 Screen.getPixel(int x, int y) - Get the color of a pixel.

Sample usage: clr = Screen.getPixel(5, 5)
void Screen.waitVblankStart(void) - Wait screen refresh.

Sample usage: Screen.waitVblankStart()


Graphics Module
void Graphics.initBlend(void) - Init drawing phase.

Sample usage: Graphics.initBlend()
void Graphics.termBlend(void) - Term drawing phase.

Sample usage: Graphics.termBlend()
void Graphics.debugPrint(float x, float y, string text, u32 color, [float scale]) - Write a string on screen.

Sample usage: Graphics.debugPrint(0, 0, "Hello World", Color.new(255,255,255))
void Graphics.fillRect(float x1, float x2, float y1, float y2, u32 color) - Draw a rectangle.

Sample usage: Graphics.fillRect(5, 20, 5, 40, Color.new(255,0,0))
void Graphics.fillEmptyRect(float x1, float x2, float y1, float y2, u32 color) - Draw an empty rectangle.

Sample usage: Graphics.fillEmptyRect(5, 20, 5, 40, Color.new(255,0,0))
void Graphics.drawLine(float x1, float x2, float y1, float y2, u32 color) - Draw a line.

Sample usage: Graphics.drawLine(5, 20, 5, 40, Color.new(255,0,0))
void Graphics.drawPixel(float x, float y, u32 color) - Draw a pixel.

Sample usage: Graphics.drawPixel(5, 5, Color.new(255,0,0))
void Graphics.fillCircle(float x, float y, float radius, u32 color) - Draw a circle.

Sample usage: Graphics.fillCircle(5, 5, 1, Color.new(255,0,0))
u32 Graphics.loadImage(string file) - Load a JPG/PNG/BMP image.

Sample usage: image = Graphics.loadImage("cache0:/image.jpg")
void Graphics.drawImage(float x, float y, u32 image, [u32 color]) - Draw a loaded image.

Sample usage: Graphics.drawImage(10, 10, image)
void Graphics.drawPartialImage(float x, float y, int img_x, int img_y, int width, int height, u32 image, [u32 color]) - Draw a part of a loaded image.

Sample usage: Graphics.drawPartialImage(10, 10, 5, 5, 50, 50, image)
void Graphics.drawRotateImage(float x, float y, u32 image, float radius, [u32 color]) - Draw a rotated image.

Sample usage: Graphics.drawRotateImage(10, 10, 2.5, image)
void Graphics.drawScaleImage(float x, float y, u32 image, float x_scale, float y_scale, [u32 color]) - Draw a scaled image.

Sample usage: Graphics.drawScaleImage(10, 10, 2.5, 2.5, image)
void Graphics.drawImageExtended(float x, float y, int img_x, int_img_y, int width, int height, float radius, float x_scale, float y_scale, u32 image, [u32 color]) - Draw a partial scaled image.

Sample usage: Graphics.drawImageExtended(10, 10, 10, 10, 100, 200, 1.0, 2.5, 2.5, image)
u32 Graphics.createImage(int width, int height) - Create an empty image.

Sample usage:img = Graphics.createImage(10, 10)
u32 Graphics.getImageWidth(u32 image) - Get width of a loaded image.

Sample usage:width = Graphics.getImageWidth(image)
u32 Graphics.getImageHeight(u32 image) - Get height of a loaded image.

Sample usage:height = Graphics.getImageHeight(image)
void Graphics.freeImage(u32 image) - Free an image.

Sample usage: Graphics.freeImage(image)


Font Module
u32 Font.load(string filename) - Load a TTF font.

Sample usage: my_font = Font.load("/font.ttf")
void Font.setPixelSizes(u32 font,u32 size) - Set size for a font.

Sample usage: Font.setPixelSizes(my_font,18)
void Font.print(u32 font, int x, int y, string text, u32 color) - Print a text with a font.

Sample usage: Font.print(my_font, 5, 5, "Hello World!", Color.new(255,255,255))
void Font.unload(u32 font) - Free a font.

Sample usage: Font.unload(my_font)


Controls Module
u32 Controls.read([u8 ctrlr_id]) - Read controls input.

Sample usage: pad = Controls.read()
bool Controls.check(u32 controls,u32 button, [u8 ctrlr_id]) - Check if a button is pressed.

Sample usage: if (Controls.check(Controls.read(),KEY_A)) then ... end
int,int Controls.readLeftAnalog([u8 ctrlr_id]) - Get X,Y position of Left Analog.

Sample usage: x,y = Controls.readLeftAnalog()
int,int Controls.readRightAnalog([u8 ctrlr_id]) - Get X,Y position of Right Analog.

Sample usage: x,y = Controls.readRightAnalog()
int, int, ... Controls.readTouch(void) - Get X,Y position of touchscreen pixel.

Sample usage: x1,y1,x2,y2 = Controls.readTouch()
int, int, ... Controls.readRetroTouch(void) - Get X,Y position of retrotouch pixel.

Sample usage: x1,y1,x2,y2 = Controls.readRetroTouch()
void Controls.rumble(u8 ctrlr_id, u16 intensity) - Enable rumble effect of selected controller (PSTV only).

Sample usage: Controls.rumble(FIRST_CTRL, 50)
void Controls.setLightbar(u8 ctrlr_id, u32 color) - Set lightbar color for selected Dualshock 4 controller (PSTV only).

Sample usage: Controls.setLightbar(FIRST_CTRL, Color.new(255,255,255))


Sound Module
void Sound.init(void) - Initialize sound system.

Sample usage: Sound.init()
void Sound.term(void) - Terminate sound system.

Sample usage: Sound.term()
snd_id Sound.openMidi(string filename) - Open a MIDI/MID file.

Sample usage: snd = Sound.openMidi("app0:/file.mid")
snd_id Sound.openWav(string filename) - Open a WAV file.

Sample usage: snd = Sound.openWav("app0:/file.wav")
snd_id Sound.openMp3(string filename) - Open an MP3 file.

Sample usage: snd = Sound.openMp3("app0:/file.mp3")
snd_id Sound.openOgg(string filename) - Open an OGG file.

Sample usage: snd = Sound.openOgg("app0:/file.ogg")
bool Sound.isPlaying(snd_id wav_file) - Get sound playing state.

Sample usage: if Sound.isPlaying(wav) then ... end
void Sound.play(snd_id wav_file, int loop) - Play a loaded sound.

Sample usage: Sound.play(wav,NO_LOOP)
void Sound.close(snd_id wav_file) - Close and free a loaded sound.

Sample usage: Sound.close(wav)
void Sound.pause(snd_id wav_file) - Pause a sound.

Sample usage: Sound.pause(wav)
void Sound.resume(snd_id wav_file) - Resume a sound.

Sample usage: Sound.resume(wav)


Network Module
string ip, u32 port Network.initFTP() - Start FTP server.

Sample usage: ip, port = Network.initFTP()
void Network.termFTP() - Close FTP server.

Sample usage: Network.termFTP()
bool Network.isWifiEnabled() - Checks if WiFi is enabled.

Sample usage: if Network.isWifiEnabled() then ... end
int Network.getWifiLevel() - Returns Wifi strength level.

Sample usage: lvl = Network.getWifiLevel()
string Network.getMacAddress() - Returns console MAC address.

Sample usage: mac = Network.getMacAddress()
string Network.getIPAddress() - Returns console IP address.

Sample usage: ip = Network.getIPAddress()


Socket Module
void Socket.init(void) - Init socketing system.

Sample usage: Socket.init()
void Socket.term(void) - Term socketing system.

Sample usage: Socket.term()
int Socket.createServerSocket(int port) - Create a server socket.

Sample usage: server_id = Socket.createServerSocket(5000)
int Socket.connect(string host, int port) - Create a client socket and connect it to the host.

Sample usage: client_id = Socket.connect("192.168.1.71", 5000)
void Socket.send(int sock_id, string text) - Send a message.

Sample usage: Socket.send(client_id, "Hello Network World!")
string Socket.receive(int sock_id, int size) - Receive a message.

Sample usage: msg = Socket.receive(client_id, 256)
int Socket.accept(int sock_id) - Search for connections (Server sockets).

Sample usage: client_id = Socket.accept(server_id)
void Socket.close(int sock_id) - Close a socket.

Sample usage: Socket.close(client_id)


Timer Module
u32 Timer.new(void) - Create a new timer.

Sample usage: timer = Timer.new()
u32 Timer.getTime(u32 timer) - Returns time in milliseconds of timer object.

Sample usage: time = Timer.getTime(timer)
void Timer.destroy(u32 timer) - Free a timer object.

Sample usage: Timer.destroy(timer)
void Timer.reset(u32 timer) - Reset time of a timer object.

Sample usage: Timer.reset(timer)
void Timer.pause(u32 timer) - Pause a timer object.

Sample usage: Timer.pause(timer)
void Timer.resume(u32 timer) - Resume a timer object.

Sample usage: Timer.resume(timer)
bool Timer.isPlaying(u32 timer) - Check if a timer is paused or not.

Sample usage: if Timer.isPlaying(timer) then .. end


Keyboard Module
void Keyboard.show(string title, string initial_text, [int length], [int type], [int mode]) - Inits OSK.

Sample usage: Keyboard.show("Insert a number", "0", 5, TYPE_NUMBER)
u8 Keyboard.getState(void) - Gets internal state of OSK.

Sample usage: state = Keyboard.getState()
string Keyboard.getInput() - Gets user input from OSK.

Sample usage: my_text = Keyboard.getInput()
void Keyboard.clear(void) - Terminates OSK.

Sample usage: Keyboard.clear()