How can I use Lua scripting and the web server in PCSX-Redux?

Updated

PCSX-Redux exposes a Lua scripting layer and a built-in web server so you can automate emulator tasks, inspect memory and registers, hook events, and drive the emulator from outside the GUI. According to the official documentation, the Lua API covers loaded libraries, a basic Redux API, rendering, a file API, building ISO images, PPF patches, and a web server Lua API, while the web server itself is listed as a core feature alongside the VRAM viewer, GPU logger, and MIPS API. If you want to script emulator behavior or control it remotely, these are the entry points to look at.

What the Lua scripting layer covers

The documentation's Lua section is organized into these topics:

  • Lua Introduction — the starting point for the scripting layer.
  • Loaded libraries — which Lua libraries are available to your scripts.
  • Redux basic API — the core emulator-facing functions.
  • Rendering — drawing/output-related calls.
  • File API — file access from scripts.
  • Building ISO images — assembling disc images via script.
  • PPF patches — applying PPF patches.
  • Webserver Lua API — the Lua side of the web server.
  • Memory and registers — reading and writing emulator state.
  • Events — reacting to emulator events.
  • Breakpoints — scripted breakpoint handling.
  • Inline assembler — assembling MIPS code from within Lua.
  • Handling of PSX binaries — working with PlayStation executables.
  • Case studies — worked examples, including an Openbios case study.

So the practical scope is broad: you can read/write memory and registers, set breakpoints, assemble instructions inline, process PSX binaries, build ISOs, and patch with PPF — all from Lua.

What the web server gives you

The web server is documented as its own feature and also has a Webserver Lua API. That means two complementary paths:

  1. A server you can reach from a browser or another tool, useful for remote inspection or integration with external scripts.
  2. Lua bindings for the web server, so your scripts can serve or respond to requests as part of an automation workflow.

The documentation lists the web server next to the VRAM viewer, GPU logger, and MIPS API, so treat it as a first-class debugging/automation surface rather than an add-on.

How the pieces fit together for automation

A typical scripted workflow combines several documented areas:

  1. Load your script and confirm the loaded libraries match what you need.
  2. Use the Redux basic API to interact with the emulator.
  3. Read memory and registers or set breakpoints to observe execution.
  4. Hook events to trigger logic when the emulator reaches a state you care about.
  5. Use the file API to read inputs or write outputs.
  6. Build an ISO image or apply a PPF patch as the end product.
  7. Expose results through the web server (directly or via the Webserver Lua API) if another process needs them.

The inline assembler and PSX binary handling are what let you go beyond observation into patching and code injection.

Where to start

The documentation's own navigation suggests this order: Lua Introduction → Loaded libraries → Redux basic API → Rendering → File API → Building ISO images → PPF patches → Webserver Lua API → Memory and registers → Events → Breakpoints → Inline assembler → Handling of PSX binaries → Case studies. The Openbios case study is the closest thing to a full worked example, so read it after the API references.

For the emulator itself, the documentation points to the download page at https://github.com/grumpycoders/pcsx-redux#where. For emulator-specific questions it lists a Discord server, and for general PS1 development, hacking, and reverse engineering it lists the PSX.Dev Discord server.

Practical notes

  • The documentation does not state pricing or login requirements for these features, so don't assume the scripting or web server is gated — check the current docs and repository.
  • The web server and Lua API are described as features of the emulator, so version differences are likely; verify against the docs matching your build.
  • If you're new to the emulator overall, the Compiling PCSX-Redux, Menus, and Command line arguments pages are the natural prerequisites before scripting.