@origingame/engine 0.2.0 → 0.3.0

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.
Files changed (107) hide show
  1. package/bin/og.mjs +1 -1
  2. package/dist/web/origin-engine.d.ts +219 -5
  3. package/dist/web/origin-engine.js +1344 -125
  4. package/dist/web/origin-engine_bg.wasm +0 -0
  5. package/dist/web/origin-engine_bg.wasm.d.ts +68 -3
  6. package/dist/web-publish/origin-engine-lanes.js +1007 -22
  7. package/dist/web-publish/origin-engine-lanes_bg.wasm +0 -0
  8. package/dist/web-publish/origin-engine.d.ts +162 -5
  9. package/dist/web-publish/origin-engine.js +1004 -19
  10. package/dist/web-publish/origin-engine_bg.wasm +0 -0
  11. package/dist/web-publish/origin-engine_bg.wasm.d.ts +52 -3
  12. package/dist/web-publish-2d/origin-engine-lanes.js +1007 -22
  13. package/dist/web-publish-2d/origin-engine-lanes_bg.wasm +0 -0
  14. package/dist/web-publish-2d/origin-engine.d.ts +162 -5
  15. package/dist/web-publish-2d/origin-engine.js +1004 -19
  16. package/dist/web-publish-2d/origin-engine_bg.wasm +0 -0
  17. package/dist/web-publish-2d/origin-engine_bg.wasm.d.ts +52 -3
  18. package/knowledge/looks/catalogue.json +40 -40
  19. package/knowledge/package.json +1 -1
  20. package/knowledge/scaffold/distribution.json +14 -0
  21. package/knowledge/scaffold/origin-engine.json +2 -2
  22. package/knowledge/scaffold/template/README.md +2 -1
  23. package/knowledge/scaffold/template/assets/audio/sting.ogt +10 -0
  24. package/knowledge/scaffold/template/assets/timelines/intro.ogt +101 -0
  25. package/knowledge/scaffold/template/assets/timelines/narration.srt +11 -0
  26. package/knowledge/scaffold/template/host.d.ts +46 -0
  27. package/knowledge/scaffold/template/package.json +1 -1
  28. package/knowledge/scaffold/template/project.ogt +1 -1
  29. package/knowledge/scaffold/template/src/main.ts +1 -1
  30. package/knowledge/scaffold/template/tests/frames.ts +134 -0
  31. package/knowledge/scaffold/template/tests/intro.og.ts +65 -0
  32. package/knowledge/scaffold/template/tests/smoke.og.ts +30 -36
  33. package/knowledge/scaffold/template/tsconfig.json +1 -1
  34. package/knowledge/scripts/mount.ts +2 -1
  35. package/knowledge/scripts/validate.ts +19 -10
  36. package/knowledge/skills/og-build/SKILL.md +8 -5
  37. package/knowledge/skills/og-core/SKILL.md +11 -0
  38. package/knowledge/skills/og-game/SKILL.md +877 -8
  39. package/knowledge/skills/og-platform-sdk/SKILL.md +1 -0
  40. package/knowledge/skills/og-taste/SKILL.md +82 -73
  41. package/knowledge/skills/og-ui/SKILL.md +65 -50
  42. package/knowledge/wiki/ai.md +20 -20
  43. package/knowledge/wiki/anim.md +384 -41
  44. package/knowledge/wiki/atmosphere.md +36 -13
  45. package/knowledge/wiki/audio.md +18 -18
  46. package/knowledge/wiki/camera.md +19 -13
  47. package/knowledge/wiki/commands.md +19 -13
  48. package/knowledge/wiki/debug.md +414 -0
  49. package/knowledge/wiki/game.md +8 -8
  50. package/knowledge/wiki/i18n.md +7 -7
  51. package/knowledge/wiki/index.md +262 -7
  52. package/knowledge/wiki/input.md +47 -47
  53. package/knowledge/wiki/load.md +236 -68
  54. package/knowledge/wiki/math.md +2607 -0
  55. package/knowledge/wiki/nav.md +34 -34
  56. package/knowledge/wiki/net.md +340 -0
  57. package/knowledge/wiki/path.md +402 -0
  58. package/knowledge/wiki/physics.md +95 -95
  59. package/knowledge/wiki/platform.md +463 -29
  60. package/knowledge/wiki/probe.md +681 -67
  61. package/knowledge/wiki/reflect.md +15 -15
  62. package/knowledge/wiki/render.md +3893 -1896
  63. package/knowledge/wiki/rng.md +14 -14
  64. package/knowledge/wiki/stream.md +15 -15
  65. package/knowledge/wiki/system.md +8 -8
  66. package/knowledge/wiki/systems.md +2 -2
  67. package/knowledge/wiki/terrain.md +19 -19
  68. package/knowledge/wiki/tilemap.md +13 -13
  69. package/knowledge/wiki/time.md +4 -4
  70. package/knowledge/wiki/timeline.md +396 -0
  71. package/knowledge/wiki/transform.md +8 -8
  72. package/knowledge/wiki/tween.md +17 -17
  73. package/knowledge/wiki/ui.md +559 -629
  74. package/knowledge/wiki/video.md +157 -0
  75. package/knowledge/wiki/world.md +36 -36
  76. package/package.json +4 -3
  77. package/schema/api.schema.json +21707 -14725
  78. package/shell/page.ts +26 -2
  79. package/shell/platform.ts +46 -0
  80. package/shell/player.ts +7 -0
  81. package/src/depth.ts +71 -0
  82. package/src/e6.ts +32 -1
  83. package/src/env.d.ts +5 -1
  84. package/src/generated/abi.ts +189 -3
  85. package/src/index.ts +25 -4
  86. package/src/light.ts +18 -0
  87. package/src/math.ts +622 -0
  88. package/src/node/index.ts +17 -0
  89. package/src/node/playtest-run.ts +114 -18
  90. package/src/node/polish.ts +13 -3
  91. package/src/node/render.ts +291 -0
  92. package/src/node/run.ts +86 -5
  93. package/src/p2.ts +19 -1
  94. package/src/playtest.ts +57 -4
  95. package/src/runtime.ts +13 -3
  96. package/src/targets.ts +28 -0
  97. package/src/trace.ts +169 -0
  98. package/src/ui-kit/huds.ts +34 -34
  99. package/src/ui-kit/menus.ts +12 -12
  100. package/src/ui-kit/settings.ts +2 -2
  101. package/src/ui-kit/store.ts +18 -18
  102. package/src/ui-kit/story.ts +6 -4
  103. package/src/ui-kit/util.ts +8 -8
  104. package/src/web/shell.ts +58 -0
  105. package/src/web/worker.ts +103 -2
  106. package/types/bindings.json +9101 -6647
  107. package/types/index.d.ts +15503 -11564
