@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.
- package/api-targets.json +1 -1
- package/generated/b2d.d.ts +3 -0
- package/generated/buffer.d.ts +44 -38
- package/generated/builtin-messages.d.ts +1 -1
- package/generated/camera.d.ts +3 -0
- package/generated/collectionfactory.d.ts +47 -40
- package/generated/collectionproxy.d.ts +23 -18
- package/generated/crash.d.ts +3 -0
- package/generated/factory.d.ts +32 -24
- package/generated/go.d.ts +123 -124
- package/generated/graphics.d.ts +3 -0
- package/generated/gui.d.ts +303 -283
- package/generated/http.d.ts +26 -16
- package/generated/iac.d.ts +3 -0
- package/generated/iap.d.ts +6 -3
- package/generated/image.d.ts +30 -26
- package/generated/json.d.ts +36 -32
- package/generated/kinds/gui-script.d.ts +7 -5
- package/generated/kinds/render-script.d.ts +7 -5
- package/generated/kinds/script.d.ts +7 -5
- package/generated/label.d.ts +16 -9
- package/generated/liveupdate.d.ts +29 -26
- package/generated/model.d.ts +57 -45
- package/generated/msg.d.ts +3 -0
- package/generated/particlefx.d.ts +50 -34
- package/generated/physics.d.ts +153 -133
- package/generated/profiler.d.ts +45 -41
- package/generated/push.d.ts +5 -2
- package/generated/render.d.ts +410 -349
- package/generated/resource.d.ts +619 -572
- package/generated/socket.d.ts +49 -33
- package/generated/sound.d.ts +83 -72
- package/generated/sprite.d.ts +3 -0
- package/generated/sys.d.ts +198 -189
- package/generated/tilemap.d.ts +43 -39
- package/generated/timer.d.ts +42 -36
- package/generated/vmath.d.ts +22 -0
- package/generated/webview.d.ts +3 -0
- package/generated/window.d.ts +23 -17
- package/generated/zlib.d.ts +15 -12
- package/index.d.ts +3 -1
- package/package.json +6 -2
- package/scripts/fidelity-audit.ts +61 -1
- package/scripts/fidelity-baseline.json +10 -10
- package/scripts/ref-doc-delta.ts +143 -0
- package/scripts/regen.ts +18 -9
- package/src/core-types.ts +14 -0
- package/src/emit-dts.ts +219 -13
- package/src/engine-globals.d.ts +2 -0
- package/src/go-overloads.d.ts +43 -0
- package/src/index.ts +5 -0
- package/src/lifecycle.ts +157 -16
- package/src/publish-dts.ts +1 -1
package/generated/gui.d.ts
CHANGED
|
@@ -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
|
-
* ```
|
|
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))
|
|
492
|
-
* gui.animate(node, gui.PROP_COLOR, vmath.vector4(1, 1, 1, 1), gui.EASING_INOUTQUAD, 0.5)
|
|
493
|
-
*
|
|
494
|
-
* How to start a sequenced animation where the node fades in to white during 0.5
|
|
495
|
-
*
|
|
496
|
-
*
|
|
497
|
-
*
|
|
498
|
-
*
|
|
499
|
-
*
|
|
500
|
-
*
|
|
501
|
-
*
|
|
502
|
-
*
|
|
503
|
-
*
|
|
504
|
-
* gui.
|
|
505
|
-
*
|
|
506
|
-
* gui.
|
|
507
|
-
*
|
|
508
|
-
*
|
|
509
|
-
*
|
|
510
|
-
*
|
|
511
|
-
*
|
|
512
|
-
*
|
|
513
|
-
*
|
|
514
|
-
*
|
|
515
|
-
*
|
|
516
|
-
*
|
|
517
|
-
*
|
|
518
|
-
*
|
|
519
|
-
*
|
|
520
|
-
*
|
|
521
|
-
*
|
|
522
|
-
*
|
|
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
|
-
* ```
|
|
546
|
-
* Start an animation of the position property of a node, then cancel parts of
|
|
547
|
-
* the animation:
|
|
548
|
-
*
|
|
549
|
-
*
|
|
550
|
-
*
|
|
551
|
-
* gui.animate(node, "position", pos, go.EASING_LINEAR, 2)
|
|
552
|
-
* ...
|
|
553
|
-
*
|
|
554
|
-
* gui.cancel_animations(node, "position.x")
|
|
555
|
-
*
|
|
556
|
-
* Cancels all property animations on a node in a single call:
|
|
557
|
-
*
|
|
558
|
-
*
|
|
559
|
-
* gui.animate(node, "
|
|
560
|
-
*
|
|
561
|
-
*
|
|
562
|
-
*
|
|
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
|
-
* ```
|
|
573
|
-
*
|
|
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
|
-
* ```
|
|
604
|
-
* Delete a particular node and any child nodes it might have:
|
|
605
|
-
*
|
|
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
|
-
* ```
|
|
616
|
-
*
|
|
617
|
-
*
|
|
618
|
-
*
|
|
619
|
-
*
|
|
620
|
-
*
|
|
621
|
-
*
|
|
622
|
-
*
|
|
623
|
-
*
|
|
624
|
-
*
|
|
625
|
-
*
|
|
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
|
-
* ```
|
|
638
|
-
*
|
|
639
|
-
*
|
|
640
|
-
*
|
|
641
|
-
*
|
|
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
|
-
* ```
|
|
673
|
-
* Get properties on existing nodes:
|
|
674
|
-
*
|
|
675
|
-
*
|
|
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
|
-
* ```
|
|
802
|
-
* Get the text metrics for a text
|
|
803
|
-
*
|
|
804
|
-
*
|
|
805
|
-
*
|
|
806
|
-
*
|
|
807
|
-
*
|
|
808
|
-
*
|
|
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
|
-
* ```
|
|
825
|
-
* Gets the id of a node:
|
|
826
|
-
*
|
|
837
|
+
* ```ts
|
|
838
|
+
* // Gets the id of a node:
|
|
839
|
+
* const node = gui.get_node("my_node");
|
|
827
840
|
*
|
|
828
|
-
*
|
|
829
|
-
* print(id)
|
|
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
|
-
* ```
|
|
842
|
-
* Compare the index order of two sibling nodes:
|
|
843
|
-
*
|
|
844
|
-
*
|
|
845
|
-
*
|
|
846
|
-
* if gui.get_index(node1) < gui.get_index(node2)
|
|
847
|
-
*
|
|
848
|
-
* else
|
|
849
|
-
*
|
|
850
|
-
*
|
|
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
|
-
* ```
|
|
913
|
-
* Getting the material for a node, and assign it to another node:
|
|
914
|
-
*
|
|
915
|
-
*
|
|
916
|
-
*
|
|
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
|
-
* ```
|
|
928
|
-
* Gets a node by id and change its color:
|
|
929
|
-
*
|
|
930
|
-
*
|
|
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
|
-
* ```
|
|
1139
|
-
*
|
|
1140
|
-
*
|
|
1141
|
-
*
|
|
1142
|
-
*
|
|
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
|
-
* ```
|
|
1220
|
-
* How to create a texture and apply it to a new box node:
|
|
1221
|
-
*
|
|
1222
|
-
*
|
|
1223
|
-
*
|
|
1224
|
-
*
|
|
1225
|
-
*
|
|
1226
|
-
*
|
|
1227
|
-
*
|
|
1228
|
-
*
|
|
1229
|
-
*
|
|
1230
|
-
*
|
|
1231
|
-
*
|
|
1232
|
-
*
|
|
1233
|
-
*
|
|
1234
|
-
*
|
|
1235
|
-
*
|
|
1236
|
-
*
|
|
1237
|
-
*
|
|
1238
|
-
*
|
|
1239
|
-
*
|
|
1240
|
-
*
|
|
1241
|
-
*
|
|
1242
|
-
*
|
|
1243
|
-
*
|
|
1244
|
-
*
|
|
1245
|
-
*
|
|
1246
|
-
*
|
|
1247
|
-
*
|
|
1248
|
-
*
|
|
1249
|
-
*
|
|
1250
|
-
*
|
|
1251
|
-
*
|
|
1252
|
-
* gui.
|
|
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
|
-
* ```
|
|
1424
|
-
* Set the texture of a node to a flipbook animation from an atlas:
|
|
1425
|
-
*
|
|
1426
|
-
*
|
|
1427
|
-
*
|
|
1428
|
-
*
|
|
1429
|
-
*
|
|
1430
|
-
*
|
|
1431
|
-
*
|
|
1432
|
-
* gui.
|
|
1433
|
-
* gui.
|
|
1434
|
-
*
|
|
1435
|
-
*
|
|
1436
|
-
*
|
|
1437
|
-
*
|
|
1438
|
-
*
|
|
1439
|
-
*
|
|
1440
|
-
* gui.
|
|
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
|
-
* ```
|
|
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
|
-
*
|
|
1467
|
-
* if emitter
|
|
1468
|
-
*
|
|
1469
|
-
*
|
|
1470
|
-
*
|
|
1471
|
-
*
|
|
1472
|
-
*
|
|
1473
|
-
*
|
|
1474
|
-
*
|
|
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
|
-
* ```
|
|
1488
|
-
* Resetting the material for a node:
|
|
1489
|
-
*
|
|
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
|
-
* ```
|
|
1545
|
-
* Updates the position property on an existing node:
|
|
1546
|
-
*
|
|
1547
|
-
*
|
|
1548
|
-
* gui.set(node, "position.x", node_position.x + 128)
|
|
1549
|
-
*
|
|
1550
|
-
* Updates the rotation property on an existing node:
|
|
1551
|
-
*
|
|
1552
|
-
*
|
|
1553
|
-
*
|
|
1554
|
-
*
|
|
1555
|
-
*
|
|
1556
|
-
*
|
|
1557
|
-
*
|
|
1558
|
-
*
|
|
1559
|
-
*
|
|
1560
|
-
*
|
|
1561
|
-
*
|
|
1562
|
-
* gui.set(node, "
|
|
1563
|
-
*
|
|
1564
|
-
*
|
|
1565
|
-
*
|
|
1566
|
-
*
|
|
1567
|
-
*
|
|
1568
|
-
*
|
|
1569
|
-
*
|
|
1570
|
-
* gui.set(node, "
|
|
1571
|
-
*
|
|
1572
|
-
* gui.set(node, "
|
|
1573
|
-
*
|
|
1574
|
-
*
|
|
1575
|
-
*
|
|
1576
|
-
*
|
|
1577
|
-
*
|
|
1578
|
-
*
|
|
1579
|
-
*
|
|
1580
|
-
*
|
|
1581
|
-
*
|
|
1582
|
-
*
|
|
1583
|
-
*
|
|
1584
|
-
*
|
|
1585
|
-
*
|
|
1586
|
-
*
|
|
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
|
-
* ```
|
|
1720
|
-
* Create a new node and set its id:
|
|
1721
|
-
*
|
|
1722
|
-
*
|
|
1723
|
-
*
|
|
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
|
-
* ```
|
|
1784
|
-
* Assign an existing material to a node:
|
|
1785
|
-
*
|
|
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
|
-
* ```
|
|
1950
|
-
* To set a texture (or animation) from an atlas:
|
|
1951
|
-
*
|
|
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
|
-
*
|
|
1958
|
-
*
|
|
1959
|
-
*
|
|
1960
|
-
*
|
|
1961
|
-
*
|
|
1962
|
-
*
|
|
1963
|
-
*
|
|
1964
|
-
*
|
|
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
|
-
* ```
|
|
1986
|
-
*
|
|
1987
|
-
*
|
|
1988
|
-
*
|
|
1989
|
-
*
|
|
1990
|
-
*
|
|
1991
|
-
*
|
|
1992
|
-
*
|
|
1993
|
-
*
|
|
1994
|
-
*
|
|
1995
|
-
*
|
|
1996
|
-
*
|
|
1997
|
-
*
|
|
1998
|
-
*
|
|
1999
|
-
*
|
|
2000
|
-
*
|
|
2001
|
-
*
|
|
2002
|
-
*
|
|
2003
|
-
*
|
|
2004
|
-
*
|
|
2005
|
-
*
|
|
2006
|
-
*
|
|
2007
|
-
*
|
|
2008
|
-
*
|
|
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;
|