@defold-typescript/types 0.5.5 → 0.6.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 (53) hide show
  1. package/api-targets.json +1 -1
  2. package/generated/b2d.d.ts +3 -0
  3. package/generated/buffer.d.ts +44 -38
  4. package/generated/builtin-messages.d.ts +1 -1
  5. package/generated/camera.d.ts +3 -0
  6. package/generated/collectionfactory.d.ts +47 -40
  7. package/generated/collectionproxy.d.ts +23 -18
  8. package/generated/crash.d.ts +3 -0
  9. package/generated/factory.d.ts +32 -24
  10. package/generated/go.d.ts +123 -124
  11. package/generated/graphics.d.ts +3 -0
  12. package/generated/gui.d.ts +303 -283
  13. package/generated/http.d.ts +26 -16
  14. package/generated/iac.d.ts +3 -0
  15. package/generated/iap.d.ts +6 -3
  16. package/generated/image.d.ts +30 -26
  17. package/generated/json.d.ts +36 -32
  18. package/generated/kinds/gui-script.d.ts +7 -5
  19. package/generated/kinds/render-script.d.ts +7 -5
  20. package/generated/kinds/script.d.ts +7 -5
  21. package/generated/label.d.ts +16 -9
  22. package/generated/liveupdate.d.ts +29 -26
  23. package/generated/model.d.ts +57 -45
  24. package/generated/msg.d.ts +3 -0
  25. package/generated/particlefx.d.ts +50 -34
  26. package/generated/physics.d.ts +153 -133
  27. package/generated/profiler.d.ts +45 -41
  28. package/generated/push.d.ts +5 -2
  29. package/generated/render.d.ts +410 -349
  30. package/generated/resource.d.ts +619 -572
  31. package/generated/socket.d.ts +49 -33
  32. package/generated/sound.d.ts +83 -72
  33. package/generated/sprite.d.ts +3 -0
  34. package/generated/sys.d.ts +198 -189
  35. package/generated/tilemap.d.ts +43 -39
  36. package/generated/timer.d.ts +42 -36
  37. package/generated/vmath.d.ts +22 -0
  38. package/generated/webview.d.ts +3 -0
  39. package/generated/window.d.ts +23 -17
  40. package/generated/zlib.d.ts +15 -12
  41. package/index.d.ts +3 -1
  42. package/package.json +6 -2
  43. package/scripts/fidelity-audit.ts +61 -1
  44. package/scripts/fidelity-baseline.json +10 -10
  45. package/scripts/ref-doc-delta.ts +143 -0
  46. package/scripts/regen.ts +18 -9
  47. package/src/core-types.ts +14 -0
  48. package/src/emit-dts.ts +219 -13
  49. package/src/engine-globals.d.ts +2 -0
  50. package/src/go-overloads.d.ts +43 -0
  51. package/src/index.ts +5 -0
  52. package/src/lifecycle.ts +157 -16
  53. package/src/publish-dts.ts +1 -1
@@ -2,6 +2,11 @@
2
2
  import type { Hash, Opaque, Quaternion, Url, Vector, Vector3, Vector4 } from "../src/core-types";
3
3
 