@@ -8,6 +8,8 @@ Calls are asynchronous: each returns a request number at once, and the answer ar
8
8
 
9
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
10
 
11
+ Rooms (roomCreate, roomJoin, roomSend, ...) put this engine with other players' engines: the host carries them (natively `og relay` with `og run --room`, on the web the platform's rooms through the shell, docs/platform-asks.md) and its answers and the other peers' messages arrive as events at the start of a tick (og.RoomJoined, og.RoomPeerJoined, og.RoomPeerLeft, og.RoomMessage), host input like key presses. Deterministic play over a room is og.net's lockstep.
12
+
11
13
  - **TypeScript**: functions are the namespace `og.platform`; components, resources and events are tokens on `og`.
12
14
  - **Publish builds**: kept (members may override).
13
15
  - **Skill**: `og-platform-sdk`, which teaches the module (how much of it to use, and how to prove it).
@@ -18,7 +20,7 @@ module platform {
18
20
  # declarations follow, each quoted below
19
21
  ```
20
22
 
21
- <sub>`api.ogt` line 7521</sub>
23
+ <sub>`api.ogt` line 9150</sub>
22
24
 
23
25
  ## Contents
24
26
 
@@ -52,6 +54,21 @@ module platform {
52
54
  | [`og.platform.result`](#fn-result) | function | The answer to a call, once it arrived. |
53
55
  | [`og.platform.info`](#fn-info) | function | What answers platform calls here, and what it answers. |
54
56
  | [`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). |
