Skip to content

Search

Documentation

device

What a phone lends a game beyond the store: its motor, the share sheet and the store's review prompt. A call that answers does so through task::wait with…

On this page

What a phone lends a game beyond the store: its motor, the share sheet and the store's review prompt. A call that answers does so through task::wait with a map whose kind is shared, done, cancelled, error or unsupported, each an EVENT_* constant. platform::is_available says which of them work here. A test answers share and request_review from the file BALAUR_STAND_INS names.

4 functions, 12 constants. Scripts reach it as device::.

Functions

Argument kinds are the script values a call passes: node is a node handle, any a table or value of any kind, fn a callback.

function acts on what it does
haptic(string) — One tap of feedback, named by a HAPTIC_* constant: iOS's feedback generators, Android's predefined effects, a short buzz on a page. Nothing on a desktop, and never recorded.
request_review() -> int — Ask the store to show its prompt to rate the game, and return the id its done answer carries. The store decides whether it shows, and says nothing about what the player did. unsupported off iOS and macOS.
share(device::ShareOptions) -> int — Show the OS's share sheet over the game, and return the id its answer carries: shared with the target the player picked where the OS names it, cancelled, error, or unsupported where there is no sheet.
vibrate(float) — Buzz the device's motor for that many seconds: Android's vibrator, a page's navigator.vibrate, the iPhone's one system buzz whatever the length. Nothing on a desktop, and never recorded, like rumble.

Constants

name value
EVENT_CANCELLED "cancelled"
EVENT_DONE "done"
EVENT_ERROR "error"
EVENT_SHARED "shared"
EVENT_UNSUPPORTED "unsupported"
HAPTIC_ERROR "error"
HAPTIC_HEAVY "heavy"
HAPTIC_LIGHT "light"
HAPTIC_MEDIUM "medium"
HAPTIC_SELECTION "selection"
HAPTIC_SUCCESS "success"
HAPTIC_WARNING "warning"

Are you sure?