diff options
| author | NotRexed <therealnothingfn@gmail.com> | 2026-11-27 00:00:36 -0500 |
|---|---|---|
| committer | NotRexed <therealnothingfn@gmail.com> | 2026-11-27 00:11:49 -0500 |
| commit | 312dfeac0da7e2e205ed7202df88a9c594aa33ca (patch) | |
| tree | 223e892a05116d6d60fea46c21d0c32fd195ed9f /docs | |
| parent | 0ed5c935d7ba64ac48788b22f363482a3c2ffa40 (diff) | |
leonida-lua: a sandboxed Lua 5.4 modding API (events, overlay, settings, menu pages, checked memory)
What: a new crate that runs the Lua mods of mods\<name>\ (mod.json with
"script": "main.lua", enabled unless it says false) in one Lua 5.4 state (mlua,
vendored, MIT) on a thread of its own. The `leonida` table (api_version 1):
on("frame"|"key"|"menu_open"), key_down, pad, hold_keys/release_keys, text/rect
(a draw list cleared each pass), get/set for fps_cap, dlss_sharpness, panel,
menu_scale and game_speed only, menu.page():toggle/number/action, memory
read/write u8..f64/bytes, scan with wildcards and base, log, screenshot, frame,
time, read_file/write_file in the mod's folder, require of the mod's own .lua.
Sandbox: each mod gets an environment of copies of the safe base functions and
coroutine/table/string/utf8/math and os.time/clock/date/difftime. No io, package,
debug, dofile, loadfile, string.dump, os.execute/remove/rename/exit/getenv, no
precompiled chunks, no network. A mod's error, a call that outlives its 200 ms
budget (also inside pcall and coroutines) or 128 MiB for the state switches that
mod off and nothing else. The host is behind a Platform trait; the renderer
wiring follows in the next commit. mod.json is read by a small JSON reader of
its own (json.rs): serde_json in the build made `assert_eq!(vec_of_u32, [])`
ambiguous in leonida-gpu's tests.
Why: mods can use what the runtime controls (the title's own script functions
are not reachable: docs/mod-menu.md).
How checked: cargo test -p leonida-lua --lib (34 passed): forbidden functions
gone, event dispatch, one mod failing (syntax, runtime, table errors, endless
loops, memory) leaving the others, memory reads and writes of a local buffer
with unmapped, protected and out-of-range addresses, scan across chunks and
holes, overlay list, menu pages and callbacks, settings, files, require,
manifests, the JSON reader, API version. Cargo.lock gains mlua, mlua-sys,
lua-src and their small dependencies. scripts/check_no_game_data.py on the
files. AI-assisted.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'docs')
0 files changed, 0 insertions, 0 deletions