Touch
cinnabar:extension/touch@0.1.0
Mod-owned on-screen buttons drawn in the built-in touch control style while touch controls are shown. Players move them in the touch layout editor. Requires controls authority.
Grants: controls.
Types
point
A GUI-pixel pair.
record point {
x: f32,
y: f32,
}
| Member | Type | Description |
|---|---|---|
x | f32 | |
y | f32 |
anchor
The screen edge or centre a placement measures from.
enum anchor {
top-left,
top-center,
top-right,
left,
center,
right,
bottom-left,
bottom-center,
bottom-right,
}
| Member | Type | Description |
|---|---|---|
top-left | ||
top-center | ||
top-right | ||
left | ||
center | ||
right | ||
bottom-left | ||
bottom-center | ||
bottom-right |
button
A retained mod-owned touch control with player-adjustable default placement.
record button {
id: string,
label: string,
anchor: anchor,
offset: point,
size: point,
}
| Member | Type | Description |
|---|---|---|
id | string | 1–32 bytes of lowercase ASCII letters, digits, _ and -. A player’s savedplacement is keyed by it, so prefix it with the mod’s name; when two mods use one id, only the earlier mod’s button is shown. |
label | string | One line of 1–24 bytes of plain text without § codes, drawn centred as written. |
anchor | anchor | Default placement, in GUI pixels inward from the anchored edges or right/down from centred axes, each at most 1024. |
offset | point | |
size | point | Width and height in GUI pixels, each 18 through 96. |
Functions
set-buttons
set-buttons: func(buttons: list<button>) -> result<_, string>;
Replaces this instance’s retained buttons, at most 4; an empty list removes them. Committed after a successful callback; quarantine, unload and revocation remove them.
Types: button.
read-presses
read-presses: func() -> result<list<string>, string>;
IDs of this instance’s buttons tapped since its previous frame callback, oldest first.
A tap completes when the finger lifts inside the button. Empty outside frame; a
deferred frame keeps the taps for the next one.