Skip to content

About

File-based IPC bridge for executing Lua inside a running BG:EE/BG2:EE game with EEex

Resources

Stars

1 star

Watchers

1 watching

Forks

Repository files navigation

EEex Remote Console

A lightweight file-based IPC bridge that lets external tools, coding agents, and test suites execute Lua commands inside a running BG:EE, SoD, BG2:EE, EET, or IWD:EE game with EEex and read structured JSON results back — no sockets, no FFI, no external dependencies.

Optional developer tool in Chriz Easy BG & Chriz Easy IWD · bg.chrizfader.org


Part 1: Overview, Quick Start & CLI Usage

Use Cases

  • AI-assisted modding — let coding agents inspect and manipulate live game state (see CLAUDE.md.example)
  • Automated testing — run test suites against a running game from CI or scripts (tools/smoke-test.ps1)
  • Live debugging & diagnostics — query sprites, spells, effects, and variables without alt-tabbing to the in-game console

Requirements & Compatibility Matrix

  • A supported Infinity Engine EE game on Windows (runtime-tested on 2.7.3.0 and 2.6.6.0)
  • EEex 0.10.x through 1.3.x with the LuaJIT component, which provides the Lua io/os libraries this mod depends on:
    • EEex v1.2.x and v1.3.x: install component 1 (Main) and component 8 (LuaJIT)
    • EEex v1.0.0: choose the Experimental quick-menu tier; 0.10.x / 0.11.x: Experimental - Use LuaJIT
  • Install EEex Remote Console after EEex — the installer verifies capabilities (override/M___EEex.lua and LuaPatchMode=REPLACE_INTERNAL_WITH_EXTERNAL in InfinityLoader.ini) rather than hardcoded component logs
EEex version Status Verification
0.9.x Not supported No LuaJIT component; installer refuses
0.10.x Supported Not separately verified
0.11.x Supported Runtime-tested: v0.11.0-alpha on BG2:EE, full 22-case suite passed
1.0.x Supported Source-verified only: required EEex APIs confirmed in v1.0.0 source
1.2.x Supported Runtime-tested: v1.2.0 on BG2:EE 2.6.6.0 (22/22) and EET 2.7.3.0 (pong)
1.3.x Supported Runtime-tested: v1.3.1 on EET 2.7.3.0 (main menu & world screen 22/22)
Game Status
BG:EE (incl. SoD) Supported (GAME_IS ~bgee~ matches BG:EE + SoD)
BG2:EE Supported — runtime-tested on 2.6.6.0
EET Supported — runtime-tested on 2.7.3.0 (v0.2.1 checklist passed)
IWD:EE Supported — IWD:EE 2.7.3.0 + EEex v1.3.1 verified in Chriz Easy IWD labs

Installation

  1. Install EEex v1.2.0 or later with component 1 (Main) and component 8 (LuaJIT).
  2. Copy the eeexremote folder and setup-eeexremote.tp2 into your game directory.
  3. Run setup-eeexremote.exe (or WeiDU) after EEex.
  4. Launch via InfinityLoader.exe — the console is live from the main menu onward.

CLI Usage (tools/)

Both reference clients write commands atomically, tag them with request IDs so stale results are rejected, and share exit codes (0 ok, 1 Lua runtime or parse error, 2 timeout, 3 usage error).

PowerShell — tools/eeex-remote.ps1 (Windows PowerShell 5.1 & pwsh 7+)

$override = "C:\Games\Baldur's Gate II Enhanced Edition\override"
.\tools\eeex-remote.ps1 $override 'return 2 + 2'                       # Inline Lua
.\tools\eeex-remote.ps1 $override '@tools/scripts/party.lua'           # Quote @paths in PowerShell
.\tools\eeex-remote.ps1 $override -Api '^EEex_Sprite_' -TimeoutSec 10  # List live API globals
'return 2 + 2' | pwsh -File tools\eeex-remote.ps1 $override -          # Piped stdin (pwsh -File)
.\tools\eeex-remote.ps1 $override 'return 2 + 2' 5                     # Custom timeout (seconds)

Bash — tools/eeex-remote.sh

OVERRIDE="/path/to/Baldur's Gate II Enhanced Edition/override"
tools/eeex-remote.sh "$OVERRIDE" 'return 2 + 2'
tools/eeex-remote.sh "$OVERRIDE" 'print(EEex_Sprite_GetInPortrait(0):getName())'
tools/eeex-remote.sh "$OVERRIDE" @tools/scripts/party.lua
tools/eeex-remote.sh "$OVERRIDE" --api '^EEex_Sprite_'
tools/eeex-remote.sh "$OVERRIDE" - <<< 'return 2 + 2'

