platform
Store services every platform shares: sign-in, achievements, leaderboards, cloud saves. A call answers task::wait later with a map whose kind is…
Store services every platform shares: sign-in, achievements, leaderboards, cloud saves. A call answers task::wait later with a map whose kind is signed_in, signed_out, done, scores, read, error or unsupported, each an EVENT_* constant. A sign-in or sign-out, asked for or not, is also the platform_event event, events::listen(node, "platform_event").
11 functions, 7 constants. Scripts reach it as platform::.
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 |
|---|---|---|
backend() -> string |
— | The name of the loaded store, or "none". |
cloud_read(string) -> int |
— | Read a value the store syncs between the player's devices, and return the id whose read answer holds it as value: a string, or nil when the key holds nothing. |
cloud_write(string, string) -> int |
— | Write a value for the store to sync between the player's devices, and return the id its answer carries. |
player() -> platform::Player? |
— | Who the store says is playing, or nil before a sign-in has landed. |
progress(string, float) -> int |
— | Report an achievement's completion, 0 to 100, and return the id its answer carries. |
scores(string, platform::ScoresOptions?) -> int |
— | Read a leaderboard's entries, and return the id whose scores answer holds them as entries, each a Score. |
set_presence(string) -> int |
— | Say what the player is doing, where the store shows it, and return the id its answer carries. |
sign_in() -> int |
— | Ask the store who is playing, and return the id its answer carries. A later sign-out is the platform_event event. |
signed_in() -> bool |
— | Whether a sign-in has landed. |
submit_score(string, int) -> int |
— | Post a score to a leaderboard, and return the id its answer carries. |
unlock(string) -> int |
— | Award an achievement whole, and return the id its answer carries. |
Constants
| name | value |
|---|---|
EVENT_DONE |
"done" |
EVENT_ERROR |
"error" |
EVENT_READ |
"read" |
EVENT_SCORES |
"scores" |
EVENT_SIGNED_IN |
"signed_in" |
EVENT_SIGNED_OUT |
"signed_out" |
EVENT_UNSUPPORTED |
"unsupported" |