Mod API: capability input (experimental): claimed items' use, mod keys
- WIT `input`: claim-items(ids) makes the use button on those items the mod's: use-start, then use-stop with the ticks held (button up, item out of the hand, or a screen opening); the game does nothing else with the click. register-key(name, label, key) for up to 16 keys (key.keyboard.r), heard as key-down / key-up while playing; the game's own mapping on the key still runs. held(), poll() (256 kept). - game/mod_input.rs: play_mouse asks mod_use first (local and remote windows), the tick ends a use whose item left the hand, the keyboard and horizon-ctl's key send the physical key to mod_key. - No claim and no key, no cost: one check each. - Experimental: the manifest needs experimental = ["input"]. - The ui test guest gains /input_claim, /input_poll and /input_held, with a sandbox test. Docs: mods.md, stability.md, the changelog, the regenerated reference. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+2
-1
@@ -88,6 +88,7 @@ folder, loads no runtime and plays exactly like vanilla 26.3.
|
||||
| `storage` | `storage` | `get(key)`, `set(key, value)`, `delete(key)`: a per-mod folder of up to 64 files, 4 MiB total, at most 1 MiB written per call |
|
||||
| `ui` | `ui` | `open-screen`, `close-screen`, `set-settings`: a screen the mod owns and a page in Options > Mods, of text, item and list widgets the game lays out and draws with its own menus' code. **Experimental:** the manifest needs `experimental = ["ui"]` |
|
||||
| `render` | `render` | `set-hud(shapes)`: up to 1024 fills, four-cornered shapes, GUI sprites, items and text, kept on the HUD (over the hotbar, under chat and screens, hidden with F1) until replaced; `gui-size()`; `shake(strength, seconds)`: the view turns, the player doesn't, scaled by Distortion Effects. The game's own HUD renderer draws them: a mod never supplies shader code. **Experimental:** `experimental = ["render"]` |
|
||||
| `input` | `input` | `claim-items(ids)`: the use button on those items is the mod's (`use-start`, `use-stop` with the ticks held; the game doesn't place, eat or swing); `register-key(name, label, key)`: up to 16 keys (`key.keyboard.r`), heard while playing as `key-down` / `key-up` (the game's own mapping on that key still runs); `held()`; `poll()` returns the events, at most 256 kept. **Experimental:** `experimental = ["input"]` |
|
||||
|
||||
| Hook (export) | When |
|
||||
|---|---|
|
||||
@@ -289,7 +290,7 @@ experimental = [] # experimental capabilities it uses, e.g. ["ui"]
|
||||
```
|
||||
|
||||
Unknown keys are refused, so a typo is an error, not a silently ignored
|
||||
permission. An experimental capability (today `ui` and `render`) may change in any release
|
||||
permission. An experimental capability (today `ui`, `render` and `input`) may change in any release
|
||||
([stability](api/stability.md)): a mod uses it only by naming it in
|
||||
`experimental` as well, so nobody depends on it by accident.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user