57
+ | [`RoomDesc`](#type-RoomDesc) | desc struct | A room to create. |
58
+ | [`RoomPeer`](#type-RoomPeer) | struct | One peer in the room. |
59
+ | [`RoomInfo`](#type-RoomInfo) | struct | The room this engine is in. |
60
+ | [`RoomMessageData`](#type-RoomMessageData) | struct | A message another peer sent: what og.RoomMessage announced. |
61
+ | [`og.RoomJoined`](#record-RoomJoined) | event | roomCreate or roomJoin finished, or the host put this engine in a room (`og run --room`, a Play link to a room): sent at the start of the tick after the host answered. With ok false the engine is in no room and `reason` says why. |
62
+ | [`og.RoomPeerJoined`](#record-RoomPeerJoined) | event | Another peer joined this engine's room. |
63
+ | [`og.RoomPeerLeft`](#record-RoomPeerLeft) | event | A peer left this engine's room (it left, closed, or lost its connection), after every message it sent; or, with peer equal to this engine's own number, this engine is in no room any more (roomLeave, or the host lost the room). |
64
+ | [`og.RoomMessage`](#record-RoomMessage) | event | Another peer's message arrived; read it with og.platform.roomMessage. Messages from one peer arrive in the order it sent them. While lockstep runs (og.Lockstep) a message is this peer's host input alone: a system that changes the world from one makes it differ from the other peers' (og.Desync); carry what all must see in og.PlayerInput. |
65
+ | [`og.platform.roomCreate`](#fn-roomCreate) | function | Create a room and join it. The answer is og.RoomJoined, with the room's id to share (natively the relay names it `room-N`; on the web the platform does). |
66
+ | [`og.platform.roomJoin`](#fn-roomJoin) | function | Join a room by its id. The answer is og.RoomJoined (with ok false and `not_found` or `full` when it cannot); then og.RoomPeerJoined and og.RoomPeerLeft as others come and go. |
67
+ | [`og.platform.roomLeave`](#fn-roomLeave) | function | Leave the room: og.RoomPeerLeft with this engine's own peer number answers, and the other peers hear it leave after its last message. |
68
+ | [`og.platform.roomSend`](#fn-roomSend) | function | Send a message to every other peer in the room, or to one: a JSON value, or bytes (a Uint8Array). It arrives as og.RoomMessage, after every earlier message of this peer. |
69
+ | [`og.platform.roomPeers`](#fn-roomPeers) | function | The peers in this engine's room, this one included, by number; empty in none. |
70
+ | [`og.platform.roomInfo`](#fn-roomInfo) | function | The room this engine is in, and what carries rooms here. |
71
+ | [`og.platform.roomMessage`](#fn-roomMessage) | function | A message og.RoomMessage announced: who sent it and what it carries. The engine keeps the last 256. |
55
72
 
56
73
  ## Functions
57
74
 
@@ -83,7 +100,7 @@ fn storeGet {
83
100
  }
84
101
  ```
85
102
 
86
- <sub>`api.ogt` line 7636</sub>
103
+ <sub>`api.ogt` line 9266</sub>
87
104
 
88
105
  <a id="fn-storeSet"></a>
89
106
 
@@ -113,7 +130,7 @@ fn storeSet {
113
130
  }
114
131
  ```
115
132
 
116
- <sub>`api.ogt` line 7643</sub>
133
+ <sub>`api.ogt` line 9273</sub>
117
134
 
118
135
  <a id="fn-storeList"></a>
119
136
 
@@ -141,7 +158,7 @@ fn storeList {
141
158
  }
142
159
  ```
143
160
 
144
- <sub>`api.ogt` line 7650</sub>
161
+ <sub>`api.ogt` line 9280</sub>
145
162
 
146
163
  <a id="fn-leaderboardSubmit"></a>
147
164
 
@@ -171,7 +188,7 @@ fn leaderboardSubmit {
171
188
  }
172
189
  ```
173
190
 
174
- <sub>`api.ogt` line 7656</sub>
191
+ <sub>`api.ogt` line 9286</sub>
175
192
 
176
193
  <a id="fn-leaderboardTop"></a>
177
194
 
@@ -201,7 +218,7 @@ fn leaderboardTop {
201
218
  }
202
219
  ```
203
220
 
204
- <sub>`api.ogt` line 7663</sub>
221
+ <sub>`api.ogt` line 9293</sub>
205
222
 
206
223
  <a id="fn-leaderboardAround"></a>
207
224
 
@@ -231,7 +248,7 @@ fn leaderboardAround {
231
248
  }
232
249
  ```
233
250
 
234
- <sub>`api.ogt` line 7670</sub>
251
+ <sub>`api.ogt` line 9300</sub>
235
252
 
236
253
  <a id="fn-telemetry"></a>
237
254
 
@@ -265,7 +282,7 @@ fn telemetry {
265
282
  }
266
283
  ```
267
284
 
268
- <sub>`api.ogt` line 7677</sub>
285
+ <sub>`api.ogt` line 9307</sub>
269
286
 
270
287
  <a id="fn-point"></a>
271
288
 
@@ -295,7 +312,7 @@ fn point {
295
312
  }
296
313
  ```
297
314
 
298
- <sub>`api.ogt` line 7687</sub>
315
+ <sub>`api.ogt` line 9317</sub>
299
316
 
300
317
  <a id="fn-aiMark"></a>
301
318
 
@@ -325,7 +342,7 @@ fn aiMark {
325
342
  }
326
343
  ```
327
344
 
328
- <sub>`api.ogt` line 7694</sub>
345
+ <sub>`api.ogt` line 9324</sub>
329
346
 
330
347
  <a id="fn-loadSettings"></a>
331
348
 
@@ -353,7 +370,7 @@ fn loadSettings {
353
370
  }
354
371
  ```
355
372
 
356
- <sub>`api.ogt` line 7701</sub>
373
+ <sub>`api.ogt` line 9331</sub>
357
374
 
358
375
  <a id="fn-saveSettings"></a>
359
376
 
@@ -383,7 +400,7 @@ fn saveSettings {
383
400
  }
384
401
  ```
385
402
 
386
- <sub>`api.ogt` line 7707</sub>
403
+ <sub>`api.ogt` line 9337</sub>
387
404
 
388
405
  <a id="fn-saveSlot"></a>
389
406
 
@@ -413,7 +430,7 @@ fn saveSlot {
413
430
  }
414
431
  ```
415
432
 
416
- <sub>`api.ogt` line 7714</sub>
433
+ <sub>`api.ogt` line 9344</sub>
417
434
 
418
435
  <a id="fn-loadSlot"></a>
419
436
 
@@ -443,7 +460,7 @@ fn loadSlot {
443
460
  }
444
461
  ```
445
462
 
446
- <sub>`api.ogt` line 7721</sub>
463
+ <sub>`api.ogt` line 9351</sub>
447
464
 
448
465
  <a id="fn-result"></a>
449
466
 
@@ -473,7 +490,7 @@ fn result {
473
490
  }
474
491
  ```
475
492
 
476
- <sub>`api.ogt` line 7728</sub>
493
+ <sub>`api.ogt` line 9358</sub>
477
494
 
478
495
  <a id="fn-info"></a>
479
496
 
@@ -501,7 +518,7 @@ fn info {
501
518
  }
502
519
  ```
503
520
 
504
- <sub>`api.ogt` line 7735</sub>
521
+ <sub>`api.ogt` line 9365</sub>
505
522
 
506
523
  <a id="fn-now"></a>
507
524
 
@@ -529,7 +546,217 @@ fn now {
529
546
  }
530
547
  ```
531
548
 
532
- <sub>`api.ogt` line 7741</sub>
549
+ <sub>`api.ogt` line 9371</sub>
550
+
551
+ <a id="fn-roomCreate"></a>
552
+
553
+ ### `og.platform.roomCreate`
554
+
555
+ Create a room and join it. The answer is og.RoomJoined, with the room's id to share (natively the relay names it `room-N`; on the web the platform does).
556
+
557
+ ```ts
558
+ og.platform.roomCreate(world: World, desc?: RoomDesc): Result<void>
559
+ ```
560
+
561
+ | Parameter | Type | Optional | Doc |
562
+ |---|---|---|---|
563
+ | `world` | `World` | no | The world. |
564
+ | `desc` | `RoomDesc` | yes | Its name and capacity. |
565
+
566
+ **Returns** `Result<void>`: Refused with no room host (og.platform.roomInfo's host `none`), while in or joining a room (roomLeave first), or for a malformed name.
567
+
568
+ Binding symbol `og_platform_room_create` · publish builds: kept
569
+
570
+ ```ogt
571
+ fn roomCreate {
572
+ doc "Create a room and join it. The answer is og.RoomJoined, with the room's id to share (natively the relay names it `room-N`; on the web the platform does)."
573
+ param world World "The world."
574
+ param desc RoomDesc "Its name and capacity." {
575
+ optional true
576
+ }
577
+ returns Result.Void "Refused with no room host (og.platform.roomInfo's host `none`), while in or joining a room (roomLeave first), or for a malformed name."
578
+ }
579
+ ```
580
+
581
+ <sub>`api.ogt` line 9444</sub>
582
+
583
+ <a id="fn-roomJoin"></a>
584
+
585
+ ### `og.platform.roomJoin`
586
+
587
+ Join a room by its id. The answer is og.RoomJoined (with ok false and `not_found` or `full` when it cannot); then og.RoomPeerJoined and og.RoomPeerLeft as others come and go.
588
+
589
+ ```ts
590
+ og.platform.roomJoin(world: World, room: string): Result<void>
591
+ ```
592
+
593
+ | Parameter | Type | Optional | Doc |
594
+ |---|---|---|---|
595
+ | `world` | `World` | no | The world. |
596
+ | `room` | `string` | no | The room's id: 1 to 64 of letters, digits, `.`, `_` and `-`. |
597
+
598
+ **Returns** `Result<void>`: Refused with no room host, while in or joining a room, or for a malformed id.
599
+
600
+ Binding symbol `og_platform_room_join` · publish builds: kept
601
+
602
+ ```ogt
603
+ fn roomJoin {
604
+ doc "Join a room by its id. The answer is og.RoomJoined (with ok false and `not_found` or `full` when it cannot); then og.RoomPeerJoined and og.RoomPeerLeft as others come and go."
605
+ param world World "The world."
606
+ param room String "The room's id: 1 to 64 of letters, digits, `.`, `_` and `-`."
607
+ returns Result.Void "Refused with no room host, while in or joining a room, or for a malformed id."
608
+ }
609
+ ```
610
+
611
+ <sub>`api.ogt` line 9453</sub>
612
+
613
+ <a id="fn-roomLeave"></a>
614
+
615
+ ### `og.platform.roomLeave`
616
+
617
+ Leave the room: og.RoomPeerLeft with this engine's own peer number answers, and the other peers hear it leave after its last message.
618
+
619
+ ```ts
620
+ og.platform.roomLeave(world: World): Result<void>
621
+ ```
622
+
623
+ | Parameter | Type | Optional | Doc |
624
+ |---|---|---|---|
625
+ | `world` | `World` | no | The world. |
626
+
627
+ **Returns** `Result<void>`: Refused when in no room.
628
+
629
+ Binding symbol `og_platform_room_leave` · publish builds: kept
630
+
631
+ ```ogt
632
+ fn roomLeave {
633
+ doc "Leave the room: og.RoomPeerLeft with this engine's own peer number answers, and the other peers hear it leave after its last message."
634
+ param world World "The world."
635
+ returns Result.Void "Refused when in no room."
636
+ }
637
+ ```
638
+
639
+ <sub>`api.ogt` line 9460</sub>
640
+
641
+ <a id="fn-roomSend"></a>
642
+
643
+ ### `og.platform.roomSend`
644
+
645
+ Send a message to every other peer in the room, or to one: a JSON value, or bytes (a Uint8Array). It arrives as og.RoomMessage, after every earlier message of this peer.
646
+
647
+ ```ts
648
+ og.platform.roomSend(world: World, data: Uint8Array | unknown, to?: number): Result<void>
649
+ ```
650
+
651
+ | Parameter | Type | Optional | Doc |
652
+ |---|---|---|---|
653
+ | `world` | `World` | no | The world. |
654
+ | `data` | `Uint8Array \| unknown` | no | What to send: a Uint8Array, or any JSON value; at most 64 KiB encoded. |
655
+ | `to` | `number` | yes | The one peer to send it to; omitted is every other peer. |
656
+
657
+ **Returns** `Result<void>`: Refused when in no room, for a message over 64 KiB, or a peer not in the room.
658
+
659
+ Binding symbol `og_platform_room_send` · publish builds: kept
660
+
661
+ ```ogt
662
+ fn roomSend {
663
+ doc "Send a message to every other peer in the room, or to one: a JSON value, or bytes (a Uint8Array). It arrives as og.RoomMessage, after every earlier message of this peer."
664
+ param world World "The world."
665
+ param data OneOf.Bytes.Json "What to send: a Uint8Array, or any JSON value; at most 64 KiB encoded."
666
+ param to u32 "The one peer to send it to; omitted is every other peer." {
667
+ optional true
668
+ }
669
+ returns Result.Void "Refused when in no room, for a message over 64 KiB, or a peer not in the room."
670
+ }
671
+ ```
672
+
673
+ <sub>`api.ogt` line 9466</sub>
674
+
675
+ <a id="fn-roomPeers"></a>
676
+
677
+ ### `og.platform.roomPeers`
678
+
679
+ The peers in this engine's room, this one included, by number; empty in none.
680
+
681
+ ```ts
682
+ og.platform.roomPeers(world: World): readonly RoomPeer[]
683
+ ```
684
+
685
+ | Parameter | Type | Optional | Doc |
686
+ |---|---|---|---|
687
+ | `world` | `World` | no | The world. |
688
+
689
+ **Returns** `readonly RoomPeer[]`.
690
+
691
+ Binding symbol `og_platform_room_peers` · publish builds: kept
692
+
693
+ ```ogt
694
+ fn roomPeers {
695
+ doc "The peers in this engine's room, this one included, by number; empty in none."
696
+ param world World "The world."
697
+ returns List.RoomPeer
698
+ }
699
+ ```
700
+
701
+ <sub>`api.ogt` line 9476</sub>
702
+
703
+ <a id="fn-roomInfo"></a>
704
+
705
+ ### `og.platform.roomInfo`
706
+
707
+ The room this engine is in, and what carries rooms here.
708
+
709
+ ```ts
710
+ og.platform.roomInfo(world: World): RoomInfo
711
+ ```
712
+
713
+ | Parameter | Type | Optional | Doc |
714
+ |---|---|---|---|
715
+ | `world` | `World` | no | The world. |
716
+
717
+ **Returns** `RoomInfo`.
718
+
719
+ Binding symbol `og_platform_room_info` · publish builds: kept
720
+
721
+ ```ogt
722
+ fn roomInfo {
723
+ doc "The room this engine is in, and what carries rooms here."
724
+ param world World "The world."
725
+ returns RoomInfo
726
+ }
727
+ ```
728
+
729
+ <sub>`api.ogt` line 9482</sub>
730
+
731
+ <a id="fn-roomMessage"></a>
732
+
733
+ ### `og.platform.roomMessage`
734
+
735
+ A message og.RoomMessage announced: who sent it and what it carries. The engine keeps the last 256.
736
+
737
+ ```ts
738
+ og.platform.roomMessage(world: World, message: number): RoomMessageData | null
739
+ ```
740
+
741
+ | Parameter | Type | Optional | Doc |
742
+ |---|---|---|---|
743
+ | `world` | `World` | no | The world. |
744
+ | `message` | `number` | no | og.RoomMessage.message. |
745
+
746
+ **Returns** `RoomMessageData | null`: Null for a number never given, or a message older than the last 256.
747
+
748
+ Binding symbol `og_platform_room_message` · publish builds: kept
749
+
750
+ ```ogt
751
+ fn roomMessage {
752
+ doc "A message og.RoomMessage announced: who sent it and what it carries. The engine keeps the last 256."
753
+ param world World "The world."
754
+ param message u32 "og.RoomMessage.message."
755
+ returns Option.RoomMessageData "Null for a number never given, or a message older than the last 256."
756
+ }
757
+ ```
758
+
759
+ <sub>`api.ogt` line 9488</sub>
533
760
 
534
761
  ## Components, resources and events
535
762
 
@@ -554,7 +781,107 @@ event PlatformAnswered {
554
781
  }
555
782
  ```
556
783
 
557
- <sub>`api.ogt` line 7533</sub>
784
+ <sub>`api.ogt` line 9163</sub>
785
+
786
+ <a id="record-RoomJoined"></a>
787
+
788
+ ### `og.RoomJoined` (event)
789
+
790
+ roomCreate or roomJoin finished, or the host put this engine in a room (`og run --room`, a Play link to a room): sent at the start of the tick after the host answered. With ok false the engine is in no room and `reason` says why.
791
+
792
+ Token `og.RoomJoined`, registered under the schema name `og.RoomJoined`; its value type is `RoomJoined`.
793
+
794
+ | Field | Type | Default | Range | Unit | Notes | Doc |
795
+ |---|---|---|---|---|---|---|
796
+ | `ok` | `boolean` | `false` | — | — | — | Whether this engine is in the room now. |
797
+ | `room` | `string` | `""` | — | — | — | The room's id (at most 63 bytes); empty when not ok. |
798
+ | `peer` | `number` | `0` | — | — | — | This engine's peer number. |
799
+ | `peers` | `number` | `0` | — | — | — | How many peers are in the room, this one included. |
800
+ | `reason` | `string` | `""` | — | — | — | Why it failed: `unavailable` (no rooms here), `not_found`, `full`, `invalid` or `offline`, then a colon and the host's words; empty when ok. |
801
+
802
+ ```ogt
803
+ event RoomJoined {
804
+ doc "roomCreate or roomJoin finished, or the host put this engine in a room (`og run --room`, a Play link to a room): sent at the start of the tick after the host answered. With ok false the engine is in no room and `reason` says why."
805
+ field ok bool "Whether this engine is in the room now."
806
+ field room String "The room's id (at most 63 bytes); empty when not ok."
807
+ field peer u32 "This engine's peer number."
808
+ field peers u32 "How many peers are in the room, this one included."
809
+ field reason String "Why it failed: `unavailable` (no rooms here), `not_found`, `full`, `invalid` or `offline`, then a colon and the host's words; empty when ok."
810
+ }
811
+ ```
812
+
813
+ <sub>`api.ogt` line 9416</sub>
814
+
815
+ <a id="record-RoomPeerJoined"></a>
816
+
817
+ ### `og.RoomPeerJoined` (event)
818
+
819
+ Another peer joined this engine's room.
820
+
821
+ Token `og.RoomPeerJoined`, registered under the schema name `og.RoomPeerJoined`; its value type is `RoomPeerJoined`.
822
+
823
+ | Field | Type | Default | Range | Unit | Notes | Doc |
824
+ |---|---|---|---|---|---|---|
825
+ | `peer` | `number` | `0` | — | — | — | Its peer number. |
826
+ | `peers` | `number` | `0` | — | — | — | How many peers are in the room now. |
827
+
828
+ ```ogt
829
+ event RoomPeerJoined {
830
+ doc "Another peer joined this engine's room."
831
+ field peer u32 "Its peer number."
832
+ field peers u32 "How many peers are in the room now."
833
+ }
834
+ ```
835
+
836
+ <sub>`api.ogt` line 9425</sub>
837
+
838
+ <a id="record-RoomPeerLeft"></a>
839
+
840
+ ### `og.RoomPeerLeft` (event)
841
+
842
+ A peer left this engine's room (it left, closed, or lost its connection), after every message it sent; or, with peer equal to this engine's own number, this engine is in no room any more (roomLeave, or the host lost the room).
843
+
844
+ Token `og.RoomPeerLeft`, registered under the schema name `og.RoomPeerLeft`; its value type is `RoomPeerLeft`.
845
+
846
+ | Field | Type | Default | Range | Unit | Notes | Doc |
847
+ |---|---|---|---|---|---|---|
848
+ | `peer` | `number` | `0` | — | — | — | Its peer number. |
849
+ | `peers` | `number` | `0` | — | — | — | How many peers are in the room now (0 once this engine left). |
850
+
851
+ ```ogt
852
+ event RoomPeerLeft {
853
+ doc "A peer left this engine's room (it left, closed, or lost its connection), after every message it sent; or, with peer equal to this engine's own number, this engine is in no room any more (roomLeave, or the host lost the room)."
854
+ field peer u32 "Its peer number."
855
+ field peers u32 "How many peers are in the room now (0 once this engine left)."
856
+ }
857
+ ```
858
+
859
+ <sub>`api.ogt` line 9431</sub>
860
+
861
+ <a id="record-RoomMessage"></a>
862
+
863
+ ### `og.RoomMessage` (event)
864
+
865
+ Another peer's message arrived; read it with og.platform.roomMessage. Messages from one peer arrive in the order it sent them. While lockstep runs (og.Lockstep) a message is this peer's host input alone: a system that changes the world from one makes it differ from the other peers' (og.Desync); carry what all must see in og.PlayerInput.
866
+
867
+ Token `og.RoomMessage`, registered under the schema name `og.RoomMessage`; its value type is `RoomMessage`.
868
+
869
+ | Field | Type | Default | Range | Unit | Notes | Doc |
870
+ |---|---|---|---|---|---|---|
871
+ | `from` | `number` | `0` | — | — | — | The sender's peer number. |
872
+ | `message` | `number` | `0` | — | — | — | The message's number, for og.platform.roomMessage. |
873
+ | `binary` | `boolean` | `false` | — | — | — | Whether it was sent as bytes (else as a JSON value). |
874
+
875
+ ```ogt
876
+ event RoomMessage {
877
+ doc "Another peer's message arrived; read it with og.platform.roomMessage. Messages from one peer arrive in the order it sent them. While lockstep runs (og.Lockstep) a message is this peer's host input alone: a system that changes the world from one makes it differ from the other peers' (og.Desync); carry what all must see in og.PlayerInput."
878
+ field from u32 "The sender's peer number."
879
+ field message u32 "The message's number, for og.platform.roomMessage."
880
+ field binary bool "Whether it was sent as bytes (else as a JSON value)."
881
+ }
882
+ ```
883
+
884
+ <sub>`api.ogt` line 9437</sub>
558
885
 
559
886
  ## Types
560
887
 
@@ -579,7 +906,7 @@ enum PlatformOrder {
579
906
  }
580
907
  ```
581
908
 
582
- <sub>`api.ogt` line 7527</sub>
909
+ <sub>`api.ogt` line 9157</sub>
583
910
 
584
911
  <a id="type-StoreSetDesc"></a>
585
912
 
@@ -607,7 +934,7 @@ struct StoreSetDesc {
607
934
  }
608
935
  ```
609
936
 
610
- <sub>`api.ogt` line 7539</sub>
937
+ <sub>`api.ogt` line 9169</sub>
611
938
 
612
939
  <a id="type-LeaderboardSubmitDesc"></a>
613
940
 
@@ -635,7 +962,7 @@ struct LeaderboardSubmitDesc {
635
962
  }
636
963
  ```
637
964
 
638
- <sub>`api.ogt` line 7548</sub>
965
+ <sub>`api.ogt` line 9178</sub>
639
966
 
640
967
  <a id="type-LeaderboardQueryDesc"></a>
641
968
 
@@ -665,7 +992,7 @@ struct LeaderboardQueryDesc {
665
992
  }
666
993
  ```
667
994
 
668
- <sub>`api.ogt` line 7558</sub>
995
+ <sub>`api.ogt` line 9188</sub>
669
996
 
670
997
  <a id="type-PointDesc"></a>
671
998
 
@@ -693,7 +1020,7 @@ struct PointDesc {
693
1020
  }
694
1021
  ```
695
1022
 
696
- <sub>`api.ogt` line 7571</sub>
1023
+ <sub>`api.ogt` line 9201</sub>
697
1024
 
698
1025
  <a id="type-AiMarkDesc"></a>
699
1026
 
@@ -719,7 +1046,7 @@ struct AiMarkDesc {
719
1046
  }
720
1047
  ```
721
1048
 
722
- <sub>`api.ogt` line 7582</sub>
1049
+ <sub>`api.ogt` line 9212</sub>
723
1050
 
724
1051
  <a id="type-SaveSlotDesc"></a>
725
1052
 
@@ -745,7 +1072,7 @@ struct SaveSlotDesc {
745
1072
  }
746
1073
  ```
747
1074
 
748
- <sub>`api.ogt` line 7590</sub>
1075
+ <sub>`api.ogt` line 9220</sub>
749
1076
 
750
1077
  <a id="type-LoadSlotDesc"></a>
751
1078
 
@@ -769,7 +1096,7 @@ struct LoadSlotDesc {
769
1096
  }
770
1097
  ```
771
1098
 
772
- <sub>`api.ogt` line 7598</sub>
1099
+ <sub>`api.ogt` line 9228</sub>
773
1100
 
774
1101
  <a id="type-PlatformError"></a>
775
1102
 
@@ -794,7 +1121,7 @@ struct PlatformError {
794
1121
  }
795
1122
  ```
796
1123
 
797
- <sub>`api.ogt` line 7605</sub>
1124
+ <sub>`api.ogt` line 9235</sub>
798
1125
 
799
1126
  <a id="type-PlatformResult"></a>
800
1127
 
@@ -829,7 +1156,7 @@ struct PlatformResult {
829
1156
  }
830
1157
  ```
831
1158
 
832
- <sub>`api.ogt` line 7613</sub>
1159
+ <sub>`api.ogt` line 9243</sub>
833
1160
 
834
1161
  <a id="type-PlatformInfo"></a>
835
1162
 
@@ -854,4 +1181,111 @@ struct PlatformInfo {
854
1181
  }
855
1182
  ```
856
1183
 
857
- <sub>`api.ogt` line 7628</sub>
1184
+ <sub>`api.ogt` line 9258</sub>
1185
+
1186
+ <a id="type-RoomDesc"></a>
1187
+
1188
+ ### `RoomDesc` (desc struct)
1189
+
1190
+ A room to create.
1191
+
1192
+ A desc: every field may be omitted and takes its default; `{}` is valid.
1193
+
1194
+ | Field | Type | Default | Range | Unit | Notes | Doc |
1195
+ |---|---|---|---|---|---|---|
1196
+ | `name` | `string` | `""` | — | — | — | What the room is called (at most 64 of letters, digits, `.`, `_` and `-`); empty for none. The host gives the room its id. |
1197
+ | `capacity` | `number` | `2` | 1 … 16 | — | — | The most peers it takes. |
1198
+
1199
+ ```ogt
1200
+ struct RoomDesc {
1201
+ doc "A room to create."
1202
+ desc true
1203
+ field name String "What the room is called (at most 64 of letters, digits, `.`, `_` and `-`); empty for none. The host gives the room its id."
1204
+ field capacity u32 "The most peers it takes." {
1205
+ default 2
1206
+ min 1
1207
+ max 16
1208
+ }
1209
+ }
1210
+ ```
1211
+
1212
+ <sub>`api.ogt` line 9379</sub>
1213
+
1214
+ <a id="type-RoomPeer"></a>
1215
+
1216
+ ### `RoomPeer` (struct)
1217
+
1218
+ One peer in the room.
1219
+
1220
+ | Field | Type | Default | Range | Unit | Notes | Doc |
1221
+ |---|---|---|---|---|---|---|
1222
+ | `peer` | `number` | `0` | — | — | — | Its number: the room numbers peers in join order from 0 and never gives one twice. |
1223
+ | `name` | `string` | `""` | — | — | — | Its name, as its host gave it; empty for none. |
1224
+ | `local` | `boolean` | `false` | — | — | — | Whether it is this engine. |
1225
+
1226
+ ```ogt
1227
+ struct RoomPeer {
1228
+ doc "One peer in the room."
1229
+ field peer u32 "Its number: the room numbers peers in join order from 0 and never gives one twice."
1230
+ field name String "Its name, as its host gave it; empty for none."
1231
+ field local bool "Whether it is this engine."
1232
+ }
1233
+ ```
1234
+
1235
+ <sub>`api.ogt` line 9390</sub>
1236
+
1237
+ <a id="type-RoomInfo"></a>
1238
+
1239
+ ### `RoomInfo` (struct)
1240
+
1241
+ The room this engine is in.
1242
+
1243
+ | Field | Type | Default | Range | Unit | Notes | Doc |
1244
+ |---|---|---|---|---|---|---|
1245
+ | `state` | `string` | `""` | — | — | — | `none` (in no room), `joining` (roomCreate or roomJoin asked, not answered yet) or `in`. |
1246
+ | `room` | `string` | `""` | — | — | — | The room's id; empty in none. |
1247
+ | `host` | `string` | `""` | — | — | — | What carries rooms here: `relay` (natively, `og run --room` through `og relay`), `player` (the platform's rooms through the Player, on the web) or `none` (roomCreate and roomJoin are refused). |
1248
+ | `peer` | `number` | `0` | — | — | — | This engine's peer number; 0 in none. |
1249
+ | `peers` | `readonly RoomPeer[]` | `[]` | — | — | — | Every peer present, this one included, by number. |
1250
+ | `link` | `string` | `""` | — | — | — | The room a Play link to a room (`?room=<id>` on the play page) named: the engine joined it at load (og.RoomJoined answers, as for roomJoin); empty without one. |
1251
+
1252
+ ```ogt
1253
+ struct RoomInfo {
1254
+ doc "The room this engine is in."
1255
+ field state String "`none` (in no room), `joining` (roomCreate or roomJoin asked, not answered yet) or `in`."
1256
+ field room String "The room's id; empty in none."
1257
+ field host String "What carries rooms here: `relay` (natively, `og run --room` through `og relay`), `player` (the platform's rooms through the Player, on the web) or `none` (roomCreate and roomJoin are refused)."
1258
+ field peer u32 "This engine's peer number; 0 in none."
1259
+ field peers List.RoomPeer "Every peer present, this one included, by number."
1260
+ field link String "The room a Play link to a room (`?room=<id>` on the play page) named: the engine joined it at load (og.RoomJoined answers, as for roomJoin); empty without one."
1261
+ }
1262
+ ```
1263
+
1264
+ <sub>`api.ogt` line 9397</sub>
1265
+
1266
+ <a id="type-RoomMessageData"></a>
1267
+
1268
+ ### `RoomMessageData` (struct)
1269
+
1270
+ A message another peer sent: what og.RoomMessage announced.
1271
+
1272
+ | Field | Type | Default | Range | Unit | Notes | Doc |
1273
+ |---|---|---|---|---|---|---|
1274
+ | `message` | `number` | `0` | — | — | — | Its number (og.RoomMessage.message): 1 for the first message this engine received, counting up. |
1275
+ | `from` | `number` | `0` | — | — | — | The sender's peer number. |
1276
+ | `tick` | `number` | `0` | — | — | — | The tick it was delivered at. |
1277
+ | `data` | `unknown` | `null` | — | — | — | What it carries, when it was sent as a JSON value; null when it was sent as bytes. |
1278
+ | `bytes` | `Uint8Array \| null` | `null` | — | — | — | What it carries, when it was sent as bytes. |
1279
+
1280
+ ```ogt
1281
+ struct RoomMessageData {
1282
+ doc "A message another peer sent: what og.RoomMessage announced."
1283
+ field message u32 "Its number (og.RoomMessage.message): 1 for the first message this engine received, counting up."
1284
+ field from u32 "The sender's peer number."
1285
+ field tick u32 "The tick it was delivered at."
1286
+ field data Json "What it carries, when it was sent as a JSON value; null when it was sent as bytes."
1287
+ field bytes Option.Bytes "What it carries, when it was sent as bytes."
1288
+ }
1289
+ ```
1290
+
1291
+ <sub>`api.ogt` line 9407</sub>