@origingame/engine 0.0.0-stage → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/og.mjs +25 -0
- package/dist/web/origin-engine.d.ts +1233 -0
- package/dist/web/origin-engine.js +8628 -0
- package/dist/web/origin-engine_bg.wasm +0 -0
- package/dist/web/origin-engine_bg.wasm.d.ts +366 -0
- package/dist/web-publish/origin-engine-lanes.js +8509 -0
- package/dist/web-publish/origin-engine-lanes_bg.wasm +0 -0
- package/dist/web-publish/origin-engine.d.ts +1176 -0
- package/dist/web-publish/origin-engine.js +8313 -0
- package/dist/web-publish/origin-engine_bg.wasm +0 -0
- package/dist/web-publish/origin-engine_bg.wasm.d.ts +347 -0
- package/dist/web-publish/snippets/wasm-bindgen-rayon-38edf6e439f6d70d/src/workerHelpers.no-bundler.js +77 -0
- package/dist/web-publish-2d/origin-engine-lanes.js +8509 -0
- package/dist/web-publish-2d/origin-engine-lanes_bg.wasm +0 -0
- package/dist/web-publish-2d/origin-engine.d.ts +1176 -0
- package/dist/web-publish-2d/origin-engine.js +8313 -0
- package/dist/web-publish-2d/origin-engine_bg.wasm +0 -0
- package/dist/web-publish-2d/origin-engine_bg.wasm.d.ts +347 -0
- package/dist/web-publish-2d/snippets/wasm-bindgen-rayon-38edf6e439f6d70d/src/workerHelpers.no-bundler.js +77 -0
- package/knowledge/README.md +31 -0
- package/knowledge/knowledge.json +13 -0
- package/knowledge/looks/catalogue.json +1871 -0
- package/knowledge/package.json +33 -0
- package/knowledge/rules/platform.json +329 -0
- package/knowledge/scaffold/README.md +27 -0
- package/knowledge/scaffold/distribution.json +48 -0
- package/knowledge/scaffold/origin-engine.json +19 -0
- package/knowledge/scaffold/template/.origin/setup +14 -0
- package/knowledge/scaffold/template/LICENSES.md +23 -0
- package/knowledge/scaffold/template/README.md +37 -0
- package/knowledge/scaffold/template/assets/ai/guard.ogt +48 -0
- package/knowledge/scaffold/template/assets/audio/click.ogt +9 -0
- package/knowledge/scaffold/template/assets/fonts/NotoSansSC-Regular-subset.ttf.ogt +12 -0
- package/knowledge/scaffold/template/assets/fonts/OFL.txt +93 -0
- package/knowledge/scaffold/template/assets/looks/origin-game.ogt +12 -0
- package/knowledge/scaffold/template/assets/nav/yard.ogt +27 -0
- package/knowledge/scaffold/template/assets/scenes/main.ogt +34 -0
- package/knowledge/scaffold/template/assets/strings/en.ogt +14 -0
- package/knowledge/scaffold/template/assets/textures/stone_n.png.ogt +7 -0
- package/knowledge/scaffold/template/gitattributes +22 -0
- package/knowledge/scaffold/template/gitignore +8 -0
- package/knowledge/scaffold/template/package.json +18 -0
- package/knowledge/scaffold/template/project.ogt +25 -0
- package/knowledge/scaffold/template/src/main.ts +246 -0
- package/knowledge/scaffold/template/tests/guard.og.ts +67 -0
- package/knowledge/scaffold/template/tests/smoke.og.ts +43 -0
- package/knowledge/scaffold/template/tsconfig.json +17 -0
- package/knowledge/scripts/lib.ts +207 -0
- package/knowledge/scripts/mount.ts +210 -0
- package/knowledge/scripts/pack.ts +25 -0
- package/knowledge/scripts/scaffold.ts +72 -0
- package/knowledge/scripts/validate.ts +749 -0
- package/knowledge/skills/og-ai/SKILL.md +386 -0
- package/knowledge/skills/og-audio/SKILL.md +191 -0
- package/knowledge/skills/og-build/SKILL.md +330 -0
- package/knowledge/skills/og-core/SKILL.md +285 -0
- package/knowledge/skills/og-feel/SKILL.md +385 -0
- package/knowledge/skills/og-game/SKILL.md +1479 -0
- package/knowledge/skills/og-i18n/SKILL.md +220 -0
- package/knowledge/skills/og-platform-sdk/SKILL.md +199 -0
- package/knowledge/skills/og-taste/SKILL.md +537 -0
- package/knowledge/skills/og-ui/SKILL.md +444 -0
- package/knowledge/wiki/ai.md +627 -0
- package/knowledge/wiki/anim.md +1187 -0
- package/knowledge/wiki/atmosphere.md +636 -0
- package/knowledge/wiki/audio.md +732 -0
- package/knowledge/wiki/camera.md +711 -0
- package/knowledge/wiki/commands.md +357 -0
- package/knowledge/wiki/game.md +220 -0
- package/knowledge/wiki/i18n.md +213 -0
- package/knowledge/wiki/index.md +1027 -0
- package/knowledge/wiki/input.md +1714 -0
- package/knowledge/wiki/load.md +1280 -0
- package/knowledge/wiki/math.md +166 -0
- package/knowledge/wiki/nav.md +1154 -0
- package/knowledge/wiki/physics.md +3142 -0
- package/knowledge/wiki/platform.md +857 -0
- package/knowledge/wiki/probe.md +1692 -0
- package/knowledge/wiki/reflect.md +285 -0
- package/knowledge/wiki/render.md +3511 -0
- package/knowledge/wiki/rng.md +393 -0
- package/knowledge/wiki/stream.md +376 -0
- package/knowledge/wiki/system.md +197 -0
- package/knowledge/wiki/systems.md +43 -0
- package/knowledge/wiki/terrain.md +727 -0
- package/knowledge/wiki/tilemap.md +422 -0
- package/knowledge/wiki/time.md +150 -0
- package/knowledge/wiki/transform.md +230 -0
- package/knowledge/wiki/tween.md +580 -0
- package/knowledge/wiki/ui.md +8000 -0
- package/knowledge/wiki/world.md +909 -0
- package/package.json +68 -4
- package/schema/api.schema.json +29675 -0
- package/shell/README.md +22 -0
- package/shell/brand/README.md +23 -0
- package/shell/brand/icon-192.png +0 -0
- package/shell/brand/icon-512.png +0 -0
- package/shell/brand/mark-on-paper.svg +6 -0
- package/shell/brand/origin-mark.svg +5 -0
- package/shell/brand/origin-motion.css +251 -0
- package/shell/brand/tokens.css +20 -0
- package/shell/brand.ts +132 -0
- package/shell/page.ts +715 -0
- package/shell/platform.ts +203 -0
- package/shell/player.ts +238 -0
- package/shell/shell.css +185 -0
- package/shell/sw.ts +177 -0
- package/shell/transport.ts +515 -0
- package/shell/wire.ts +369 -0
- package/src/e6.ts +69 -0
- package/src/env.d.ts +100 -0
- package/src/generated/abi.ts +980 -0
- package/src/index.ts +193 -0
- package/src/node/audio.ts +86 -0
- package/src/node/build.ts +109 -0
- package/src/node/device.ts +981 -0
- package/src/node/doctor.ts +60 -0
- package/src/node/index.ts +102 -0
- package/src/node/platform.ts +24 -0
- package/src/node/playtest-run.ts +249 -0
- package/src/node/png.ts +130 -0
- package/src/node/polish.ts +976 -0
- package/src/node/run.ts +373 -0
- package/src/node/web-build.ts +808 -0
- package/src/p2.ts +35 -0
- package/src/platform-local.ts +211 -0
- package/src/playtest.ts +131 -0
- package/src/runtime.ts +1509 -0
- package/src/systems/cameras.ts +247 -0
- package/src/ui-kit/bind.ts +141 -0
- package/src/ui-kit/huds.ts +303 -0
- package/src/ui-kit/index.ts +36 -0
- package/src/ui-kit/menus.ts +187 -0
- package/src/ui-kit/settings.ts +131 -0
- package/src/ui-kit/store.ts +222 -0
- package/src/ui-kit/story.ts +89 -0
- package/src/ui-kit/util.ts +106 -0
- package/src/web/a11y.ts +429 -0
- package/src/web/audio-worklet.ts +193 -0
- package/src/web/audio.ts +307 -0
- package/src/web/basis.ts +239 -0
- package/src/web/gamepad.ts +123 -0
- package/src/web/host.ts +166 -0
- package/src/web/input.ts +237 -0
- package/src/web/lanes.ts +21 -0
- package/src/web/play.ts +20 -0
- package/src/web/rpc-ring.ts +110 -0
- package/src/web/settle.ts +122 -0
- package/src/web/shell.ts +643 -0
- package/src/web/text-input.ts +248 -0
- package/src/web/worker.ts +1002 -0
- package/types/bindings.json +13654 -0
- package/types/index.d.ts +20090 -0
- package/vendor/basis/LICENSE +201 -0
- package/vendor/basis/NOTICE +15 -0
- package/vendor/basis/README.md +18 -0
- package/vendor/basis/basis_transcoder.js +19 -0
- package/vendor/basis/basis_transcoder.wasm +0 -0
- package/README.md +0 -3
|
@@ -0,0 +1,857 @@
|
|
|
1
|
+
<!-- Generated from crates/og-api/api.ogt by `og api gen`. Do not edit: `og api check` fails on any difference; change api.ogt and regenerate. -->
|
|
2
|
+
|
|
3
|
+
# The `platform` module
|
|
4
|
+
|
|
5
|
+
Platform services as host capabilities (docs/design.md §2.8): cloud store, leaderboards, telemetry, Origin Point and AI marks. Game code names a method and its arguments, never a credential, a URL or a cookie: the host owns them. On the web the shell forwards each call to the Player through origin-checked postMessage (Player protocol 2, docs/web-export.md); natively the host answers from a local JSON store (`og run --platform-store`, default `<project>/.og/platform.json`).
|
|
6
|
+
|
|
7
|
+
Calls are asynchronous: each returns a request number at once, and the answer arrives at the start of a later tick, when og.platform sends PlatformAnswered; read it with og.platform.result. Answers are host input, like key presses: the probe's `dump_platform` lists every call, its arguments, its answer and the ticks.
|
|
8
|
+
|
|
9
|
+
Errors carry the Player's stable codes: offline, timeout, invalid, unauthorized, not_found, conflict, too_large, rate_limited, unavailable, failed; retryable is true for offline, timeout, unavailable and rate_limited.
|
|
10
|
+
|
|
11
|
+
- **TypeScript**: functions are the namespace `og.platform`; components, resources and events are tokens on `og`.
|
|
12
|
+
- **Publish builds**: kept (members may override).
|
|
13
|
+
- **Skill**: `og-platform-sdk`, which teaches the module (how much of it to use, and how to prove it).
|
|
14
|
+
- **Index**: [every module and name](index.md).
|
|
15
|
+
|
|
16
|
+
```ogt
|
|
17
|
+
module platform {
|
|
18
|
+
# declarations follow, each quoted below
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
<sub>`api.ogt` line 7489</sub>
|
|
22
|
+
|
|
23
|
+
## Contents
|
|
24
|
+
|
|
25
|
+
| Name | Kind | Summary |
|
|
26
|
+
|---|---|---|
|
|
27
|
+
| [`PlatformOrder`](#type-PlatformOrder) | enum | How a leaderboard sorts; the first submission to a board fixes it. |
|
|
28
|
+
| [`og.PlatformAnswered`](#record-PlatformAnswered) | event | An answer arrived: sent by og.platform at the start of the tick it was applied, read by systems the tick after (og.platform.result has it at once). |
|
|
29
|
+
| [`StoreSetDesc`](#type-StoreSetDesc) | desc struct | A write to the store. |
|
|
30
|
+
| [`LeaderboardSubmitDesc`](#type-LeaderboardSubmitDesc) | desc struct | A score. |
|
|
31
|
+
| [`LeaderboardQueryDesc`](#type-LeaderboardQueryDesc) | desc struct | Which entries. |
|
|
32
|
+
| [`PointDesc`](#type-PointDesc) | desc struct | Origin Point for something the player did. |
|
|
33
|
+
| [`AiMarkDesc`](#type-AiMarkDesc) | desc struct | Marks content the game shows as generated by AI, for the platform's disclosure. |
|
|
34
|
+
| [`SaveSlotDesc`](#type-SaveSlotDesc) | desc struct | A save slot: a long text (a world.snapshot()) kept across as many store keys as it needs. |
|
|
35
|
+
| [`LoadSlotDesc`](#type-LoadSlotDesc) | desc struct | Which slot to read, and how much of it. |
|
|
36
|
+
| [`PlatformError`](#type-PlatformError) | struct | Why a call failed. |
|
|
37
|
+
| [`PlatformResult`](#type-PlatformResult) | struct | The answer to one call. |
|
|
38
|
+
| [`PlatformInfo`](#type-PlatformInfo) | struct | What answers platform calls here. |
|
|
39
|
+
| [`og.platform.storeGet`](#fn-storeGet) | function | Read one key of the player's store for this game. |
|
|
40
|
+
| [`og.platform.storeSet`](#fn-storeSet) | function | Write one key of the player's store for this game; with a revision, only if nobody wrote it since (another device, another tab). |
|
|
41
|
+
| [`og.platform.storeList`](#fn-storeList) | function | The keys of the player's store and their revisions. |
|
|
42
|
+
| [`og.platform.leaderboardSubmit`](#fn-leaderboardSubmit) | function | Submit a score; the board keeps the player's best. |
|
|
43
|
+
| [`og.platform.leaderboardTop`](#fn-leaderboardTop) | function | The best entries of a board, and the player's own. |
|
|
44
|
+
| [`og.platform.leaderboardAround`](#fn-leaderboardAround) | function | The entries around the player's rank. |
|
|
45
|
+
| [`og.platform.telemetry`](#fn-telemetry) | function | Record a game event for the game's analytics. |
|
|
46
|
+
| [`og.platform.point`](#fn-point) | function | Ask for Origin Point for something the player did. |
|
|
47
|
+
| [`og.platform.aiMark`](#fn-aiMark) | function | Disclose AI-generated content the game shows. |
|
|
48
|
+
| [`og.platform.loadSettings`](#fn-loadSettings) | function | Ask for the game's saved settings (volume, controls, language): store.get of the key `og.settings`. Where the Player has no store, or is offline, the shell answers from the browser's own storage; natively, from the local store. |
|
|
49
|
+
| [`og.platform.saveSettings`](#fn-saveSettings) | function | Save the game's settings under `og.settings` (the last save wins), with the same local fallback as loadSettings. |
|
|
50
|
+
| [`og.platform.saveSlot`](#fn-saveSlot) | function | Save a long text under a slot, in as many store keys as it needs: a mid-size 3D world's snapshot is over a key's 64 KiB (examples/kestrel-stair's 93 entities: about 78 KB). The parts go in the bank of keys the slot's last save did not use (`<slot>.a*` or `<slot>.b*`), then the manifest (`<slot>`: the bank, the part count, the length, a checksum and `meta`) is written last, at the revision read before: so a save cut short leaves the last one whole, and another device's save landing meanwhile is a conflict, never a mix. One request for all of it; a slot takes at most 17 of the player's 64 keys for this game. og-game §17. |
|
|
51
|
+
| [`og.platform.loadSlot`](#fn-loadSlot) | function | Read a slot saveSlot wrote: its manifest, then its parts, joined and checked against the manifest's length and checksum. One request for all of it. |
|
|
52
|
+
| [`og.platform.result`](#fn-result) | function | The answer to a call, once it arrived. |
|
|
53
|
+
| [`og.platform.info`](#fn-info) | function | What answers platform calls here, and what it answers. |
|
|
54
|
+
| [`og.platform.now`](#fn-now) | function | The host's wall-clock time, UTC milliseconds since 1970, as of this tick: what the host last told the engine (when it attached, and with every answer, applied at a tick's start like the answers) moved on by the ticks since. The one wall-clock read game code may make: it is host input, so a replay with the same answers gives the same values. Use it to know how long the game was closed (a save's time against a launch's), never to time play (that is og.Time). |
|
|
55
|
+
|
|
56
|
+
## Functions
|
|
57
|
+
|
|
58
|
+
<a id="fn-storeGet"></a>
|
|
59
|
+
|
|
60
|
+
### `og.platform.storeGet`
|
|
61
|
+
|
|
62
|
+
Read one key of the player's store for this game.
|
|
63
|
+
|
|
64
|
+
```ts
|
|
65
|
+
og.platform.storeGet(world: World, key: string): Result<number>
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
| Parameter | Type | Optional | Doc |
|
|
69
|
+
|---|---|---|---|
|
|
70
|
+
| `world` | `World` | no | The world. |
|
|
71
|
+
| `key` | `string` | no | The key. |
|
|
72
|
+
|
|
73
|
+
**Returns** `Result<number>`: Refused for a malformed key. The answer's data is `{ key, value, revision }` (value null and revision 0 for a key never written).
|
|
74
|
+
|
|
75
|
+
Binding symbol `og_platform_store_get` · publish builds: kept
|
|
76
|
+
|
|
77
|
+
```ogt
|
|
78
|
+
fn storeGet {
|
|
79
|
+
doc "Read one key of the player's store for this game."
|
|
80
|
+
param world World "The world."
|
|
81
|
+
param key String "The key."
|
|
82
|
+
returns Result.u32 "Refused for a malformed key. The answer's data is `{ key, value, revision }` (value null and revision 0 for a key never written)."
|
|
83
|
+
}
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
<sub>`api.ogt` line 7604</sub>
|
|
87
|
+
|
|
88
|
+
<a id="fn-storeSet"></a>
|
|
89
|
+
|
|
90
|
+
### `og.platform.storeSet`
|
|
91
|
+
|
|
92
|
+
Write one key of the player's store for this game; with a revision, only if nobody wrote it since (another device, another tab).
|
|
93
|
+
|
|
94
|
+
```ts
|
|
95
|
+
og.platform.storeSet(world: World, desc?: StoreSetDesc): Result<number>
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
| Parameter | Type | Optional | Doc |
|
|
99
|
+
|---|---|---|---|
|
|
100
|
+
| `world` | `World` | no | The world. |
|
|
101
|
+
| `desc` | `StoreSetDesc` | yes | The key, the value and the revision it must be at. |
|
|
102
|
+
|
|
103
|
+
**Returns** `Result<number>`: Refused for a malformed key or a value over 64 KiB. The answer's data is `{ key, revision }` (the new revision); `conflict` when the key moved past desc.revision.
|
|
104
|
+
|
|
105
|
+
Binding symbol `og_platform_store_set` · publish builds: kept
|
|
106
|
+
|
|
107
|
+
```ogt
|
|
108
|
+
fn storeSet {
|
|
109
|
+
doc "Write one key of the player's store for this game; with a revision, only if nobody wrote it since (another device, another tab)."
|
|
110
|
+
param world World "The world."
|
|
111
|
+
param desc StoreSetDesc "The key, the value and the revision it must be at."
|
|
112
|
+
returns Result.u32 "Refused for a malformed key or a value over 64 KiB. The answer's data is `{ key, revision }` (the new revision); `conflict` when the key moved past desc.revision."
|
|
113
|
+
}
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
<sub>`api.ogt` line 7611</sub>
|
|
117
|
+
|
|
118
|
+
<a id="fn-storeList"></a>
|
|
119
|
+
|
|
120
|
+
### `og.platform.storeList`
|
|
121
|
+
|
|
122
|
+
The keys of the player's store and their revisions.
|
|
123
|
+
|
|
124
|
+
```ts
|
|
125
|
+
og.platform.storeList(world: World): number
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
| Parameter | Type | Optional | Doc |
|
|
129
|
+
|---|---|---|---|
|
|
130
|
+
| `world` | `World` | no | The world. |
|
|
131
|
+
|
|
132
|
+
**Returns** `number`: The answer's data is `{ keys: [{ key, revision }] }`.
|
|
133
|
+
|
|
134
|
+
Binding symbol `og_platform_store_list` · publish builds: kept
|
|
135
|
+
|
|
136
|
+
```ogt
|
|
137
|
+
fn storeList {
|
|
138
|
+
doc "The keys of the player's store and their revisions."
|
|
139
|
+
param world World "The world."
|
|
140
|
+
returns u32 "The answer's data is `{ keys: [{ key, revision }] }`."
|
|
141
|
+
}
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
<sub>`api.ogt` line 7618</sub>
|
|
145
|
+
|
|
146
|
+
<a id="fn-leaderboardSubmit"></a>
|
|
147
|
+
|
|
148
|
+
### `og.platform.leaderboardSubmit`
|
|
149
|
+
|
|
150
|
+
Submit a score; the board keeps the player's best.
|
|
151
|
+
|
|
152
|
+
```ts
|
|
153
|
+
og.platform.leaderboardSubmit(world: World, desc?: LeaderboardSubmitDesc): Result<number>
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
| Parameter | Type | Optional | Doc |
|
|
157
|
+
|---|---|---|---|
|
|
158
|
+
| `world` | `World` | no | The world. |
|
|
159
|
+
| `desc` | `LeaderboardSubmitDesc` | yes | The board, the score and its order. |
|
|
160
|
+
|
|
161
|
+
**Returns** `Result<number>`: Refused for a score that is not finite. The answer's data is `{ board, rank, best }`, or `{ board, rank: null, queued: true }` while offline.
|
|
162
|
+
|
|
163
|
+
Binding symbol `og_platform_leaderboard_submit` · publish builds: kept
|
|
164
|
+
|
|
165
|
+
```ogt
|
|
166
|
+
fn leaderboardSubmit {
|
|
167
|
+
doc "Submit a score; the board keeps the player's best."
|
|
168
|
+
param world World "The world."
|
|
169
|
+
param desc LeaderboardSubmitDesc "The board, the score and its order."
|
|
170
|
+
returns Result.u32 "Refused for a score that is not finite. The answer's data is `{ board, rank, best }`, or `{ board, rank: null, queued: true }` while offline."
|
|
171
|
+
}
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
<sub>`api.ogt` line 7624</sub>
|
|
175
|
+
|
|
176
|
+
<a id="fn-leaderboardTop"></a>
|
|
177
|
+
|
|
178
|
+
### `og.platform.leaderboardTop`
|
|
179
|
+
|
|
180
|
+
The best entries of a board, and the player's own.
|
|
181
|
+
|
|
182
|
+
```ts
|
|
183
|
+
og.platform.leaderboardTop(world: World, desc?: LeaderboardQueryDesc): number
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
| Parameter | Type | Optional | Doc |
|
|
187
|
+
|---|---|---|---|
|
|
188
|
+
| `world` | `World` | no | The world. |
|
|
189
|
+
| `desc` | `LeaderboardQueryDesc` | yes | The board and how many. |
|
|
190
|
+
|
|
191
|
+
**Returns** `number`: The answer's data is `{ board, order, entries: [{ rank, name, score, me }], me }`.
|
|
192
|
+
|
|
193
|
+
Binding symbol `og_platform_leaderboard_top` · publish builds: kept
|
|
194
|
+
|
|
195
|
+
```ogt
|
|
196
|
+
fn leaderboardTop {
|
|
197
|
+
doc "The best entries of a board, and the player's own."
|
|
198
|
+
param world World "The world."
|
|
199
|
+
param desc LeaderboardQueryDesc "The board and how many."
|
|
200
|
+
returns u32 "The answer's data is `{ board, order, entries: [{ rank, name, score, me }], me }`."
|
|
201
|
+
}
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
<sub>`api.ogt` line 7631</sub>
|
|
205
|
+
|
|
206
|
+
<a id="fn-leaderboardAround"></a>
|
|
207
|
+
|
|
208
|
+
### `og.platform.leaderboardAround`
|
|
209
|
+
|
|
210
|
+
The entries around the player's rank.
|
|
211
|
+
|
|
212
|
+
```ts
|
|
213
|
+
og.platform.leaderboardAround(world: World, desc?: LeaderboardQueryDesc): number
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
| Parameter | Type | Optional | Doc |
|
|
217
|
+
|---|---|---|---|
|
|
218
|
+
| `world` | `World` | no | The world. |
|
|
219
|
+
| `desc` | `LeaderboardQueryDesc` | yes | The board and how many around the player. |
|
|
220
|
+
|
|
221
|
+
**Returns** `number`: The answer's data is the leaderboardTop shape with the entries around the player's rank.
|
|
222
|
+
|
|
223
|
+
Binding symbol `og_platform_leaderboard_around` · publish builds: kept
|
|
224
|
+
|
|
225
|
+
```ogt
|
|
226
|
+
fn leaderboardAround {
|
|
227
|
+
doc "The entries around the player's rank."
|
|
228
|
+
param world World "The world."
|
|
229
|
+
param desc LeaderboardQueryDesc "The board and how many around the player."
|
|
230
|
+
returns u32 "The answer's data is the leaderboardTop shape with the entries around the player's rank."
|
|
231
|
+
}
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
<sub>`api.ogt` line 7638</sub>
|
|
235
|
+
|
|
236
|
+
<a id="fn-telemetry"></a>
|
|
237
|
+
|
|
238
|
+
### `og.platform.telemetry`
|
|
239
|
+
|
|
240
|
+
Record a game event for the game's analytics.
|
|
241
|
+
|
|
242
|
+
```ts
|
|
243
|
+
og.platform.telemetry(world: World, name: string, attrs?: unknown): Result<void>
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
| Parameter | Type | Optional | Doc |
|
|
247
|
+
|---|---|---|---|
|
|
248
|
+
| `world` | `World` | no | The world. |
|
|
249
|
+
| `name` | `string` | no | The event: `level.started`, `level.completed`, `boss.defeated` (letters, digits, `.`, `_`; the Player files it as `game.custom.<name>`). |
|
|
250
|
+
| `attrs` | `unknown` | yes | Its attributes: an object of at most 16 strings (up to 512 characters), numbers, booleans or null, keys a lowercase letter then letters, digits and `_`. |
|
|
251
|
+
|
|
252
|
+
**Returns** `Result<void>`: Refused for a malformed name or attributes. Fire and forget: nothing answers.
|
|
253
|
+
|
|
254
|
+
Binding symbol `og_platform_telemetry` · publish builds: kept
|
|
255
|
+
|
|
256
|
+
```ogt
|
|
257
|
+
fn telemetry {
|
|
258
|
+
doc "Record a game event for the game's analytics."
|
|
259
|
+
param world World "The world."
|
|
260
|
+
param name String "The event: `level.started`, `level.completed`, `boss.defeated` (letters, digits, `.`, `_`; the Player files it as `game.custom.<name>`)."
|
|
261
|
+
param attrs Json "Its attributes: an object of at most 16 strings (up to 512 characters), numbers, booleans or null, keys a lowercase letter then letters, digits and `_`." {
|
|
262
|
+
optional true
|
|
263
|
+
}
|
|
264
|
+
returns Result.Void "Refused for a malformed name or attributes. Fire and forget: nothing answers."
|
|
265
|
+
}
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
<sub>`api.ogt` line 7645</sub>
|
|
269
|
+
|
|
270
|
+
<a id="fn-point"></a>
|
|
271
|
+
|
|
272
|
+
### `og.platform.point`
|
|
273
|
+
|
|
274
|
+
Ask for Origin Point for something the player did.
|
|
275
|
+
|
|
276
|
+
```ts
|
|
277
|
+
og.platform.point(world: World, desc?: PointDesc): Result<number>
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
| Parameter | Type | Optional | Doc |
|
|
281
|
+
|---|---|---|---|
|
|
282
|
+
| `world` | `World` | no | The world. |
|
|
283
|
+
| `desc` | `PointDesc` | yes | Why and how many. |
|
|
284
|
+
|
|
285
|
+
**Returns** `Result<number>`: Refused for a reason outside 1 to 64 of letters, digits, `.`, `_` and `-`. The answer's data is `{ granted, balance }`; under a Player today always `{ granted: 0, balance: null }` (the platform grants nothing until a release carries an approved point policy), locally the amount asked.
|
|
286
|
+
|
|
287
|
+
Binding symbol `og_platform_point` · publish builds: kept
|
|
288
|
+
|
|
289
|
+
```ogt
|
|
290
|
+
fn point {
|
|
291
|
+
doc "Ask for Origin Point for something the player did."
|
|
292
|
+
param world World "The world."
|
|
293
|
+
param desc PointDesc "Why and how many."
|
|
294
|
+
returns Result.u32 "Refused for a reason outside 1 to 64 of letters, digits, `.`, `_` and `-`. The answer's data is `{ granted, balance }`; under a Player today always `{ granted: 0, balance: null }` (the platform grants nothing until a release carries an approved point policy), locally the amount asked."
|
|
295
|
+
}
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
<sub>`api.ogt` line 7655</sub>
|
|
299
|
+
|
|
300
|
+
<a id="fn-aiMark"></a>
|
|
301
|
+
|
|
302
|
+
### `og.platform.aiMark`
|
|
303
|
+
|
|
304
|
+
Disclose AI-generated content the game shows.
|
|
305
|
+
|
|
306
|
+
```ts
|
|
307
|
+
og.platform.aiMark(world: World, desc?: AiMarkDesc): Result<number>
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
| Parameter | Type | Optional | Doc |
|
|
311
|
+
|---|---|---|---|
|
|
312
|
+
| `world` | `World` | no | The world. |
|
|
313
|
+
| `desc` | `AiMarkDesc` | yes | What was generated. |
|
|
314
|
+
|
|
315
|
+
**Returns** `Result<number>`: Refused for an empty kind or label. The answer's data is `{ marked: true }`.
|
|
316
|
+
|
|
317
|
+
Binding symbol `og_platform_ai_mark` · publish builds: kept
|
|
318
|
+
|
|
319
|
+
```ogt
|
|
320
|
+
fn aiMark {
|
|
321
|
+
doc "Disclose AI-generated content the game shows."
|
|
322
|
+
param world World "The world."
|
|
323
|
+
param desc AiMarkDesc "What was generated."
|
|
324
|
+
returns Result.u32 "Refused for an empty kind or label. The answer's data is `{ marked: true }`."
|
|
325
|
+
}
|
|
326
|
+
```
|
|
327
|
+
|
|
328
|
+
<sub>`api.ogt` line 7662</sub>
|
|
329
|
+
|
|
330
|
+
<a id="fn-loadSettings"></a>
|
|
331
|
+
|
|
332
|
+
### `og.platform.loadSettings`
|
|
333
|
+
|
|
334
|
+
Ask for the game's saved settings (volume, controls, language): store.get of the key `og.settings`. Where the Player has no store, or is offline, the shell answers from the browser's own storage; natively, from the local store.
|
|
335
|
+
|
|
336
|
+
```ts
|
|
337
|
+
og.platform.loadSettings(world: World): number
|
|
338
|
+
```
|
|
339
|
+
|
|
340
|
+
| Parameter | Type | Optional | Doc |
|
|
341
|
+
|---|---|---|---|
|
|
342
|
+
| `world` | `World` | no | The world. |
|
|
343
|
+
|
|
344
|
+
**Returns** `number`: The request; its answer's data is `{ key, value, revision }` (value null before the first save).
|
|
345
|
+
|
|
346
|
+
Binding symbol `og_platform_load_settings` · publish builds: kept
|
|
347
|
+
|
|
348
|
+
```ogt
|
|
349
|
+
fn loadSettings {
|
|
350
|
+
doc "Ask for the game's saved settings (volume, controls, language): store.get of the key `og.settings`. Where the Player has no store, or is offline, the shell answers from the browser's own storage; natively, from the local store."
|
|
351
|
+
param world World "The world."
|
|
352
|
+
returns u32 "The request; its answer's data is `{ key, value, revision }` (value null before the first save)."
|
|
353
|
+
}
|
|
354
|
+
```
|
|
355
|
+
|
|
356
|
+
<sub>`api.ogt` line 7669</sub>
|
|
357
|
+
|
|
358
|
+
<a id="fn-saveSettings"></a>
|
|
359
|
+
|
|
360
|
+
### `og.platform.saveSettings`
|
|
361
|
+
|
|
362
|
+
Save the game's settings under `og.settings` (the last save wins), with the same local fallback as loadSettings.
|
|
363
|
+
|
|
364
|
+
```ts
|
|
365
|
+
og.platform.saveSettings(world: World, value: unknown): Result<number>
|
|
366
|
+
```
|
|
367
|
+
|
|
368
|
+
| Parameter | Type | Optional | Doc |
|
|
369
|
+
|---|---|---|---|
|
|
370
|
+
| `world` | `World` | no | The world. |
|
|
371
|
+
| `value` | `unknown` | no | The settings: an object, at most 64 KiB encoded. |
|
|
372
|
+
|
|
373
|
+
**Returns** `Result<number>`: Refused for a value that is not an object or is too large.
|
|
374
|
+
|
|
375
|
+
Binding symbol `og_platform_save_settings` · publish builds: kept
|
|
376
|
+
|
|
377
|
+
```ogt
|
|
378
|
+
fn saveSettings {
|
|
379
|
+
doc "Save the game's settings under `og.settings` (the last save wins), with the same local fallback as loadSettings."
|
|
380
|
+
param world World "The world."
|
|
381
|
+
param value Json "The settings: an object, at most 64 KiB encoded."
|
|
382
|
+
returns Result.u32 "Refused for a value that is not an object or is too large."
|
|
383
|
+
}
|
|
384
|
+
```
|
|
385
|
+
|
|
386
|
+
<sub>`api.ogt` line 7675</sub>
|
|
387
|
+
|
|
388
|
+
<a id="fn-saveSlot"></a>
|
|
389
|
+
|
|
390
|
+
### `og.platform.saveSlot`
|
|
391
|
+
|
|
392
|
+
Save a long text under a slot, in as many store keys as it needs: a mid-size 3D world's snapshot is over a key's 64 KiB (examples/kestrel-stair's 93 entities: about 78 KB). The parts go in the bank of keys the slot's last save did not use (`<slot>.a*` or `<slot>.b*`), then the manifest (`<slot>`: the bank, the part count, the length, a checksum and `meta`) is written last, at the revision read before: so a save cut short leaves the last one whole, and another device's save landing meanwhile is a conflict, never a mix. One request for all of it; a slot takes at most 17 of the player's 64 keys for this game. og-game §17.
|
|
393
|
+
|
|
394
|
+
```ts
|
|
395
|
+
og.platform.saveSlot(world: World, desc?: SaveSlotDesc): Result<number>
|
|
396
|
+
```
|
|
397
|
+
|
|
398
|
+
| Parameter | Type | Optional | Doc |
|
|
399
|
+
|---|---|---|---|
|
|
400
|
+
| `world` | `World` | no | The world. |
|
|
401
|
+
| `desc` | `SaveSlotDesc` | yes | The slot, the text and what a title shows of it. |
|
|
402
|
+
|
|
403
|
+
**Returns** `Result<number>`: Refused for a malformed slot name, a text over 512 KiB or a meta over 4 KiB. The answer arrives when the manifest is written: data `{ slot, parts, bytes, revision }`; an error is the first refused part's, or the manifest's (`conflict`: another save of the slot landed meanwhile; the slot holds that one).
|
|
404
|
+
|
|
405
|
+
Binding symbol `og_platform_save_slot` · publish builds: kept
|
|
406
|
+
|
|
407
|
+
```ogt
|
|
408
|
+
fn saveSlot {
|
|
409
|
+
doc "Save a long text under a slot, in as many store keys as it needs: a mid-size 3D world's snapshot is over a key's 64 KiB (examples/kestrel-stair's 93 entities: about 78 KB). The parts go in the bank of keys the slot's last save did not use (`<slot>.a*` or `<slot>.b*`), then the manifest (`<slot>`: the bank, the part count, the length, a checksum and `meta`) is written last, at the revision read before: so a save cut short leaves the last one whole, and another device's save landing meanwhile is a conflict, never a mix. One request for all of it; a slot takes at most 17 of the player's 64 keys for this game. og-game §17."
|
|
410
|
+
param world World "The world."
|
|
411
|
+
param desc SaveSlotDesc "The slot, the text and what a title shows of it."
|
|
412
|
+
returns Result.u32 "Refused for a malformed slot name, a text over 512 KiB or a meta over 4 KiB. The answer arrives when the manifest is written: data `{ slot, parts, bytes, revision }`; an error is the first refused part's, or the manifest's (`conflict`: another save of the slot landed meanwhile; the slot holds that one)."
|
|
413
|
+
}
|
|
414
|
+
```
|
|
415
|
+
|
|
416
|
+
<sub>`api.ogt` line 7682</sub>
|
|
417
|
+
|
|
418
|
+
<a id="fn-loadSlot"></a>
|
|
419
|
+
|
|
420
|
+
### `og.platform.loadSlot`
|
|
421
|
+
|
|
422
|
+
Read a slot saveSlot wrote: its manifest, then its parts, joined and checked against the manifest's length and checksum. One request for all of it.
|
|
423
|
+
|
|
424
|
+
```ts
|
|
425
|
+
og.platform.loadSlot(world: World, desc?: LoadSlotDesc): Result<number>
|
|
426
|
+
```
|
|
427
|
+
|
|
428
|
+
| Parameter | Type | Optional | Doc |
|
|
429
|
+
|---|---|---|---|
|
|
430
|
+
| `world` | `World` | no | The world. |
|
|
431
|
+
| `desc` | `LoadSlotDesc` | yes | The slot, and whether to read its meta alone. |
|
|
432
|
+
|
|
433
|
+
**Returns** `Result<number>`: Refused for a malformed slot name. The answer's data is `{ slot, text, meta, parts, bytes, revision }`: text and meta null for a slot never saved, text null with metaOnly; `invalid` for a key that holds no slot manifest or parts that do not match it.
|
|
434
|
+
|
|
435
|
+
Binding symbol `og_platform_load_slot` · publish builds: kept
|
|
436
|
+
|
|
437
|
+
```ogt
|
|
438
|
+
fn loadSlot {
|
|
439
|
+
doc "Read a slot saveSlot wrote: its manifest, then its parts, joined and checked against the manifest's length and checksum. One request for all of it."
|
|
440
|
+
param world World "The world."
|
|
441
|
+
param desc LoadSlotDesc "The slot, and whether to read its meta alone."
|
|
442
|
+
returns Result.u32 "Refused for a malformed slot name. The answer's data is `{ slot, text, meta, parts, bytes, revision }`: text and meta null for a slot never saved, text null with metaOnly; `invalid` for a key that holds no slot manifest or parts that do not match it."
|
|
443
|
+
}
|
|
444
|
+
```
|
|
445
|
+
|
|
446
|
+
<sub>`api.ogt` line 7689</sub>
|
|
447
|
+
|
|
448
|
+
<a id="fn-result"></a>
|
|
449
|
+
|
|
450
|
+
### `og.platform.result`
|
|
451
|
+
|
|
452
|
+
The answer to a call, once it arrived.
|
|
453
|
+
|
|
454
|
+
```ts
|
|
455
|
+
og.platform.result(world: World, request: number): PlatformResult | null
|
|
456
|
+
```
|
|
457
|
+
|
|
458
|
+
| Parameter | Type | Optional | Doc |
|
|
459
|
+
|---|---|---|---|
|
|
460
|
+
| `world` | `World` | no | The world. |
|
|
461
|
+
| `request` | `number` | no | The call. |
|
|
462
|
+
|
|
463
|
+
**Returns** `PlatformResult | null`: Null while it is in flight, or for an unknown request.
|
|
464
|
+
|
|
465
|
+
Binding symbol `og_platform_result` · publish builds: kept
|
|
466
|
+
|
|
467
|
+
```ogt
|
|
468
|
+
fn result {
|
|
469
|
+
doc "The answer to a call, once it arrived."
|
|
470
|
+
param world World "The world."
|
|
471
|
+
param request u32 "The call."
|
|
472
|
+
returns Option.PlatformResult "Null while it is in flight, or for an unknown request."
|
|
473
|
+
}
|
|
474
|
+
```
|
|
475
|
+
|
|
476
|
+
<sub>`api.ogt` line 7696</sub>
|
|
477
|
+
|
|
478
|
+
<a id="fn-info"></a>
|
|
479
|
+
|
|
480
|
+
### `og.platform.info`
|
|
481
|
+
|
|
482
|
+
What answers platform calls here, and what it answers.
|
|
483
|
+
|
|
484
|
+
```ts
|
|
485
|
+
og.platform.info(world: World): PlatformInfo
|
|
486
|
+
```
|
|
487
|
+
|
|
488
|
+
| Parameter | Type | Optional | Doc |
|
|
489
|
+
|---|---|---|---|
|
|
490
|
+
| `world` | `World` | no | The world. |
|
|
491
|
+
|
|
492
|
+
**Returns** `PlatformInfo`.
|
|
493
|
+
|
|
494
|
+
Binding symbol `og_platform_info` · publish builds: kept
|
|
495
|
+
|
|
496
|
+
```ogt
|
|
497
|
+
fn info {
|
|
498
|
+
doc "What answers platform calls here, and what it answers."
|
|
499
|
+
param world World "The world."
|
|
500
|
+
returns PlatformInfo
|
|
501
|
+
}
|
|
502
|
+
```
|
|
503
|
+
|
|
504
|
+
<sub>`api.ogt` line 7703</sub>
|
|
505
|
+
|
|
506
|
+
<a id="fn-now"></a>
|
|
507
|
+
|
|
508
|
+
### `og.platform.now`
|
|
509
|
+
|
|
510
|
+
The host's wall-clock time, UTC milliseconds since 1970, as of this tick: what the host last told the engine (when it attached, and with every answer, applied at a tick's start like the answers) moved on by the ticks since. The one wall-clock read game code may make: it is host input, so a replay with the same answers gives the same values. Use it to know how long the game was closed (a save's time against a launch's), never to time play (that is og.Time).
|
|
511
|
+
|
|
512
|
+
```ts
|
|
513
|
+
og.platform.now(world: World): number
|
|
514
|
+
```
|
|
515
|
+
|
|
516
|
+
| Parameter | Type | Optional | Doc |
|
|
517
|
+
|---|---|---|---|
|
|
518
|
+
| `world` | `World` | no | The world. |
|
|
519
|
+
|
|
520
|
+
**Returns** `number`: UTC milliseconds; 0 until a host has told the time (`none`).
|
|
521
|
+
|
|
522
|
+
Binding symbol `og_platform_now` · publish builds: kept
|
|
523
|
+
|
|
524
|
+
```ogt
|
|
525
|
+
fn now {
|
|
526
|
+
doc "The host's wall-clock time, UTC milliseconds since 1970, as of this tick: what the host last told the engine (when it attached, and with every answer, applied at a tick's start like the answers) moved on by the ticks since. The one wall-clock read game code may make: it is host input, so a replay with the same answers gives the same values. Use it to know how long the game was closed (a save's time against a launch's), never to time play (that is og.Time)."
|
|
527
|
+
param world World "The world."
|
|
528
|
+
returns f64 "UTC milliseconds; 0 until a host has told the time (`none`)."
|
|
529
|
+
}
|
|
530
|
+
```
|
|
531
|
+
|
|
532
|
+
<sub>`api.ogt` line 7709</sub>
|
|
533
|
+
|
|
534
|
+
## Components, resources and events
|
|
535
|
+
|
|
536
|
+
<a id="record-PlatformAnswered"></a>
|
|
537
|
+
|
|
538
|
+
### `og.PlatformAnswered` (event)
|
|
539
|
+
|
|
540
|
+
An answer arrived: sent by og.platform at the start of the tick it was applied, read by systems the tick after (og.platform.result has it at once).
|
|
541
|
+
|
|
542
|
+
Token `og.PlatformAnswered`, registered under the schema name `og.PlatformAnswered`; its value type is `PlatformAnswered`.
|
|
543
|
+
|
|
544
|
+
| Field | Type | Default | Range | Unit | Notes | Doc |
|
|
545
|
+
|---|---|---|---|---|---|---|
|
|
546
|
+
| `request` | `number` | `0` | — | — | — | The call's request number. |
|
|
547
|
+
| `ok` | `boolean` | `false` | — | — | — | Whether it succeeded; og.platform.result has the data or the error. |
|
|
548
|
+
|
|
549
|
+
```ogt
|
|
550
|
+
event PlatformAnswered {
|
|
551
|
+
doc "An answer arrived: sent by og.platform at the start of the tick it was applied, read by systems the tick after (og.platform.result has it at once)."
|
|
552
|
+
field request u32 "The call's request number."
|
|
553
|
+
field ok bool "Whether it succeeded; og.platform.result has the data or the error."
|
|
554
|
+
}
|
|
555
|
+
```
|
|
556
|
+
|
|
557
|
+
<sub>`api.ogt` line 7501</sub>
|
|
558
|
+
|
|
559
|
+
## Types
|
|
560
|
+
|
|
561
|
+
<a id="type-PlatformOrder"></a>
|
|
562
|
+
|
|
563
|
+
### `PlatformOrder` (enum)
|
|
564
|
+
|
|
565
|
+
How a leaderboard sorts; the first submission to a board fixes it.
|
|
566
|
+
|
|
567
|
+
A string: one of the variants below. The zero value is `"desc"`.
|
|
568
|
+
|
|
569
|
+
| Variant | Doc |
|
|
570
|
+
|---|---|
|
|
571
|
+
| `"desc"` | Higher is better (scores). |
|
|
572
|
+
| `"asc"` | Lower is better (times). |
|
|
573
|
+
|
|
574
|
+
```ogt
|
|
575
|
+
enum PlatformOrder {
|
|
576
|
+
doc "How a leaderboard sorts; the first submission to a board fixes it."
|
|
577
|
+
variant desc "Higher is better (scores)."
|
|
578
|
+
variant asc "Lower is better (times)."
|
|
579
|
+
}
|
|
580
|
+
```
|
|
581
|
+
|
|
582
|
+
<sub>`api.ogt` line 7495</sub>
|
|
583
|
+
|
|
584
|
+
<a id="type-StoreSetDesc"></a>
|
|
585
|
+
|
|
586
|
+
### `StoreSetDesc` (desc struct)
|
|
587
|
+
|
|
588
|
+
A write to the store.
|
|
589
|
+
|
|
590
|
+
A desc: every field may be omitted and takes its default; `{}` is valid.
|
|
591
|
+
|
|
592
|
+
| Field | Type | Default | Range | Unit | Notes | Doc |
|
|
593
|
+
|---|---|---|---|---|---|---|
|
|
594
|
+
| `key` | `string` | `""` | — | — | — | The key: 1 to 64 of letters, digits, `.`, `_` and `-`. |
|
|
595
|
+
| `value` | `unknown` | `null` | — | — | — | Any JSON value, at most 64 KiB encoded. |
|
|
596
|
+
| `revision` | `number` | `0` | — | — | — | Write only if the key is at this revision (a conflict otherwise, whose error carries the revision the key is at now); 0 writes whatever is there (the last write wins). |
|
|
597
|
+
| `create` | `boolean` | `false` | — | — | — | Write only if the key has never been written (a conflict otherwise); revision is then ignored. |
|
|
598
|
+
|
|
599
|
+
```ogt
|
|
600
|
+
struct StoreSetDesc {
|
|
601
|
+
doc "A write to the store."
|
|
602
|
+
desc true
|
|
603
|
+
field key String "The key: 1 to 64 of letters, digits, `.`, `_` and `-`."
|
|
604
|
+
field value Json "Any JSON value, at most 64 KiB encoded."
|
|
605
|
+
field revision u32 "Write only if the key is at this revision (a conflict otherwise, whose error carries the revision the key is at now); 0 writes whatever is there (the last write wins)."
|
|
606
|
+
field create bool "Write only if the key has never been written (a conflict otherwise); revision is then ignored."
|
|
607
|
+
}
|
|
608
|
+
```
|
|
609
|
+
|
|
610
|
+
<sub>`api.ogt` line 7507</sub>
|
|
611
|
+
|
|
612
|
+
<a id="type-LeaderboardSubmitDesc"></a>
|
|
613
|
+
|
|
614
|
+
### `LeaderboardSubmitDesc` (desc struct)
|
|
615
|
+
|
|
616
|
+
A score.
|
|
617
|
+
|
|
618
|
+
A desc: every field may be omitted and takes its default; `{}` is valid.
|
|
619
|
+
|
|
620
|
+
| Field | Type | Default | Range | Unit | Notes | Doc |
|
|
621
|
+
|---|---|---|---|---|---|---|
|
|
622
|
+
| `board` | `string` | `"main"` | — | — | — | The board (default `main`). |
|
|
623
|
+
| `score` | `number` | `0` | — | — | — | The score, or a time in seconds for an ascending board. |
|
|
624
|
+
| `order` | `PlatformOrder` | `"desc"` | — | — | — | How the board sorts, fixed by its first submission. |
|
|
625
|
+
|
|
626
|
+
```ogt
|
|
627
|
+
struct LeaderboardSubmitDesc {
|
|
628
|
+
doc "A score."
|
|
629
|
+
desc true
|
|
630
|
+
field board String "The board (default `main`)." {
|
|
631
|
+
default "main"
|
|
632
|
+
}
|
|
633
|
+
field score f64 "The score, or a time in seconds for an ascending board."
|
|
634
|
+
field order PlatformOrder "How the board sorts, fixed by its first submission."
|
|
635
|
+
}
|
|
636
|
+
```
|
|
637
|
+
|
|
638
|
+
<sub>`api.ogt` line 7516</sub>
|
|
639
|
+
|
|
640
|
+
<a id="type-LeaderboardQueryDesc"></a>
|
|
641
|
+
|
|
642
|
+
### `LeaderboardQueryDesc` (desc struct)
|
|
643
|
+
|
|
644
|
+
Which entries.
|
|
645
|
+
|
|
646
|
+
A desc: every field may be omitted and takes its default; `{}` is valid.
|
|
647
|
+
|
|
648
|
+
| Field | Type | Default | Range | Unit | Notes | Doc |
|
|
649
|
+
|---|---|---|---|---|---|---|
|
|
650
|
+
| `board` | `string` | `"main"` | — | — | — | The board (default `main`). |
|
|
651
|
+
| `count` | `number` | `10` | 1 … 100 | — | — | How many entries: the top `count`, or `count` around the player. |
|
|
652
|
+
|
|
653
|
+
```ogt
|
|
654
|
+
struct LeaderboardQueryDesc {
|
|
655
|
+
doc "Which entries."
|
|
656
|
+
desc true
|
|
657
|
+
field board String "The board (default `main`)." {
|
|
658
|
+
default "main"
|
|
659
|
+
}
|
|
660
|
+
field count u32 "How many entries: the top `count`, or `count` around the player." {
|
|
661
|
+
default 10
|
|
662
|
+
min 1
|
|
663
|
+
max 100
|
|
664
|
+
}
|
|
665
|
+
}
|
|
666
|
+
```
|
|
667
|
+
|
|
668
|
+
<sub>`api.ogt` line 7526</sub>
|
|
669
|
+
|
|
670
|
+
<a id="type-PointDesc"></a>
|
|
671
|
+
|
|
672
|
+
### `PointDesc` (desc struct)
|
|
673
|
+
|
|
674
|
+
Origin Point for something the player did.
|
|
675
|
+
|
|
676
|
+
A desc: every field may be omitted and takes its default; `{}` is valid.
|
|
677
|
+
|
|
678
|
+
| Field | Type | Default | Range | Unit | Notes | Doc |
|
|
679
|
+
|---|---|---|---|---|---|---|
|
|
680
|
+
| `reason` | `string` | `""` | — | — | — | Why, as the game names it: `level.completed`, `daily.streak` (1 to 64 of letters, digits, `.`, `_` and `-`). |
|
|
681
|
+
| `amount` | `number` | `1` | 1 … 1000 | — | — | How many points the game asks for; the platform decides what it grants. |
|
|
682
|
+
|
|
683
|
+
```ogt
|
|
684
|
+
struct PointDesc {
|
|
685
|
+
doc "Origin Point for something the player did."
|
|
686
|
+
desc true
|
|
687
|
+
field reason String "Why, as the game names it: `level.completed`, `daily.streak` (1 to 64 of letters, digits, `.`, `_` and `-`)."
|
|
688
|
+
field amount u32 "How many points the game asks for; the platform decides what it grants." {
|
|
689
|
+
default 1
|
|
690
|
+
min 1
|
|
691
|
+
max 1000
|
|
692
|
+
}
|
|
693
|
+
}
|
|
694
|
+
```
|
|
695
|
+
|
|
696
|
+
<sub>`api.ogt` line 7539</sub>
|
|
697
|
+
|
|
698
|
+
<a id="type-AiMarkDesc"></a>
|
|
699
|
+
|
|
700
|
+
### `AiMarkDesc` (desc struct)
|
|
701
|
+
|
|
702
|
+
Marks content the game shows as generated by AI, for the platform's disclosure.
|
|
703
|
+
|
|
704
|
+
A desc: every field may be omitted and takes its default; `{}` is valid.
|
|
705
|
+
|
|
706
|
+
| Field | Type | Default | Range | Unit | Notes | Doc |
|
|
707
|
+
|---|---|---|---|---|---|---|
|
|
708
|
+
| `kind` | `string` | `""` | — | — | — | What: `text`, `image`, `audio`, `level`, `character` (1 to 32 of a-z, 0-9, `_` and `-`, a letter first). |
|
|
709
|
+
| `label` | `string` | `""` | — | — | — | What the player sees it as, at most 120 characters. |
|
|
710
|
+
| `model` | `string` | `""` | — | — | — | The model or service, when known (at most 80 characters). |
|
|
711
|
+
|
|
712
|
+
```ogt
|
|
713
|
+
struct AiMarkDesc {
|
|
714
|
+
doc "Marks content the game shows as generated by AI, for the platform's disclosure."
|
|
715
|
+
desc true
|
|
716
|
+
field kind String "What: `text`, `image`, `audio`, `level`, `character` (1 to 32 of a-z, 0-9, `_` and `-`, a letter first)."
|
|
717
|
+
field label String "What the player sees it as, at most 120 characters."
|
|
718
|
+
field model String "The model or service, when known (at most 80 characters)."
|
|
719
|
+
}
|
|
720
|
+
```
|
|
721
|
+
|
|
722
|
+
<sub>`api.ogt` line 7550</sub>
|
|
723
|
+
|
|
724
|
+
<a id="type-SaveSlotDesc"></a>
|
|
725
|
+
|
|
726
|
+
### `SaveSlotDesc` (desc struct)
|
|
727
|
+
|
|
728
|
+
A save slot: a long text (a world.snapshot()) kept across as many store keys as it needs.
|
|
729
|
+
|
|
730
|
+
A desc: every field may be omitted and takes its default; `{}` is valid.
|
|
731
|
+
|
|
732
|
+
| Field | Type | Default | Range | Unit | Notes | Doc |
|
|
733
|
+
|---|---|---|---|---|---|---|
|
|
734
|
+
| `slot` | `string` | `""` | — | — | — | The slot's name: 1 to 60 of letters, digits, `.`, `_` and `-` (`slot1`). Its keys are the name itself (the manifest) and `<slot>.a0`, `<slot>.a1`, ... or `<slot>.b0`, ... (the parts). |
|
|
735
|
+
| `text` | `string` | `""` | — | — | — | The text: at most 512 KiB of UTF-8 (eight parts of 64 KiB). |
|
|
736
|
+
| `meta` | `unknown` | `null` | — | — | — | What a title screen shows of the slot (`{ place, hour }`), kept in the manifest so loadSlot with metaOnly reads it without the parts: any JSON, at most 4 KiB encoded. |
|
|
737
|
+
|
|
738
|
+
```ogt
|
|
739
|
+
struct SaveSlotDesc {
|
|
740
|
+
doc "A save slot: a long text (a world.snapshot()) kept across as many store keys as it needs."
|
|
741
|
+
desc true
|
|
742
|
+
field slot String "The slot's name: 1 to 60 of letters, digits, `.`, `_` and `-` (`slot1`). Its keys are the name itself (the manifest) and `<slot>.a0`, `<slot>.a1`, ... or `<slot>.b0`, ... (the parts)."
|
|
743
|
+
field text String "The text: at most 512 KiB of UTF-8 (eight parts of 64 KiB)."
|
|
744
|
+
field meta Json "What a title screen shows of the slot (`{ place, hour }`), kept in the manifest so loadSlot with metaOnly reads it without the parts: any JSON, at most 4 KiB encoded."
|
|
745
|
+
}
|
|
746
|
+
```
|
|
747
|
+
|
|
748
|
+
<sub>`api.ogt` line 7558</sub>
|
|
749
|
+
|
|
750
|
+
<a id="type-LoadSlotDesc"></a>
|
|
751
|
+
|
|
752
|
+
### `LoadSlotDesc` (desc struct)
|
|
753
|
+
|
|
754
|
+
Which slot to read, and how much of it.
|
|
755
|
+
|
|
756
|
+
A desc: every field may be omitted and takes its default; `{}` is valid.
|
|
757
|
+
|
|
758
|
+
| Field | Type | Default | Range | Unit | Notes | Doc |
|
|
759
|
+
|---|---|---|---|---|---|---|
|
|
760
|
+
| `slot` | `string` | `""` | — | — | — | The slot's name, as saveSlot wrote it. |
|
|
761
|
+
| `metaOnly` | `boolean` | `false` | — | — | — | Read the manifest alone: the answer's text stays null (a title's Continue label, before the player asks for the world). |
|
|
762
|
+
|
|
763
|
+
```ogt
|
|
764
|
+
struct LoadSlotDesc {
|
|
765
|
+
doc "Which slot to read, and how much of it."
|
|
766
|
+
desc true
|
|
767
|
+
field slot String "The slot's name, as saveSlot wrote it."
|
|
768
|
+
field metaOnly bool "Read the manifest alone: the answer's text stays null (a title's Continue label, before the player asks for the world)."
|
|
769
|
+
}
|
|
770
|
+
```
|
|
771
|
+
|
|
772
|
+
<sub>`api.ogt` line 7566</sub>
|
|
773
|
+
|
|
774
|
+
<a id="type-PlatformError"></a>
|
|
775
|
+
|
|
776
|
+
### `PlatformError` (struct)
|
|
777
|
+
|
|
778
|
+
Why a call failed.
|
|
779
|
+
|
|
780
|
+
| Field | Type | Default | Range | Unit | Notes | Doc |
|
|
781
|
+
|---|---|---|---|---|---|---|
|
|
782
|
+
| `code` | `string` | `""` | — | — | — | offline, timeout, invalid, unauthorized, not_found, conflict, too_large, rate_limited, unavailable or failed. |
|
|
783
|
+
| `message` | `string` | `""` | — | — | — | What happened, in words. |
|
|
784
|
+
| `retryable` | `boolean` | `false` | — | — | — | Whether the same call may succeed later. |
|
|
785
|
+
| `revision` | `number` | `0` | — | — | — | For a conflict of a conditional write: the revision the key is at now (read it again, merge, write at it); 0 otherwise. |
|
|
786
|
+
|
|
787
|
+
```ogt
|
|
788
|
+
struct PlatformError {
|
|
789
|
+
doc "Why a call failed."
|
|
790
|
+
field code String "offline, timeout, invalid, unauthorized, not_found, conflict, too_large, rate_limited, unavailable or failed."
|
|
791
|
+
field message String "What happened, in words."
|
|
792
|
+
field retryable bool "Whether the same call may succeed later."
|
|
793
|
+
field revision u32 "For a conflict of a conditional write: the revision the key is at now (read it again, merge, write at it); 0 otherwise."
|
|
794
|
+
}
|
|
795
|
+
```
|
|
796
|
+
|
|
797
|
+
<sub>`api.ogt` line 7573</sub>
|
|
798
|
+
|
|
799
|
+
<a id="type-PlatformResult"></a>
|
|
800
|
+
|
|
801
|
+
### `PlatformResult` (struct)
|
|
802
|
+
|
|
803
|
+
The answer to one call.
|
|
804
|
+
|
|
805
|
+
| Field | Type | Default | Range | Unit | Notes | Doc |
|
|
806
|
+
|---|---|---|---|---|---|---|
|
|
807
|
+
| `request` | `number` | `0` | — | — | — | The call's request number. |
|
|
808
|
+
| `method` | `string` | `""` | — | — | — | Its method, such as `store.get`. |
|
|
809
|
+
| `ok` | `boolean` | `false` | — | — | — | Whether it succeeded. |
|
|
810
|
+
| `data` | `unknown` | `null` | — | — | — | The answer (see each function); null on failure. |
|
|
811
|
+
| `error` | `PlatformError` | `{ code: "", message: "", retryable: false, revision: 0 }` | — | — | optional | Why it failed. |
|
|
812
|
+
| `tick` | `number` | `0` | — | — | — | The tick it was answered at. |
|
|
813
|
+
| `time` | `number` | `0` | — | `ms` | — | The host's clock when it answered, UTC milliseconds since 1970 (PlatformInfo.clock says whose); 0 when the host gave none. |
|
|
814
|
+
|
|
815
|
+
```ogt
|
|
816
|
+
struct PlatformResult {
|
|
817
|
+
doc "The answer to one call."
|
|
818
|
+
field request u32 "The call's request number."
|
|
819
|
+
field method String "Its method, such as `store.get`."
|
|
820
|
+
field ok bool "Whether it succeeded."
|
|
821
|
+
field data Json "The answer (see each function); null on failure."
|
|
822
|
+
field error PlatformError "Why it failed." {
|
|
823
|
+
optional true
|
|
824
|
+
}
|
|
825
|
+
field tick u32 "The tick it was answered at."
|
|
826
|
+
field time f64 "The host's clock when it answered, UTC milliseconds since 1970 (PlatformInfo.clock says whose); 0 when the host gave none." {
|
|
827
|
+
unit ms
|
|
828
|
+
}
|
|
829
|
+
}
|
|
830
|
+
```
|
|
831
|
+
|
|
832
|
+
<sub>`api.ogt` line 7581</sub>
|
|
833
|
+
|
|
834
|
+
<a id="type-PlatformInfo"></a>
|
|
835
|
+
|
|
836
|
+
### `PlatformInfo` (struct)
|
|
837
|
+
|
|
838
|
+
What answers platform calls here.
|
|
839
|
+
|
|
840
|
+
| Field | Type | Default | Range | Unit | Notes | Doc |
|
|
841
|
+
|---|---|---|---|---|---|---|
|
|
842
|
+
| `host` | `string` | `""` | — | — | — | `player` (a Player frames the game), `local` (the native host's JSON store or the browser's own storage) or `none`. |
|
|
843
|
+
| `capabilities` | `readonly string[]` | `[]` | — | — | — | The methods it answers: store.get, store.set, store.list, leaderboard.submit, leaderboard.top, leaderboard.around, telemetry, point, ai.mark. |
|
|
844
|
+
| `pending` | `number` | `0` | — | — | — | Calls not answered yet. |
|
|
845
|
+
| `clock` | `string` | `""` | — | — | — | Whose clock og.platform.now and the answers' `time` read: `player` (the Player's answers carry its time), `browser` (the web host's own clock: the Player gives no time yet, docs/platform-asks.md), `system` (the native host's system clock), `fixed` (`og run --clock` and playtests: a clock that starts where it is told and moves with the ticks) or `none`. |
|
|
846
|
+
|
|
847
|
+
```ogt
|
|
848
|
+
struct PlatformInfo {
|
|
849
|
+
doc "What answers platform calls here."
|
|
850
|
+
field host String "`player` (a Player frames the game), `local` (the native host's JSON store or the browser's own storage) or `none`."
|
|
851
|
+
field capabilities List.String "The methods it answers: store.get, store.set, store.list, leaderboard.submit, leaderboard.top, leaderboard.around, telemetry, point, ai.mark."
|
|
852
|
+
field pending u32 "Calls not answered yet."
|
|
853
|
+
field clock String "Whose clock og.platform.now and the answers' `time` read: `player` (the Player's answers carry its time), `browser` (the web host's own clock: the Player gives no time yet, docs/platform-asks.md), `system` (the native host's system clock), `fixed` (`og run --clock` and playtests: a clock that starts where it is told and moves with the ticks) or `none`."
|
|
854
|
+
}
|
|
855
|
+
```
|
|
856
|
+
|
|
857
|
+
<sub>`api.ogt` line 7596</sub>
|