# BG3Access A screen-reader accessibility layer for **Baldur's Gate 3**, using a Script Extender fork and Lua readers for the game's live UI and gameplay state. Native Prism speech runs inside the game through the client-only `Ext.Speech` API. The next milestone uses a [Lua graph core with a native SE host](docs/graph-kernel.md) for keyboard accessibility, starting with the main menu and settings. The first host/navigator integration builds and passes offline tests. Sounds and tab navigation are confirmed working in DX11, along with scrolling beyond the initial rows and resolved Video values. The Keyboard identity fix passes a read-only live snapshot; navigation and activation await user testing. Complete settings coverage remains unfinished. ## Native development build This working tree requires our custom SE runtime. With Just installed: ```powershell just setup # first build: submodules and native dependencies just build # SE, Prism, and the Lua pak just test just install # rebuild and install; close BG3 first just status ``` Run `just` to list all recipes. Paths can be set in an ignored `.env` (see [env.example](env.example)); BG3 is detected automatically and Divine defaults to `~/.local/bin/lslib/Tools/Divine.exe`. Close BG3 before installing. The native installer uses the existing SE `DWrite.dll` loader, selects our local runtime, and retires the legacy speech autostart. A fresh game without a user profile uses `Data\Mods\GustavX\ScriptExtender`; a normal profile can use the enabled `.pak`. See [native development](docs/native-development.md) for the API, checks, and rollback. Installation always copies all Lua modules as loose files to `%LOCALAPPDATA%\Larian Studios\Baldur's Gate 3\Script Extender\A11y`. The bootstrap loads these first. Use `just push` to update Lua and reload the layer while the game is running. Native DLL or bootstrap changes require a closed-game installation and restart. Changed localization resources are applied live by `just push` (staged under `A11y\Localization` and written into the game's string repository with `Ext.Loca.UpdateTranslatedString`) for the current session only; `just push` reminds you until a closed-game `just install` makes them permanent. Loading tips and the splash-screen key prompt have a passive speech reader. The game handles the key that opens Main Menu. Generic controller UI reading is removed; existing dialogue, inventory, combat, and navigation helpers remain restricted to their supported screens and gameplay contexts. Main Menu starts on the first available main action after its opening animation. Tab cycles between main actions, the Larian account panel (button first), and information such as the game version and legal notice. Arrows read within each group. Space on Continue reads its visible save preview. The keyboard new-game flow now includes difficulty, character choices, ability point buy and bonuses, skills, class-specific selections, appearance, naming, guardian creation, and final confirmation. Tab changes zones; arrows browse; Enter selects; Space reads tooltips. Left/Right adjust scores and appearance carousels. In the name field, type normally and use Tab to leave editing. The latest extension passes offline tests; full in-game validation is pending. World navigation now has a WotR-access port with separate exploration and review cursors, its keyboard layout, scanner, floor browsing and original navigation sounds. Ctrl+Shift+A toggles focus; Ctrl+Shift+M opens spoken settings. See the [world navigation controls and validation limits](docs/world-navigation.md). This port requires the rebuilt native runtime and updated bootstraps. Its offline checks pass; live game actions and heard audio remain unverified. ## Playing it Testers download `BG3Access-Setup.exe` from the newest release on GitHub and run it. It finds the game (Steam or GOG), downloads the newest `BG3Access-.zip` from the releases, and installs everything the mod needs: our Script Extender build with native speech, the Script Extender loader, the mod pak switched on in the game's mod list, the game's actions on the mod's letter keys moved to Ctrl, and `--skip-launcher` in Steam's launch options (it asks first). Running it again updates or removes the mod; removal puts back exactly what it changed (it keeps a record in `Script Extender\A11y\install.txt`). The game must have been started once, so that its player profile exists. The installer's log is `%TEMP%\BG3Access-setup.log`. Making a release: `just build`, then `just release` (writes `dist/release/`), then `just test-setup` (install, update and removal in a sandbox). The version is in `VERSION`. Publish the zip and the exe as a normal (not pre-) release tagged `v`; the installer itself only needs rebuilding when `tools/installer/setup.cpp` changes. From a working copy the mod is installed with `just install` (above). The old releases 0.1-0.6 belonged to an earlier design and were removed. ## Layout | Path | What it is | | --- | --- | | `lua/` | The layer itself — **source of truth** for every module | | `BG3Access/` | Mod tree: `meta.lsx`, `Config.json`, `BootstrapClient/Server.lua` | | `BG3AccessDiag/` | A separate diagnostic mod (client/server probes) | | `probes/` | Console probes run by hand during investigation | | `tools/` | PowerShell: build, install, hot-reload, console I/O, data indexes | | `external/bg3se/` | Script Extender submodule: upstream development baseline for our fork | | `external/prism/` | Prism source submodule, pinned to a release tag | | `bg3-host-port-research.md` | How the five host ports map onto BG3's engine | | `experiment-results.md` | Running log of what was tried and what it did | `lua/a11y-*.lua` are the layer's modules: `pad` (input), `nav` (navigation), `menu` (screen readers), `model`, `mouse`, plus `nav-server` on the server context. ## Languages BG3 loads the layer's English and Russian translations into its native localization repository from `BG3Access/Mods/BG3Access/Localization//bg3access.xml`. Lua requests stable handles, for example `T("NoTooltip", "No tooltip")` resolves `BG3AccessNoTooltip` through `Ext.Loca.GetTranslatedString`. The second argument is an English fallback for unavailable resources. BG3 selects the language; the former Lua translation dictionaries, `Lang.set`, and `A11y/lang.txt` override are retired. | Path | What it is | | --- | --- | | `BG3Access/Mods/BG3Access/Localization/` | Native English/Russian resources; add another supported language directory here | | `lua/a11y-lang.lua` | Native lookup, numbered argument substitution, grammatical form selection, and game-caption recognition | | `tools/check-lang.ps1` | Handle coverage, duplicate/empty entries, count forms, and matching numbered arguments | Keep existing handles when editing wording. Formatted sentences use `[1]`, `[2]`, and so on, allowing translators to reorder arguments. `F("MessageId", "%s ... %d", name, count)` formats each argument before substituting it into the native text. Count sentences also live in XML; Lua selects the appropriate grammatical form. Game-owned names and labels use their original game handles or rendered localized UI text, including the game's argument substitutions. The pak includes these resources. The first-launch GustavX graft installs only the mod's `Localization//BG3Access.xml` beside its ScriptExtender folder, so the already-loaded host module supplies both Lua and native strings. Switching to the pak removes those exact graft localization files. Permanent localization updates need module loading or a restart; for testing, `just push` applies the mod's own changed strings to the running game until it exits (`Lang.loadOverrides`). `a11y-lang.lua` also holds the handles for the strings the layer matches **against** the game — the options row that carries the control scheme, the buttons under a dialogue box, the camp supply label. Those were hard-coded in Russian until 0.5.0, which is why the control-scheme repair silently did nothing on any copy of the game that was not Russian. A handle resolves to whatever the player is looking at, in all fifteen of the game's languages. ## How the game takes the mod **Close the game first**: Baldur's Gate 3 holds every pak in `Mods\` open while it runs, switched on or not, so an install cannot replace one until it quits. The mod is an ordinary mod (`BG3Access.pak` in `%LOCALAPPDATA%\...\Mods\`, enabled in `modsettings.lsx`) or, on a fresh profile, a graft (below); our SE runtime and Prism go into `\bin\`. `just install` does all of it. By hand: ```powershell powershell -File tools\build-mod.ps1 -Pak -InstallPak # build and install as a mod powershell -File tools\register-mod.ps1 -Pak BG3Access.pak # switch it on powershell -File tools\mod-status.ps1 # after restarting: did it take? ``` This README said the opposite until 2026-08-07 — "Patch 8 does not accept a mod from outside its own manager, a `.pak` in `Mods\` is never listed and a `modsettings.lsx` entry is stripped on the next launch" — and that was wrong in a way worth recording, because it shaped the whole project. Patch 8 accepts outside paks. It was rejecting *this* mod, whose `meta.lsx` was still in the pre-Patch-7 format, and a module whose meta will not parse is not refused with a message: it is simply absent from `AvailableMods`, from the in-game manager, and from the log. The entry in `modsettings.lsx` then disappeared for the plainest of reasons — the game deletes an entry whose module it cannot find. Two questions were being asked as one, and they have different answers: - **does the game know the module** — `meta.lsx` decides it, `AvailableMods` reports it; - **does the game load it** — `modsettings.lsx` decides it. A pak in `Mods\` is installed and switched *off* until something enables it. `tools/register-mod.ps1` answers the second for any mod, not just this one: `-List` shows what is installed against what is enabled, `-Pak ` switches one on, `-Remove` off. Given a mod in the old format it refuses to write the entry and says so, instead of writing one that will vanish. `tools/build-mod.ps1` checks the same things before packing, so this repo cannot ship a module the game would ignore in silence. **Grafting** is still there and still works, as the fallback for a machine where the pak route fails: `graft-mod.ps1` puts the layer's `ScriptExtender` folder inside a module the game already loads (`GustavX`), where the Script Extender finds it without any mod at all. It adds only new paths, replaces nothing, and `-Uninstall` takes them away again. The two routes are **mutually exclusive** — both declare `"ModTable": "BG3Access"` — so `-InstallPak` removes one as it installs the other. Every script takes `-GameDir`, and defaults it to whatever `tools/find-game.ps1` finds — Steam's `libraryfolders.vdf`, then GOG's registry entry, then the usual paths, each candidate proved by `bin\bg3.exe` rather than by the folder name. ## Development loop ### Native development dependencies The selected architecture is an SE fork supporting UI and gameplay accessibility, with native speech and additional engine bindings. The source dependencies are Git submodules: ```powershell git submodule update --init -- external/bg3se external/prism ``` SE follows upstream `main` (upstream has no `master` branch). Prism is pinned to `v0.18.2`. Both exact commits are recorded by this repository. See [Native development setup](docs/native-development.md) for the dependency layout and scope. ### Existing Lua development loop ```powershell powershell -File tools\push-lua.ps1 # push every module + reload powershell -File tools\push-lua.ps1 -Name a11y-pad # push one ``` The push copies into the running game's Script Extender folder and asks the live layer to re-read it — no repack, no restart. ## Running native plugins alongside this Nothing here needs it, and it is written down because getting it wrong takes the layer with it. Native BG3 plugins are DLLs loaded into the game process. BG3's [Native Mod Loader](https://www.nexusmods.com/baldursgate3/mods/944) uses a `bink2w64.dll` proxy and loads plugins from `bin\NativeMods\`. Script Extender uses `DWrite.dll`. These loaders use different proxy filenames and can coexist; individual plugin compatibility still needs testing. The previous claim here that both require `DWrite.dll` was incorrect. See [Native speech investigation](docs/native-speech-investigation.md) for the reference checkouts and the standalone bridge option that was investigated before selecting an SE fork. The following dated observations concern an earlier deployment using a different loader. [Yet Another BG3 Native Mod Loader](https://github.com/MolotovCherry/Yet-Another-BG3-Mod-Loader) does not proxy anything — it injects from outside — so it and the extender coexist. Measured on this machine, 2026-08-06: game up, loader in the process (`Running Loader by Cherry v0.1.0`), `boot.json` reporting `state=running` with all six of our modules loaded. No conflict. **Coexisting is not the same as harmless, and 2026-08-07 is the day that showed it.** Two crashes in two days — one in combat, one on the options screen — with nothing in the extender's logs, no Windows fault event and no dump, because runtime logging and crash reports were both off. What there was: ``` ERROR Отказано в доступе. (0x80070005) ×9 ERROR panicked at crates\yabg3nml\src\tray.rs:72:22 INFO Loading plugin bg3nativecameratweaks.dll ``` - The watcher **panics creating its tray icon** when the logon task starts it, which is the crash dialog that appears at boot pointing into `AppData\...\Plugins\logs`. Access denied on `Shell_NotifyIcon` is what starting before the shell looks like; a delay on the trigger would probably settle it. - The plugin it injects is Native Camera Tweaks, and both crashes were at a moment the camera changes mode. That is a suspicion, not a finding — but it is the newest variable, and this layer needs none of it. So the isolation run is: task disabled, watcher killed, `enabled = false` in `%LOCALAPPDATA%\Larian Studios\Baldur's Gate 3\Plugins\config.toml`. Putting it back is `Enable-ScheduledTask -TaskName "BG3Access Native Loader"` and the `.bak-enabled` beside that config. Anything diagnosed with the loader in the process is diagnosed with a variable nobody here controls. - Tools (`bg3_injector.exe`, `bg3_watcher.exe`, `loader.dll`) → `\bin\NativeModLoader\`. From that folder the game root is found on its own, but `install_root` in the config is written as the default Steam path and needs correcting on a machine like this one where the game is on another drive. - Plugins and config → `%LOCALAPPDATA%\Larian Studios\Baldur's Gate 3\Plugins\`, **not** `bin\NativeMods\`. `config.toml` and a `logs\` folder appear there on first run. - The injector is one-shot: start the game, then run it. The watcher is the same thing left running in the background. The autostart variant edits the registry; this machine does not use it. **This is a door to native plugins only.** Ordinary `.pak` mods are a different problem, and a solved one — see Install: Patch 8 does take them, this layer ships as one, and `tools/register-mod.ps1` enables any other. ## Dependencies not in this repo - **LSLib / Divine** → `tools/lslib/`, from https://github.com/Norbyte/lslib/releases. Only `build-mod.ps1 -Pak` needs it. Use this build, not the one bundled with Vortex: the Vortex one writes an LSPK v16 package and BG3 reads v18, failing silently. Native builds use `build/native/prism/prism.dll`, compiled from `external/prism` v0.18.2. ## License MIT — see [LICENSE](LICENSE). Prism is third-party and carries its own terms.