All Functions Modules Pages
OneLua Documentation

Version 4R1

Currently ONElua v4R1 has large functions implemented:

  • It has been optimized and improved the code for better performance.
  • It has adapted to the current needs for the Scene PSP-PSVita: VHBL, eCFW ARK and eCFW TN-V.
  • Added CAM module (GO! CAM).
  • Added IR module (Infrared Port).
  • Added HTTP module, includes an automatic integrated manager cookies.
  • Added the image upload BMP type.
  • Added files .pmf (gameboots) playback with the function pmf.run().
  • It has been included TV output (progressive mode 720 * 480) with the function os.modetv().
  • Added FTP module, improved the module Sockets and optimised the module Wlan with new features.
  • Optimized extraction of files .zip and .rar (mode thread) parallel extraction through.
  • It has several interesting modules like 3D module and SIO Module.
  • Added the function to load a default font: onefont.pgf if exist within the eboot.pbp, if it does not, it loads the jpn0.pgf of flash0.
  • This upgrade is really useful for the ppsspp emulator use, it just needs to put de renamed font correctly in onefont.pgf so the onelua eboot could start our homebrew with this default font.
  • Bit aggregate the Lua library that allows operations to bit-level.
  • Added several 'PATCH' to extend the syntax of lua, examples:
    • -Type C: operations "sum: +=, subtraction:-=, multiplication: *=, division: /=, power: ^=, mod: %=, different: !=, division does not float: \"
    • C operations bit: "and: &, or: |, not: ~, shift left: <<, right shift: >>"
    • Operations continue, "skips a cycle", in any loop.

Introduction

The OneLua project began as an idea not achievable in short-term, but after several plans and tests ended as you can see here. OneLua doesn't features very advanced functions, and it's not the most efficient or fastest Lua interpreter for the PSP, but even so features a great set of functions, starting with the most common of them and those that other interpreters doesn't have.

Installation

  1. Download the OneLua executable. Try to use only our links, to get the latest versions (both executable as docs).
  2. Make a new folder at /PSP/GAME, and put here the executable. Also, make a file named script.lua, to hold your source code.
  3. Edit your script.lua, and execute it as any other homebrew.
Warning
If you'll to use special characters (as ñ or accents) make sure your scripts are encoded using UTF-8, otherwise those chars won't be printed.

OneLua in the emulator PPSSPP

In order to work properly Onelua over the emulator, it is necessary to make certain adjustments:

  • Uncheck the box "software rendering"
  • Check the box "fast memory (unstable)".
  • and the most important, you need to place the font: oneFont.pgf beside the onelua eboot.pbp (the ppsspp emulator font jpn0.pgf in the flash0 is different).

Before using OneLua

In this docs you won't find info about using Lua native functions (as those of the modules math, string or io), only the custom functions of the interpreter. If you want to know more about the Lua functions,visit the oficial page.

Constants

Some OneLua functions features constants to ease its use. These constants have an associated numeric value (stated in the documentation in each case) so you can use either the constant or its value directly.

As not written rule, the OneLua constants are defined as __NAME (two underscores to top, and uppercase).

Callbacks

OneLua features several callbacks, that are functions that, if are defined, will be executed automatically during certain tasks that block the script execution. To use a callback you only need to define a function with the right name (see the following list) and put inside your code. The callbacks are not designed to run heavy or very complex code, so try to not overload them.

These are the available callbacks:

  • onDebug(msg) Executed when an error occurs in your script, to display a custom error.
    • msg: The error message generated for lua.
  • onAdhocConnection(state, backtime) Executed when you request an ad-hoc connection using the function adhoc.sendrequest().
    • state: Connection state.
    • backtime: counter with the time available before the request run out.
  • onCopyFiles(size, written, name) Executed when files are copied using files.copy().
    • size: File size (bytes).
    • written: written bytes.
    • name: Filename.
  • onExtractFiles(size, written, name) Executed when files are uncompresed using files.extract().
    • size: File size (bytes).
    • written: written bytes.
    • name: Filename.
  • onNetConnection(state) Executed when a WiFi connection is performed using wlan.connect().
    • state: A number, indicating the connection status.
  • onNetConfig(index, name) Executed with the next functions: wlan.backup(), wlan.restore() and wlan.add().
    • index: the position or ID of the net.
    • name: the name of the net connection.
  • onNetGetFile(size, written) Executed when a file is downloaded using http.getfile().
    • size: file size (bytes). if size can't be detected, it will return 0).
    • written: written bytes.
  • onDumpUmd(size, written) Executed when an UMD disc is dumped using umd.dumpiso().
    • size: UMD size (sectors).
    • written: written sectors.
  • onPbpUnpack(size, written, name) Executed when an EBOOT.PBP is unpacked using game.unpack().
    • size: File size (bytes).
    • written: written bytes.
    • name: filename.
  • onPbpPack(size, written, name) Executed when an EBOOT.PBP is packed using game.pack().
    • size: File size (bytes).
    • written: written bytes.
    • name: filename.
  • onPmfPlay(state) Executed when pmf file its playing using pmf.run().
    • state: State of play, true or false according to whether this in playing "play".
Note
  • The args of onExtractFiles and onPbpUnpack are not referred to the whole compressed file, but each file inside it.
  • The number and/or name of the callback arguments don't need to be the same as listed, however, the callback name must be exactly the same.
Warning
The callbacks don't update the screen, so you need to call manually screen.flip() to avoid crashes when using text or images in your callbacks.

Legal

Copyright © 1994–2014 Lua.org, PUC-Rio.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.