euca-script, via mlua) so you can attach per-entity behavior
scripts that read and write the world through a small euca API, with an instruction budget and hot
reload. Scripts run each tick in script_tick_system.
What it does
- Sandbox — dangerous globals are removed, and each script call is capped at an instruction budget (default 100,000) so a runaway loop can’t hang the tick.
- ECS bridge — the
eucaglobal exposesspawn(),despawn(id),get_position(id)/set_position(id,x,y,z),get_health(id)/set_health(id,v),delta_time(), and an event APIon("event", fn)/emit("event", …). - Per-entity scripts — a
ScriptComponent(script name, update function, enabled flag) attaches a script to an entity;script_tick_systemcalls its update function each tick. - Hot reload — a file watcher reloads changed scripts at runtime.
- Fork-safe — the engine is shared as
Arc<Mutex<ScriptEngine>>, so a forked world reuses the same VM rather than cloning it.
Endpoints
| Method | Path | Description |
|---|---|---|
POST | /script/load | Load a .lua file and attach it to an entity |
GET | /script/list | List entities with attached scripts |
Example
Status
- ✅ Sandboxed Lua VM, instruction budget, ECS bridge, per-entity scripts, hot reload, fork-safe sharing — shipped.
- 🟡 The default headless server does not register a
ScriptEngine(see the warning above).
Script endpoints
Load and list endpoints with schemas.