mirror of
https://github.com/ProjectLeonida/mandy.git
synced 2026-12-06 14:48:37 +00:00
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>
29 lines
714 B
TOML
29 lines
714 B
TOML
[package]
|
|
name = "leonida-lua"
|
|
description = "A sandboxed Lua 5.4 modding API for the runtime: events, overlay, settings, trainer pages and checked memory access."
|
|
version.workspace = true
|
|
edition.workspace = true
|
|
rust-version.workspace = true
|
|
license.workspace = true
|
|
publish.workspace = true
|
|
|
|
[dependencies]
|
|
leonida-menu.workspace = true
|
|
mlua.workspace = true
|
|
tracing.workspace = true
|
|
|
|
[target.'cfg(windows)'.dependencies]
|
|
windows-sys = { workspace = true, features = [
|
|
"Win32_Foundation",
|
|
"Win32_System_Threading",
|
|
"Win32_UI_Input_KeyboardAndMouse",
|
|
"Win32_UI_Input_XboxController",
|
|
"Win32_UI_WindowsAndMessaging",
|
|
] }
|
|
|
|
[dev-dependencies]
|
|
tempfile.workspace = true
|
|
|
|
[lints]
|
|
workspace = true
|