4
4
  declare global {
5
+ /**
6
+ * GUI core hooks, functions, messages, properties and constants for
7
+ * creation and manipulation of GUI nodes. The "gui" namespace is
8
+ * accessible only from gui scripts.
9
+ */
5
10
  namespace gui {
6
11
  /**
7
12
  * Adjust mode is used when the screen resolution differs from the project settings.
@@ -486,40 +491,43 @@ declare global {
486
491
  * - `gui.PLAYBACK_LOOP_BACKWARD`
487
492
  * - `gui.PLAYBACK_LOOP_PINGPONG`
488
493
  * @example
489
- * ```lua
490
- * How to start a simple color animation, where the node fades in to white during 0.5 seconds:
491
- * gui.set_color(node, vmath.vector4(0, 0, 0, 0)) -- node is fully transparent
492
- * gui.animate(node, gui.PROP_COLOR, vmath.vector4(1, 1, 1, 1), gui.EASING_INOUTQUAD, 0.5) -- start animation
493
- *
494
- * How to start a sequenced animation where the node fades in to white during 0.5 seconds, stays visible for 2 seconds and then fades out:
495
- * local function on_animation_done(self, node)
496
- * -- fade out node, but wait 2 seconds before the animation starts
497
- * gui.animate(node, gui.PROP_COLOR, vmath.vector4(0, 0, 0, 0), gui.EASING_OUTQUAD, 0.5, 2.0)
498
- * end
499
- *
500
- * function init(self)
501
- * -- fetch the node we want to animate
502
- * local my_node = gui.get_node("my_node")
503
- * -- node is initially set to fully transparent
504
- * gui.set_color(my_node, vmath.vector4(0, 0, 0, 0))
505
- * -- animate the node immediately and call on_animation_done when the animation has completed
506
- * gui.animate(my_node, gui.PROP_COLOR, vmath.vector4(1, 1, 1, 1), gui.EASING_INOUTQUAD, 0.5, 0.0, on_animation_done)
507
- * end
508
- *
509
- * How to animate a node's y position using a crazy custom easing curve:
510
- * function init(self)
511
- * local values = { 0, 0, 0, 0, 0, 0, 0, 0,
512
- * 1, 1, 1, 1, 1, 1, 1, 1,
513
- * 0, 0, 0, 0, 0, 0, 0, 0,
514
- * 1, 1, 1, 1, 1, 1, 1, 1,
515
- * 0, 0, 0, 0, 0, 0, 0, 0,
516
- * 1, 1, 1, 1, 1, 1, 1, 1,
517
- * 0, 0, 0, 0, 0, 0, 0, 0,
518
- * 1, 1, 1, 1, 1, 1, 1, 1 }
519
- * local vec = vmath.vector(values)
520
- * local node = gui.get_node("box")
521
- * gui.animate(node, "position.y", 100, vec, 4.0, 0, nil, gui.PLAYBACK_LOOP_PINGPONG)
522
- * end
494
+ * ```ts
495
+ * // How to start a simple color animation, where the node fades in to white during 0.5 seconds:
496
+ * gui.set_color(node, vmath.vector4(0, 0, 0, 0)); // node is fully transparent
497
+ * gui.animate(node, gui.PROP_COLOR, vmath.vector4(1, 1, 1, 1), gui.EASING_INOUTQUAD, 0.5); // start animation
498
+ *
499
+ * // How to start a sequenced animation where the node fades in to white during 0.5
500
+ * // seconds, stays visible for 2 seconds and then fades out:
501
+ * function on_animation_done(self, node) {
502
+ * // fade out node, but wait 2 seconds before the animation starts
503
+ * gui.animate(node, gui.PROP_COLOR, vmath.vector4(0, 0, 0, 0), gui.EASING_OUTQUAD, 0.5, 2.0);
504
+ * }
505
+ *
506
+ * export default defineScript({
507
+ * init(self) {
508
+ * // fetch the node we want to animate
509
+ * const my_node = gui.get_node("my_node");
510
+ * // node is initially set to fully transparent
511
+ * gui.set_color(my_node, vmath.vector4(0, 0, 0, 0));
512
+ * // animate the node immediately and call on_animation_done when the animation has completed
513
+ * gui.animate(my_node, gui.PROP_COLOR, vmath.vector4(1, 1, 1, 1), gui.EASING_INOUTQUAD, 0.5, 0.0, on_animation_done);
514
+ * },
515
+ * });
516
+ *
517
+ * // How to animate a node's y position using a crazy custom easing curve:
518
+ * export default defineScript({
519
+ * init(self) {
520
+ * const values = [
521
+ * 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1,
522
+ * 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1,
523
+ * 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1,
524
+ * 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1,
525
+ * ];
526
+ * const vec = vmath.vector(values);
527
+ * const node = gui.get_node("box");
528
+ * gui.animate(node, "position.y", 100, vec, 4.0, 0, undefined, gui.PLAYBACK_LOOP_PINGPONG);
529
+ * },
530
+ * });
523
531
  * ```
524
532
  */
525
533
  function animate(node: Opaque<"node">, property: string | Opaque<"constant">, to: number | Vector3 | Vector4 | Quaternion, easing: Opaque<"constant"> | Vector, duration: number, delay?: number, complete_function?: (self: unknown, node: unknown) => void, playback?: Opaque<"constant">): void;
@@ -542,25 +550,24 @@ declare global {
542
550
  * - `"tracking"` (text)
543
551
  * - `"slice9"` (slice9)
544
552
  * @example
545
- * ```lua
546
- * Start an animation of the position property of a node, then cancel parts of
547
- * the animation:
548
- * local node = gui.get_node("my_node")
549
- * -- animate to new position
550
- * local pos = vmath.vector3(100, 100, 0)
551
- * gui.animate(node, "position", pos, go.EASING_LINEAR, 2)
552
- * ...
553
- * -- cancel animation of the x component.
554
- * gui.cancel_animations(node, "position.x")
555
- *
556
- * Cancels all property animations on a node in a single call:
557
- * local node = gui.get_node("my_node")
558
- * -- animate to new position and scale
559
- * gui.animate(node, "position", vmath.vector3(100, 100, 0), go.EASING_LINEAR, 5)
560
- * gui.animate(node, "scale", vmath.vector3(0.5), go.EASING_LINEAR, 5)
561
- * ...
562
- * -- cancel positioning and scaling at once
563
- * gui.cancel_animations(node)
553
+ * ```ts
554
+ * // Start an animation of the position property of a node, then cancel parts of
555
+ * // the animation:
556
+ * const node = gui.get_node("my_node");
557
+ * // animate to new position
558
+ * const pos = vmath.vector3(100, 100, 0);
559
+ * gui.animate(node, "position", pos, go.EASING_LINEAR, 2);
560
+ * // ...
561
+ * // cancel animation of the x component.
562
+ * gui.cancel_animations(node, "position.x");
563
+ *
564
+ * // Cancels all property animations on a node in a single call:
565
+ * // animate to new position and scale
566
+ * gui.animate(node, "position", vmath.vector3(100, 100, 0), go.EASING_LINEAR, 5);
567
+ * gui.animate(node, "scale", vmath.vector3(0.5), go.EASING_LINEAR, 5);
568
+ * // ...
569
+ * // cancel positioning and scaling at once
570
+ * gui.cancel_animations(node);
564
571
  * ```
565
572
  */
566
573
  function cancel_animations(node: Opaque<"node">, property?: string | Opaque<"constant">): void;
@@ -569,9 +576,9 @@ declare global {
569
576
  *
570
577
  * @param node - node cancel flipbook animation for
571
578
  * @example
572
- * ```lua
573
- * local node = gui.get_node("anim_node")
574
- * gui.cancel_flipbook(node)
579
+ * ```ts
580
+ * const node = gui.get_node("anim_node");
581
+ * gui.cancel_flipbook(node);
575
582
  * ```
576
583
  */
577
584
  function cancel_flipbook(node: Opaque<"node">): void;
@@ -600,10 +607,10 @@ declare global {
600
607
  *
601
608
  * @param node - node to delete
602
609
  * @example
603
- * ```lua
604
- * Delete a particular node and any child nodes it might have:
605
- * local node = gui.get_node("my_node")
606
- * gui.delete_node(node)
610
+ * ```ts
611
+ * // Delete a particular node and any child nodes it might have:
612
+ * const node = gui.get_node("my_node");
613
+ * gui.delete_node(node);
607
614
  * ```
608
615
  */
609
616
  function delete_node(node: Opaque<"node">): void;
@@ -612,17 +619,19 @@ declare global {
612
619
  *
613
620
  * @param texture - texture id
614
621
  * @example
615
- * ```lua
616
- * function init(self)
617
- * -- Create a texture.
618
- * if gui.new_texture("temp_tx", 10, 10, "rgb", string.rep('\0', 10 * 10 * 3)) then
619
- * -- Do something with the texture.
620
- * ...
621
- *
622
- * -- Delete the texture
623
- * gui.delete_texture("temp_tx")
624
- * end
625
- * end
622
+ * ```ts
623
+ * export default defineScript({
624
+ * init(self) {
625
+ * // Create a texture.
626
+ * if (gui.new_texture("temp_tx", 10, 10, "rgb", "\0".repeat(10 * 10 * 3))) {
627
+ * // Do something with the texture.
628
+ * // ...
629
+ *
630
+ * // Delete the texture
631
+ * gui.delete_texture("temp_tx");
632
+ * }
633
+ * },
634
+ * });
626
635
  * ```
627
636
  */
628
637
  function delete_texture(texture: string | Hash): void;
@@ -634,11 +643,13 @@ declare global {
634
643
  *
635
644
  * @param self - reference to the script state to be used for storing data
636
645
  * @example
637
- * ```lua
638
- * function final(self)
639
- * -- report finalization
640
- * msg.post("my_friend_instance", "im_dead", {my_stats = self.some_value})
641
- * end
646
+ * ```ts
647
+ * export default defineScript({
648
+ * final(self) {
649
+ * // report finalization
650
+ * msg.post("my_friend_instance", "im_dead", { my_stats: self.some_value });
651
+ * },
652
+ * });
642
653
  * ```
643
654
  */
644
655
  function final(self: Opaque<"userdata">): void;
@@ -669,10 +680,10 @@ declare global {
669
680
  * @param options - optional options table (only applicable for material constants)
670
681
  * - `index` number index into array property (1 based)
671
682
  * @example
672
- * ```lua
673
- * Get properties on existing nodes:
674
- * local node = gui.get_node("my_box_node")
675
- * local node_position = gui.get(node, "position")
683
+ * ```ts
684
+ * // Get properties on existing nodes:
685
+ * const node = gui.get_node("my_box_node");
686
+ * const node_position = gui.get(node, "position");
676
687
  * ```
677
688
  */
678
689
  function get(node: Opaque<"node">, property: string | Hash | Opaque<"constant">, options?: { index?: number }): void;
@@ -798,14 +809,16 @@ declare global {
798
809
  * @param font_name - font of which to get the path hash
799
810
  * @returns path hash to resource
800
811
  * @example
801
- * ```lua
802
- * Get the text metrics for a text
803
- * function init(self)
804
- * local node = gui.get_node("name")
805
- * local font_name = gui.get_font(node)
806
- * local font = gui.get_font_resource(font_name)
807
- * local metrics = resource.get_text_metrics(font, "The quick brown fox\n jumps over the lazy dog")
808
- * end
812
+ * ```ts
813
+ * // Get the text metrics for a text
814
+ * export default defineScript({
815
+ * init(self) {
816
+ * const node = gui.get_node("name");
817
+ * const font_name = gui.get_font(node);
818
+ * const font = gui.get_font_resource(font_name);
819
+ * const metrics = resource.get_text_metrics(font, "The quick brown fox\n jumps over the lazy dog");
820
+ * },
821
+ * });
809
822
  * ```
810
823
  */
811
824
  function get_font_resource(font_name: Hash | string): Hash;
@@ -821,12 +834,12 @@ declare global {
821
834
  * @param node - the node to retrieve the id from
822
835
  * @returns the id of the node
823
836
  * @example
824
- * ```lua
825
- * Gets the id of a node:
826
- * local node = gui.get_node("my_node")
837
+ * ```ts
838
+ * // Gets the id of a node:
839
+ * const node = gui.get_node("my_node");
827
840
  *
828
- * local id = gui.get_id(node)
829
- * print(id) --> hash: [my_node]
841
+ * const id = gui.get_id(node);
842
+ * print(id); // => hash: [my_node]
830
843
  * ```
831
844
  */
832
845
  function get_id(node: Opaque<"node">): Hash;
@@ -838,16 +851,16 @@ declare global {
838
851
  * @param node - the node to retrieve the id from
839
852
  * @returns the index of the node
840
853
  * @example
841
- * ```lua
842
- * Compare the index order of two sibling nodes:
843
- * local node1 = gui.get_node("my_node_1")
844
- * local node2 = gui.get_node("my_node_2")
845
- *
846
- * if gui.get_index(node1) < gui.get_index(node2) then
847
- * -- node1 is drawn below node2
848
- * else
849
- * -- node2 is drawn below node1
850
- * end
854
+ * ```ts
855
+ * // Compare the index order of two sibling nodes:
856
+ * const node1 = gui.get_node("my_node_1");
857
+ * const node2 = gui.get_node("my_node_2");
858
+ *
859
+ * if (gui.get_index(node1) < gui.get_index(node2)) {
860
+ * // node1 is drawn below node2
861
+ * } else {
862
+ * // node2 is drawn below node1
863
+ * }
851
864
  * ```
852
865
  */
853
866
  function get_index(node: Opaque<"node">): number;
@@ -909,12 +922,12 @@ declare global {
909
922
  * @param node - node to get the material for
910
923
  * @returns material id
911
924
  * @example
912
- * ```lua
913
- * Getting the material for a node, and assign it to another node:
914
- * local node1 = gui.get_node("my_node")
915
- * local node2 = gui.get_node("other_node")
916
- * local node1_material = gui.get_material(node1)
917
- * gui.set_material(node2, node1_material)
925
+ * ```ts
926
+ * // Getting the material for a node, and assign it to another node:
927
+ * const node1 = gui.get_node("my_node");
928
+ * const node2 = gui.get_node("other_node");
929
+ * const node1_material = gui.get_material(node1);
930
+ * gui.set_material(node2, node1_material);
918
931
  * ```
919
932
  */
920
933
  function get_material(node: Opaque<"node">): Hash;
@@ -924,11 +937,11 @@ declare global {
924
937
  * @param id - id of the node to retrieve
925
938
  * @returns a new node instance
926
939
  * @example
927
- * ```lua
928
- * Gets a node by id and change its color:
929
- * local node = gui.get_node("my_node")
930
- * local red = vmath.vector4(1.0, 0.0, 0.0, 1.0)
931
- * gui.set_color(node, red)
940
+ * ```ts
941
+ * // Gets a node by id and change its color:
942
+ * const node = gui.get_node("my_node");
943
+ * const red = vmath.vector4(1.0, 0.0, 0.0, 1.0);
944
+ * gui.set_color(node, red);
932
945
  * ```
933
946
  */
934
947
  function get_node(id: string | Hash): Opaque<"node">;
@@ -1135,11 +1148,13 @@ declare global {
1135
1148
  *
1136
1149
  * @param self - reference to the script state to be used for storing data
1137
1150
  * @example
1138
- * ```lua
1139
- * function init(self)
1140
- * -- set up useful data
1141
- * self.my_value = 1
1142
- * end
1151
+ * ```ts
1152
+ * export default defineScript({
1153
+ * init() {
1154
+ * // set up useful data
1155
+ * return { my_value: 1 };
1156
+ * },
1157
+ * });
1143
1158
  * ```
1144
1159
  */
1145
1160
  function init(self: Opaque<"userdata">): void;
@@ -1216,40 +1231,41 @@ declare global {
1216
1231
  * @param buffer - texture data
1217
1232
  * @param flip - flip texture vertically
1218
1233
  * @example
1219
- * ```lua
1220
- * How to create a texture and apply it to a new box node:
1221
- * function init(self)
1222
- * local w = 200
1223
- * local h = 300
1224
- *
1225
- * -- A nice orange. String with the RGB values.
1226
- * local orange = string.char(0xff) .. string.char(0x80) .. string.char(0x10)
1227
- *
1228
- * -- Create the texture. Repeat the color string for each pixel.
1229
- * local ok, reason = gui.new_texture("orange_tx", w, h, "rgb", string.rep(orange, w * h))
1230
- * if ok then
1231
- * -- Create a box node and apply the texture to it.
1232
- * local n = gui.new_box_node(vmath.vector3(200, 200, 0), vmath.vector3(w, h, 0))
1233
- * gui.set_texture(n, "orange_tx")
1234
- * else
1235
- * -- Could not create texture for some reason...
1236
- * if reason == gui.RESULT_TEXTURE_ALREADY_EXISTS then
1237
- * ...
1238
- * else
1239
- * ...
1240
- * end
1241
- * end
1242
- * end
1243
- * ```How to create a texture using .astc format
1244
- *
1245
- * ```lua
1246
- * local path = "/assets/images/logo_4x4.astc"
1247
- * local buffer = sys.load_resource(path)
1248
- * local n = gui.new_box_node(pos, vmath.vector3(size, size, 0))
1249
- * -- size is read from the .astc buffer
1250
- * -- flip is not supported
1251
- * gui.new_texture(path, 0, 0, "astc", buffer, false)
1252
- * gui.set_texture(n, path)
1234
+ * ```ts
1235
+ * // How to create a texture and apply it to a new box node:
1236
+ * export default defineScript({
1237
+ * init(self) {
1238
+ * const w = 200;
1239
+ * const h = 300;
1240
+ *
1241
+ * // A nice orange. String with the RGB values.
1242
+ * const orange = String.fromCharCode(0xff, 0x80, 0x10);
1243
+ *
1244
+ * // Create the texture. Repeat the color string for each pixel.
1245
+ * const [ok, reason] = gui.new_texture("orange_tx", w, h, "rgb", orange.repeat(w * h));
1246
+ * if (ok) {
1247
+ * // Create a box node and apply the texture to it.
1248
+ * const n = gui.new_box_node(vmath.vector3(200, 200, 0), vmath.vector3(w, h, 0));
1249
+ * gui.set_texture(n, "orange_tx");
1250
+ * } else {
1251
+ * // Could not create texture for some reason...
1252
+ * if (reason === gui.RESULT_TEXTURE_ALREADY_EXISTS) {
1253
+ * // ...
1254
+ * } else {
1255
+ * // ...
1256
+ * }
1257
+ * }
1258
+ * },
1259
+ * });
1260
+ *
1261
+ * // How to create a texture using .astc format
1262
+ * const path = "/assets/images/logo_4x4.astc";
1263
+ * const buffer = sys.load_resource(path);
1264
+ * const n = gui.new_box_node(pos, vmath.vector3(size, size, 0));
1265
+ * // size is read from the .astc buffer
1266
+ * // flip is not supported
1267
+ * gui.new_texture(path, 0, 0, "astc", buffer, false);
1268
+ * gui.set_texture(n, path);
1253
1269
  * ```
1254
1270
  */
1255
1271
  function new_texture(texture_id: string | Hash, width: number, height: number, type: string | Opaque<"constant">, buffer: string, flip: boolean): LuaMultiReturn<[boolean, number]>;
@@ -1420,24 +1436,26 @@ declare global {
1420
1436
  * `playback_rate`
1421
1437
  * number The rate with which the animation will be played. Must be positive
1422
1438
  * @example
1423
- * ```lua
1424
- * Set the texture of a node to a flipbook animation from an atlas:
1425
- * local function anim_callback(self, node)
1426
- * -- Take action after animation has played.
1427
- * end
1428
- *
1429
- * function init(self)
1430
- * -- Create a new node and set the texture to a flipbook animation
1431
- * local node = gui.get_node("button_node")
1432
- * gui.set_texture(node, "gui_sprites")
1433
- * gui.play_flipbook(node, "animated_button")
1434
- * end
1435
- *
1436
- * Set the texture of a node to an image from an atlas:
1437
- * -- Create a new node and set the texture to a "button.png" from atlas
1438
- * local node = gui.get_node("button_node")
1439
- * gui.set_texture(node, "gui_sprites")
1440
- * gui.play_flipbook(node, "button")
1439
+ * ```ts
1440
+ * // Set the texture of a node to a flipbook animation from an atlas:
1441
+ * function anim_callback(self, node) {
1442
+ * // Take action after animation has played.
1443
+ * }
1444
+ *
1445
+ * export default defineScript({
1446
+ * init(self) {
1447
+ * // Create a new node and set the texture to a flipbook animation
1448
+ * const node = gui.get_node("button_node");
1449
+ * gui.set_texture(node, "gui_sprites");
1450
+ * gui.play_flipbook(node, "animated_button");
1451
+ * },
1452
+ * });
1453
+ *
1454
+ * // Set the texture of a node to an image from an atlas:
1455
+ * // Create a new node and set the texture to a "button.png" from atlas
1456
+ * const node = gui.get_node("button_node");
1457
+ * gui.set_texture(node, "gui_sprites");
1458
+ * gui.play_flipbook(node, "button");
1441
1459
  * ```
1442
1460
  */
1443
1461
  function play_flipbook(node: Opaque<"node">, animation: string | Hash, complete_function?: (self: unknown, node: unknown) => void, play_properties?: { offset?: number; playback_rate?: number }): void;
@@ -1459,19 +1477,21 @@ declare global {
1459
1477
  * - `particlefx.EMITTER_STATE_SPAWNING`
1460
1478
  * - `particlefx.EMITTER_STATE_POSTSPAWN`
1461
1479
  * @example
1462
- * ```lua
1463
- * How to play a particle fx when a gui node is created.
1464
- * The callback receives the gui node, the hash of the id
1465
- * of the emitter, and the new state of the emitter as particlefx.EMITTER_STATE_.
1466
- * local function emitter_state_change(self, node, emitter, state)
1467
- * if emitter == hash("exhaust") and state == particlefx.EMITTER_STATE_POSTSPAWN then
1468
- * -- exhaust is done spawning particles...
1469
- * end
1470
- * end
1471
- *
1472
- * function init(self)
1473
- * gui.play_particlefx(gui.get_node("particlefx"), emitter_state_change)
1474
- * end
1480
+ * ```ts
1481
+ * // How to play a particle fx when a gui node is created.
1482
+ * // The callback receives the gui node, the hash of the id
1483
+ * // of the emitter, and the new state of the emitter as particlefx.EMITTER_STATE_.
1484
+ * function emitter_state_change(self, node, emitter, state) {
1485
+ * if (emitter === hash("exhaust") && state === particlefx.EMITTER_STATE_POSTSPAWN) {
1486
+ * // exhaust is done spawning particles...
1487
+ * }
1488
+ * }
1489
+ *
1490
+ * export default defineScript({
1491
+ * init(self) {
1492
+ * gui.play_particlefx(gui.get_node("particlefx"), emitter_state_change);
1493
+ * },
1494
+ * });
1475
1495
  * ```
1476
1496
  */
1477
1497
  function play_particlefx(node: Opaque<"node">, emitter_state_function?: (self: unknown, node: unknown, emitter: unknown, state: unknown) => void): void;
@@ -1484,10 +1504,10 @@ declare global {
1484
1504
  *
1485
1505
  * @param node - node to reset the material for
1486
1506
  * @example
1487
- * ```lua
1488
- * Resetting the material for a node:
1489
- * local node = gui.get_node("my_node")
1490
- * gui.reset_material(node)
1507
+ * ```ts
1508
+ * // Resetting the material for a node:
1509
+ * const node = gui.get_node("my_node");
1510
+ * gui.reset_material(node);
1491
1511
  * ```
1492
1512
  */
1493
1513
  function reset_material(node: Opaque<"node">): void;
@@ -1541,49 +1561,49 @@ declare global {
1541
1561
  * - `index` number index into array property (1 based)
1542
1562
  * - `key` hash name of internal property
1543
1563
  * @example
1544
- * ```lua
1545
- * Updates the position property on an existing node:
1546
- * local node = gui.get_node("my_box_node")
1547
- * local node_position = gui.get(node, "position")
1548
- * gui.set(node, "position.x", node_position.x + 128)
1549
- *
1550
- * Updates the rotation property on an existing node:
1551
- * local node = gui.get_node("my_box_node")
1552
- * gui.set(node, "rotation", vmath.quat_rotation_z(math.rad(45)))
1553
- * -- this is equivalent to:
1554
- * gui.set(node, "euler.z", 45)
1555
- * -- or using the entire vector:
1556
- * gui.set(node, "euler", vmath.vector3(0,0,45))
1557
- * -- or using the set_rotation
1558
- * gui.set_rotation(node, vmath.vector3(0,0,45))
1559
- *
1560
- * Sets various material constants for a node:
1561
- * local node = gui.get_node("my_box_node")
1562
- * gui.set(node, "tint", vmath.vector4(1,0,0,1))
1563
- * -- matrix4 is also supported
1564
- * gui.set(node, "light_matrix", vmath.matrix4())
1565
- * -- update a constant in an array at position 4. the array is specified in the shader as:
1566
- * -- uniform vec4 tint_array[4]; // lua is 1 based, shader is 0 based
1567
- * gui.set(node, "tint_array", vmath.vector4(1,0,0,1), { index = 4 })
1568
- * -- update a matrix constant in an array at position 4. the array is specified in the shader as:
1569
- * -- uniform mat4 light_matrix_array[4];
1570
- * gui.set(node, "light_matrix_array", vmath.matrix4(), { index = 4 })
1571
- * -- update a sub-element in a constant
1572
- * gui.set(node, "tint.x", 1)
1573
- * -- update a sub-element in an array constant at position 4
1574
- * gui.set(node, "tint_array.x", 1, {index = 4})
1575
- *
1576
- * Set a named property
1577
- * function on_message(self, message_id, message, sender)
1578
- * if message_id == hash("set_font") then
1579
- * gui.set(msg.url(), "fonts", message.font, {key = "my_font_name"})
1580
- * gui.set_font(gui.get_node("text"), "my_font_name")
1581
- * elseif message_id == hash("set_texture") then
1582
- * gui.set(msg.url(), "textures", message.texture, {key = "my_texture"})
1583
- * gui.set_texture(gui.get_node("box"), "my_texture")
1584
- * gui.play_flipbook(gui.get_node("box"), "logo_256")
1585
- * end
1586
- * end
1564
+ * ```ts
1565
+ * // Updates the position property on an existing node:
1566
+ * const node = gui.get_node("my_box_node");
1567
+ * const node_position = gui.get(node, "position");
1568
+ * gui.set(node, "position.x", node_position.x + 128);
1569
+ *
1570
+ * // Updates the rotation property on an existing node:
1571
+ * gui.set(node, "rotation", vmath.quat_rotation_z(math.rad(45)));
1572
+ * // this is equivalent to:
1573
+ * gui.set(node, "euler.z", 45);
1574
+ * // or using the entire vector:
1575
+ * gui.set(node, "euler", vmath.vector3(0, 0, 45));
1576
+ * // or using the set_rotation
1577
+ * gui.set_rotation(node, vmath.vector3(0, 0, 45));
1578
+ *
1579
+ * // Sets various material constants for a node:
1580
+ * gui.set(node, "tint", vmath.vector4(1, 0, 0, 1));
1581
+ * // matrix4 is also supported
1582
+ * gui.set(node, "light_matrix", vmath.matrix4());
1583
+ * // update a constant in an array at position 4. the array is specified in the shader as:
1584
+ * // uniform vec4 tint_array[4]; // lua is 1 based, shader is 0 based
1585
+ * gui.set(node, "tint_array", vmath.vector4(1, 0, 0, 1), { index: 4 });
1586
+ * // update a matrix constant in an array at position 4. the array is specified in the shader as:
1587
+ * // uniform mat4 light_matrix_array[4];
1588
+ * gui.set(node, "light_matrix_array", vmath.matrix4(), { index: 4 });
1589
+ * // update a sub-element in a constant
1590
+ * gui.set(node, "tint.x", 1);
1591
+ * // update a sub-element in an array constant at position 4
1592
+ * gui.set(node, "tint_array.x", 1, { index: 4 });
1593
+ *
1594
+ * // Set a named property
1595
+ * export default defineScript({
1596
+ * on_message(self, message_id, message) {
1597
+ * if (message_id === hash("set_font")) {
1598
+ * gui.set(msg.url(), "fonts", message.font, { key: "my_font_name" });
1599
+ * gui.set_font(gui.get_node("text"), "my_font_name");
1600
+ * } else if (message_id === hash("set_texture")) {
1601
+ * gui.set(msg.url(), "textures", message.texture, { key: "my_texture" });
1602
+ * gui.set_texture(gui.get_node("box"), "my_texture");
1603
+ * gui.play_flipbook(gui.get_node("box"), "logo_256");
1604
+ * }
1605
+ * },
1606
+ * });
1587
1607
  * ```
1588
1608
  */
1589
1609
  function set(node: Opaque<"node"> | Url, property: string | Hash | Opaque<"constant">, value: number | Vector4 | Vector3 | Quaternion, options?: { index?: number; key?: Hash }): void;
@@ -1716,12 +1736,12 @@ declare global {
1716
1736
  * @param node - node to set the id for
1717
1737
  * @param id - id to set
1718
1738
  * @example
1719
- * ```lua
1720
- * Create a new node and set its id:
1721
- * local pos = vmath.vector3(100, 100, 0)
1722
- * local size = vmath.vector3(100, 100, 0)
1723
- * local node = gui.new_box_node(pos, size)
1724
- * gui.set_id(node, "my_new_node")
1739
+ * ```ts
1740
+ * // Create a new node and set its id:
1741
+ * const pos = vmath.vector3(100, 100, 0);
1742
+ * const size = vmath.vector3(100, 100, 0);
1743
+ * const node = gui.new_box_node(pos, size);
1744
+ * gui.set_id(node, "my_new_node");
1725
1745
  * ```
1726
1746
  */
1727
1747
  function set_id(node: Opaque<"node">, id: string | Hash): void;
@@ -1780,10 +1800,10 @@ declare global {
1780
1800
  * @param node - node to set material for
1781
1801
  * @param material - material id
1782
1802
  * @example
1783
- * ```lua
1784
- * Assign an existing material to a node:
1785
- * local node = gui.get_node("my_node")
1786
- * gui.set_material(node, "my_material")
1803
+ * ```ts
1804
+ * // Assign an existing material to a node:
1805
+ * const node = gui.get_node("my_node");
1806
+ * gui.set_material(node, "my_material");
1787
1807
  * ```
1788
1808
  */
1789
1809
  function set_material(node: Opaque<"node">, material: string | Hash): void;
@@ -1946,24 +1966,22 @@ declare global {
1946
1966
  * @param node - node to set texture for
1947
1967
  * @param texture - texture id
1948
1968
  * @example
1949
- * ```lua
1950
- * To set a texture (or animation) from an atlas:
1951
- * local node = gui.get_node("box_node")
1952
- * gui.set_texture(node, "my_atlas")
1953
- * gui.play_flipbook(node, "image")
1954
- *
1955
- * Set a dynamically created texture to a node. Note that there is only
1956
- * one texture image in this case so gui.set_texture() is
1957
- * sufficient.
1958
- * local w = 200
1959
- * local h = 300
1960
- * -- A nice orange. String with the RGB values.
1961
- * local orange = string.char(0xff) .. string.char(0x80) .. string.char(0x10)
1962
- * -- Create the texture. Repeat the color string for each pixel.
1963
- * if gui.new_texture("orange_tx", w, h, "rgb", string.rep(orange, w * h)) then
1964
- * local node = gui.get_node("box_node")
1965
- * gui.set_texture(node, "orange_tx")
1966
- * end
1969
+ * ```ts
1970
+ * // To set a texture (or animation) from an atlas:
1971
+ * const node = gui.get_node("box_node");
1972
+ * gui.set_texture(node, "my_atlas");
1973
+ * gui.play_flipbook(node, "image");
1974
+ *
1975
+ * // Set a dynamically created texture to a node. Note that there is only
1976
+ * // one texture image in this case so gui.set_texture() is sufficient.
1977
+ * const w = 200;
1978
+ * const h = 300;
1979
+ * // A nice orange. String with the RGB values.
1980
+ * const orange = String.fromCharCode(0xff, 0x80, 0x10);
1981
+ * // Create the texture. Repeat the color string for each pixel.
1982
+ * if (gui.new_texture("orange_tx", w, h, "rgb", orange.repeat(w * h))) {
1983
+ * gui.set_texture(node, "orange_tx");
1984
+ * }
1967
1985
  * ```
1968
1986
  */
1969
1987
  function set_texture(node: Opaque<"node">, texture: string | Hash): void;
@@ -1982,30 +2000,32 @@ declare global {
1982
2000
  * @param flip - flip texture vertically
1983
2001
  * @returns setting the data was successful
1984
2002
  * @example
1985
- * ```lua
1986
- * function init(self)
1987
- * local w = 200
1988
- * local h = 300
1989
- *
1990
- * -- Create a dynamic texture, all white.
1991
- * if gui.new_texture("dynamic_tx", w, h, "rgb", string.rep(string.char(0xff), w * h * 3)) then
1992
- * -- Create a box node and apply the texture to it.
1993
- * local n = gui.new_box_node(vmath.vector3(200, 200, 0), vmath.vector3(w, h, 0))
1994
- * gui.set_texture(n, "dynamic_tx")
1995
- *
1996
- * ...
1997
- *
1998
- * -- Change the data in the texture to a nice orange.
1999
- * local orange = string.char(0xff) .. string.char(0x80) .. string.char(0x10)
2000
- * if gui.set_texture_data("dynamic_tx", w, h, "rgb", string.rep(orange, w * h)) then
2001
- * -- Go on and to more stuff
2002
- * ...
2003
- * end
2004
- * else
2005
- * -- Something went wrong
2006
- * ...
2007
- * end
2008
- * end
2003
+ * ```ts
2004
+ * export default defineScript({
2005
+ * init(self) {
2006
+ * const w = 200;
2007
+ * const h = 300;
2008
+ *
2009
+ * // Create a dynamic texture, all white.
2010
+ * if (gui.new_texture("dynamic_tx", w, h, "rgb", String.fromCharCode(0xff).repeat(w * h * 3))) {
2011
+ * // Create a box node and apply the texture to it.
2012
+ * const n = gui.new_box_node(vmath.vector3(200, 200, 0), vmath.vector3(w, h, 0));
2013
+ * gui.set_texture(n, "dynamic_tx");
2014
+ *
2015
+ * // ...
2016
+ *
2017
+ * // Change the data in the texture to a nice orange.
2018
+ * const orange = String.fromCharCode(0xff, 0x80, 0x10);
2019
+ * if (gui.set_texture_data("dynamic_tx", w, h, "rgb", orange.repeat(w * h))) {
2020
+ * // Go on and to more stuff
2021
+ * // ...
2022
+ * }
2023
+ * } else {
2024
+ * // Something went wrong
2025
+ * // ...
2026
+ * }
2027
+ * },
2028
+ * });
2009
2029
  * ```
2010
2030
  */
2011
2031
  function set_texture_data(texture: string | Hash, width: number, height: number, type: string | Opaque<"constant">, buffer: string, flip: boolean): boolean;