|
LifeLua 21-08-2025
Documentation for LifeLua, a Lua interpreter for the PS Vita
|
Wi-Fi, downloads & FTP server. More...
Functions | |
| boolean | network.wifi () |
| string | network.ip () |
| string | network.mac () |
| number | network.download (string url, string path, number method, string data, string contenttype, string useragent) |
| string | network.get (string url, number method, string data, string contenttype, string useragent) |
| string | network.header (string url, string useragent) |
| table | network.ftp.start (boolean enable) |
| boolean | network.ftp.isrunning () |
| nil | network.ftp.adddevice (string partition) |
| nil | network.ftp.removedevice (string partition) |
HTTP methods | |
Used with network.download() and network.get() to choose how the request is sent. | |
| number | SCE_HTTP_METHOD_GET |
| Get a page or file (the default) | |
| number | SCE_HTTP_METHOD_POST |
| Send data to the server, e.g. a form or JSON. | |
| number | SCE_HTTP_METHOD_HEAD |
| Like GET, but the server only sends the headers, no content. | |
| number | SCE_HTTP_METHOD_OPTIONS |
| Ask the server which methods it supports. | |
| number | SCE_HTTP_METHOD_PUT |
| Upload data to replace what's at the URL. | |
| number | SCE_HTTP_METHOD_DELETE |
| Delete what's at the URL. | |
| number | SCE_HTTP_METHOD_TRACE |
| Ask the server to send the request back (for debugging) | |
| number | SCE_HTTP_METHOD_CONNECT |
| Open a tunnel through a proxy. | |
| number network.download | ( | string | url, |
| string | path, | ||
| number | method, | ||
| string | data, | ||
| string | contenttype, | ||
| string | useragent ) |
Downloads a file (HTTP or HTTPS). The app waits until the download is finished.
If you define a global function called LifeLuaNetworkDownload, it's called every time a piece of the file is downloaded, so you can show the progress. It receives these 5 numbers (the names you give them don't matter):
If the callback raises an error, the download stops and the error is passed on.
| url | The URL of the file |
| path | Where to save the file |
| method | The HTTP method (optional, default: SCE_HTTP_METHOD_GET) |
| data | Data to send with the request, e.g. for SCE_HTTP_METHOD_POST (optional, default: nothing is sent) |
| contenttype | The type of data (optional, default: "application/x-www-form-urlencoded"). Only used if data is given. |
| useragent | The User-Agent sent to the server (optional, default: a desktop Chrome User-Agent) |
200 for OK, 404 for not found), or nil if the connection, the request or writing the file failed | nil network.ftp.adddevice | ( | string | partition | ) |
Makes a partition visible on the running FTP server
| partition | Partition name (e.g. "ux0:") |
| boolean network.ftp.isrunning | ( | ) |
Checks if the FTP server is running
true if it's running | nil network.ftp.removedevice | ( | string | partition | ) |
Hides a partition from the running FTP server
| partition | Partition name (e.g. "ux0:") |
| table network.ftp.start | ( | boolean | enable | ) |
Starts or stops an FTP server on the PS Vita, so you can access its files from a computer.
| enable | true to start, false to stop |
ip (string) and port (number) to connect to. Raises an error if the server is already in the requested state. | string network.get | ( | string | url, |
| number | method, | ||
| string | data, | ||
| string | contenttype, | ||
| string | useragent ) |
Downloads a page (HTTP or HTTPS) and returns its content as a string, instead of saving it to a file. The app waits until it's finished.
The LifeLuaNetworkDownload callback is called here too (see network.download()). Since nothing is written to a file, its "written" numbers are the same as the "downloaded" ones.
| url | The URL of the page |
| method | The HTTP method (optional, default: SCE_HTTP_METHOD_GET) |
| data | Data to send with the request, e.g. for SCE_HTTP_METHOD_POST (optional, default: nothing is sent) |
| contenttype | The type of data (optional, default: "application/x-www-form-urlencoded"). Only used if data is given. |
| useragent | The User-Agent sent to the server (optional, default: a desktop Chrome User-Agent) |
200). nil if the connection or the request failed. | string network.header | ( | string | url, |
| string | useragent ) |
Gets the HTTP response headers of a URL
| url | The URL |
| useragent | The User-Agent sent to the server (optional, default: a desktop Chrome User-Agent) |
nil if the request failed | string network.ip | ( | ) |
Gets the PS Vita's IP address
"192.168.1.20", or "127.0.0.1" if not connected | string network.mac | ( | ) |
Gets the PS Vita's MAC address
"00:11:22:AA:BB:CC" | boolean network.wifi | ( | ) |
Checks if the PS Vita is connected to Wi-Fi
true if it's connected (or connecting)