Part 2: Protocol v1.1 Specification, Architecture & License

How It Works

External Tool                            Game Process
─────────────                            ────────────
write temp file, rename to               EEexRemote.Poll() every render frame:
eeex_remote_cmd.lua        ────────────> claims atomically, compiles ONE chunk,
                                         runs under xpcall + watchdog, captures print()
poll & read
eeex_remote_result.json    <──────────── writes temp file, renames atomically

An invisible 1×1 menu element (EEexRC.menu) hooks WORLD_ACTIONBAR and START via EEex_Menu_AddAfterMainFileLoadedListener, opening before each host's onOpen so START_SP redirects are never covered (v0.2.1). Polling is render-driven and continues while the game is paused. Every command compiles as one Lua chunk: locals are shared across all lines of the script, and globals persist across successive commands.

Protocol v1.1 & Command Directives

  1. Delete any stale override/eeex_remote_result.json.
  2. Write Lua atomically (temp file in override/, then rename) to override/eeex_remote_cmd.lua.
  3. Poll for override/eeex_remote_result.json, check id if sent, read JSON, and delete it.

Leading comment directives (must be the very first lines; ignored as comments by v0.1.0 servers):

Directive Effect
--@id=<token> Echoed as id in the result so clients reject stale replies
--@watchdog=<N> Overrides instruction limit (default 200000000, ~1–2 s runaway guard)
--@nowatchdog Disables the watchdog for legitimately long scripts

Result Schema & Ready File

{
  "protocol": "1.1",
  "status": "ok | error | parse_error",
  "id": "echo of --@id (only if sent)",
  "error": "message (only on error / parse_error)",
  "traceback": "Lua stack traceback (only on runtime error)",
  "durationMs": 3,
  "returnValue": "tostring of first return value (legacy; only if non-nil)",
  "returnValues": ["every return value as structured JSON (depth <= 6, <= 256 KB each)"],
  "output": ["captured print() lines"]
}

On UI load and F5 reload, override/eeex_remote_ready.json logs {"protocol":"1.1","luajit":true,"screens":["WORLD_ACTIONBAR","START"],"disabled":false,"timestamp":"..."} — diagnostics only (not deleted on exit; send tools/scripts/ping.lua for liveness).

Discovering the Live API (tools/scripts/)

return EEexRemote.ListGlobals("^EEex_Sprite_") -- live global types & source:line
return EEexRemote.Info()                       -- protocol, luajit, io, screens, disabled, eeexActive
  • ping.lua — liveness check + capability report ("pong", EEexRemote.Info())
  • list-api.lua — overview of installed EEex globals grouped by prefix
  • party.lua — active party names in portrait order

Writing Your Own Client

Step File Action
1 override/eeex_remote_result.json Delete any stale result first
2 Temp file inside override/ Write --@id=<unique> + Lua source
3 override/eeex_remote_cmd.lua Rename temp file onto this name (atomic on same volume)
4 override/eeex_remote_result.json Poll (~10 s timeout); if id differs, delete & keep polling, else read & delete

Match the reference exit codes (0 ok, 1 Lua/parse error, 2 timeout, 3 usage).

Security Warning, Limitations & Troubleshooting

  • Security: Executes arbitrary Lua with full EEex engine and file I/O access; never install in directories writable by untrusted users or processes.
  • Limitations: Forced dialogues, the spellbook (MAGE), and Record (CHARACTER) screens suspend WORLD_ACTIONBAR polling until closed; serial one-command-at-a-time IPC (~200 ms round-trip); text/JSON only (keep returned tables and print() output well under megabyte scale).
  • Patch 2.7 won't launch: Update EEex to v1.2.0+ (delete [Auto-Generated] in InfinityLoader.ini if needed).
  • Timeouts / disabled notice: Verify the game is on the main menu or world screen, InfinityLoader.ini has LuaPatchMode=REPLACE_INTERNAL_WITH_EXTERNAL, and Generalized Biffing never biffs M_EEexRC.lua or EEexRC.menu.

Verification, Changelog & License

License

Licensed under the MIT License.

About

File-based IPC bridge for executing Lua inside a running BG:EE/BG2:EE game with EEex

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages