forked from ts-defold/types
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.d.ts
9970 lines (8572 loc) · 330 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/** @noSelfInFile */
/// <reference types="lua-types/5.1" />
/// <reference types="lua-types/special/jit-only" />
/// <reference types="@typescript-to-lua/language-extensions" />
/// <reference types="./deprecated.d.ts" />
/// <reference types="./socket.d.ts" />
// DEFOLD. stable version 1.9.5 (87b6907759f7b8dff830d54b2250b8d721bde291)
// =^..^= =^..^= =^..^= =^..^= =^..^= =^..^= =^..^= //
/**
* A unique identifier used to reference resources, messages, properties, and other entities within the game.
* @see {@link https://defold.com/manuals/addressing/#hashed-identifiers|Addressing Manual}
*/
declare type hash = Readonly<
LuaUserdata & {
readonly __hash__: unique symbol;
}
>;
/**
* A reference to game resources, such as game objects, components, and assets.
* @see {@link https://defold.com/manuals/addressing/|Addressing Manual}
*/
declare type url = {
socket: hash;
path: hash;
fragment: hash | undefined;
};
/**
* A representation of a GUI object.
* @see {@link https://defold.com/manuals/gui/|GUI Manual}
*/
declare type node = Readonly<
LuaUserdata & {
readonly __node__: unique symbol;
}
>;
/**
* A block of memory that can store binary data.
* @see {@link https://defold.com/manuals/buffer/|Buffer Manual}
*/
declare type buffer = object;
/**
* Render pipeline predicate.
* @see {@link https://defold.com/manuals/render/|Render Manual}
*/
declare type predicate = Readonly<
LuaUserdata & {
readonly __predicate__: unique symbol;
}
>;
/**
* Render pipeline target.
* @see {@link https://defold.com/manuals/render/|Render Manual}
*/
declare type rendertarget = Readonly<
LuaUserdata & {
readonly __rendertarget__: unique symbol;
}
>;
/**
* A data stream derived from a buffer.
* @see {@link https://defold.com/ref/stable/buffer/#buffer.get_stream:buffer-stream_name|API Documentation}
*/
declare type bufferstream = LuaUserdata & number[] & object;
/** @see {@link https://defold.com/ref/stable/vmath/|API Documentation} */
declare namespace vmath {
export type vector3 = number & {
/**
* Addition Operator for Vector3
* @see {@link https://typescripttolua.github.io/docs/advanced/language-extensions#operator-map-types|TSTL Docs}
*/
add: LuaAdditionMethod<vmath.vector3, vmath.vector3>;
/**
* Subtraction Operator for Vector3
* @see {@link https://typescripttolua.github.io/docs/advanced/language-extensions#operator-map-types|TSTL Docs}
*/
sub: LuaSubtractionMethod<vmath.vector3, vmath.vector3>;
/**
* Multiplication Operator for Vector3
* @see {@link https://typescripttolua.github.io/docs/advanced/language-extensions#operator-map-types|TSTL Docs}
*/
mul: LuaMultiplicationMethod<number, vmath.vector3>;
/**
* Division Operator for Vector3
* @see {@link https://typescripttolua.github.io/docs/advanced/language-extensions#operator-map-types|TSTL Docs}
*/
div: LuaDivisionMethod<number, vmath.vector3>;
/**
* Negation Operator for Vector3
* @see {@link https://typescripttolua.github.io/docs/advanced/language-extensions#operator-map-types|TSTL Docs}
*/
unm: LuaNegationMethod<vmath.vector3>;
x: number;
y: number;
z: number;
};
export type vector4 = number & {
/**
* Addition Operator for Vector4
* @see {@link https://typescripttolua.github.io/docs/advanced/language-extensions#operator-map-types|TSTL Docs}
*/
add: LuaAdditionMethod<vmath.vector4, vmath.vector4>;
/**
* Subtraction Operator for Vector4
* @see {@link https://typescripttolua.github.io/docs/advanced/language-extensions#operator-map-types|TSTL Docs}
*/
sub: LuaSubtractionMethod<vmath.vector4, vmath.vector4>;
/**
* Multiplication Operator for Vector4
* @see {@link https://typescripttolua.github.io/docs/advanced/language-extensions#operator-map-types|TSTL Docs}
*/
mul: LuaMultiplicationMethod<number, vmath.vector4>;
/**
* Division Operator for Vector4
* @see {@link https://typescripttolua.github.io/docs/advanced/language-extensions#operator-map-types|TSTL Docs}
*/
div: LuaDivisionMethod<number, vmath.vector4>;
/**
* Negation Operator for Vector4
* @see {@link https://typescripttolua.github.io/docs/advanced/language-extensions#operator-map-types|TSTL Docs}
*/
unm: LuaNegationMethod<vmath.vector4>;
x: number;
y: number;
z: number;
w: number;
};
export type matrix4 = number & {
/**
* Multiplication Operator for Matrix4
* @see {@link https://typescripttolua.github.io/docs/advanced/language-extensions#operator-map-types|TSTL Docs}
*/
mul: LuaMultiplicationMethod<number, vmath.matrix4> & LuaMultiplicationMethod<vmath.vector4, vmath.vector4>;
c0: vmath.vector4;
c1: vmath.vector4;
c2: vmath.vector4;
c3: vmath.vector4;
m01: number;
m02: number;
m03: number;
m04: number;
m11: number;
m12: number;
m13: number;
m14: number;
m21: number;
m22: number;
m23: number;
m24: number;
m31: number;
m32: number;
m33: number;
m34: number;
};
export type quaternion = number & {
/**
* Multiplication Operator for Matrix4
* @see {@link https://typescripttolua.github.io/docs/advanced/language-extensions#operator-map-types|TSTL Docs}
*/
mul: LuaMultiplicationMethod<vmath.quaternion, vmath.quaternion>;
x: number;
y: number;
z: number;
w: number;
};
}
// =^..^= =^..^= =^..^= =^..^= =^..^= =^..^= =^..^= //
/**
* All ids in the engine are represented as hashes, so a string needs to be hashed
* before it can be compared with an id.
* @param s string to hash
* @returns hash a hashed string
* @see {@link https://defold.com/ref/stable/builtins/#hash:s|API Documentation}
*/
declare function hash(s: string): hash;
/**
* Returns a hexadecimal representation of a hash value.
* The returned string is always padded with leading zeros.
* @param h hash value to get hex string for
* @returns hex hex representation of the hash
* @see {@link https://defold.com/ref/stable/builtins/#hash_to_hex:h|API Documentation}
*/
declare function hash_to_hex(h: hash): string;
/**
* Pretty printing of Lua values. This function prints Lua values
* in a manner similar to +print()+, but will also recurse into tables
* and pretty print them. There is a limit to how deep the function
* will recurse.
* @param v value to print
* @see {@link https://defold.com/ref/stable/builtins/#pprint:v|API Documentation}
*/
declare function pprint(...v: any[]): void;
// =^..^= =^..^= =^..^= =^..^= =^..^= =^..^= =^..^= //
/** @see {@link https://defold.com/ref/stable/socket/|API Documentation} */
declare namespace socket {}
// =^..^= =^..^= =^..^= =^..^= =^..^= =^..^= =^..^= //
/** @see {@link https://defold.com/ref/stable/b2d/|Box2D Documentation} @since 1.8.0 */
declare namespace b2d {
/**
* Get the Box2D body from a collision object
* @param url the url to the game object collision component
* @returns body the body if successful. Otherwise `undefined`.
* @see {@link https://defold.com/ref/stable/b2d/#b2d.get_body|API Documentation}
*/
export function get_body(
url: hash | url | string,
): typeof b2d.body | undefined;
/**
* Get the Box2D world from the current collection
* @returns world the world if successful. Otherwise `undefined`.
* @see {@link https://defold.com/ref/stable/b2d/#b2d.get_world|API Documentation}
*/
export function get_world(): AnyNotNil | undefined;
}
// =^..^= =^..^= =^..^= =^..^= =^..^= =^..^= =^..^= //
/** @see {@link https://defold.com/ref/stable/b2d.body/|Box2D b2Body Documentation} */
declare namespace b2d.body {
type BodyConstant = number & { readonly __brand: 'b2d.body.B2' };
/**
* Dynamic body
*/
export const B2_DYNAMIC_BODY: BodyConstant;
/**
* Kinematic body
*/
export const B2_KINEMATIC_BODY: BodyConstant;
/**
* Static (immovable) body
*/
export const B2_STATIC_BODY: BodyConstant;
/**
* Apply an angular impulse.
* @param body body
* @param impulse impulse the angular impulse in units of kg*m*m/s
* @see {@link https://defold.com/ref/stable/b2d.body/#b2d.body.apply_angular_impulse|API Documentation}
*/
export function apply_angular_impulse(
body: typeof b2d.body,
impulse: number,
): void;
/**
* Apply a force at a world point. If the force is not
* applied at the center of mass, it will generate a torque and
* affect the angular velocity. This wakes up the body.
* @param body body
* @param force the world force vector, usually in Newtons (N).
* @param point the world position of the point of application.
* @see {@link https://defold.com/ref/stable/b2d.body/#b2d.body.apply_force|API Documentation}
*/
export function apply_force(
body: typeof b2d.body,
force: vmath.vector3,
point: vmath.vector3,
): void;
/**
* Apply a force to the center of mass. This wakes up the body.
* @param body body
* @param force the world force vector, usually in Newtons (N).
* @see {@link https://defold.com/ref/stable/b2d.body/#b2d.body.apply_force_to_center|API Documentation}
*/
export function apply_force_to_center(
body: typeof b2d.body,
force: vmath.vector3,
): void;
/**
* Apply an impulse at a point. This immediately modifies the velocity.
* It also modifies the angular velocity if the point of application
* is not at the center of mass. This wakes up the body.
* @param body body
* @param impulse the world impulse vector, usually in N-seconds or kg-m/s.
* @param point the world position of the point of application.
* @see {@link https://defold.com/ref/stable/b2d.body/#b2d.body.apply_linear_impulse|API Documentation}
*/
export function apply_linear_impulse(
body: typeof b2d.body,
impulse: vmath.vector3,
point: vmath.vector3,
): void;
/**
* Apply a torque. This affects the angular velocity
* without affecting the linear velocity of the center of mass.
* This wakes up the body.
* @param body body
* @param torque torque about the z-axis (out of the screen), usually in N-m.
* @see {@link https://defold.com/ref/stable/b2d.body/#b2d.body.apply_torque|API Documentation}
*/
export function apply_torque(body: typeof b2d.body, torque: number): void;
/**
* Print the body representation to the log output
* @param body body
* @see {@link https://defold.com/ref/stable/b2d.body/#b2d.body.dump|API Documentation}
*/
export function dump(body: typeof b2d.body): void;
/**
* Get the angular damping of the body.
* @param body body
* @returns damping the damping
* @see {@link https://defold.com/ref/stable/b2d.body/#b2d.body.get_angular_damping|API Documentation}
*/
export function get_angular_damping(body: typeof b2d.body): number;
/**
* Get the angular velocity.
* @param body body
* @returns velocity the angular velocity in radians/second.
* @see {@link https://defold.com/ref/stable/b2d.body/#b2d.body.get_angular_velocity|API Documentation}
*/
export function get_angular_velocity(body: typeof b2d.body): number;
/**
* Get the gravity scale of the body.
* @param body body
* @returns scale the scale
* @see {@link https://defold.com/ref/stable/b2d.body/#b2d.body.get_gravity_scale|API Documentation}
*/
export function get_gravity_scale(body: typeof b2d.body): number;
/**
* Get the rotational inertia of the body about the local origin.
* @param body body
* @returns inertia the rotational inertia, usually in kg-m^2.
* @see {@link https://defold.com/ref/stable/b2d.body/#b2d.body.get_inertia|API Documentation}
*/
export function get_inertia(body: typeof b2d.body): number;
/**
* Get the linear damping of the body.
* @param body body
* @returns damping the damping
* @see {@link https://defold.com/ref/stable/b2d.body/#b2d.body.get_linear_damping|API Documentation}
*/
export function get_linear_damping(body: typeof b2d.body): number;
/**
* Get the linear velocity of the center of mass.
* @param body body
* @returns velocity the linear velocity of the center of mass.
* @see {@link https://defold.com/ref/stable/b2d.body/#b2d.body.get_linear_velocity|API Documentation}
*/
export function get_linear_velocity(body: typeof b2d.body): vmath.vector3;
/**
* Get the world velocity of a local point.
* @param body body
* @param local_point a point in local coordinates.
* @returns velocity the world velocity of a point.
* @see {@link https://defold.com/ref/stable/b2d.body/#b2d.body.get_linear_velocity_from_local_point|API Documentation}
*/
export function get_linear_velocity_from_local_point(
body: typeof b2d.body,
local_point: vmath.vector3,
): vmath.vector3;
/**
* Get the world linear velocity of a world point attached to this body.
* @param body body
* @param world_point a point in world coordinates.
* @returns velocity the world velocity of a point.
* @see {@link https://defold.com/ref/stable/b2d.body/#b2d.body.get_linear_velocity_from_world_point|API Documentation}
*/
export function get_linear_velocity_from_world_point(
body: typeof b2d.body,
world_point: vmath.vector3,
): vmath.vector3;
/**
* Get the local position of the center of mass.
* @param body body
* @returns center Get the local position of the center of mass.
* @see {@link https://defold.com/ref/stable/b2d.body/#b2d.body.get_local_center|API Documentation}
*/
export function get_local_center(body: typeof b2d.body): vmath.vector3;
/**
* Gets a local point relative to the body's origin given a world point.
* @param body body
* @param world_point a point in world coordinates.
* @returns vector the corresponding local point relative to the body's origin.
* @see {@link https://defold.com/ref/stable/b2d.body/#b2d.body.get_local_point|API Documentation}
*/
export function get_local_point(
body: typeof b2d.body,
world_point: vmath.vector3,
): vmath.vector3;
/**
* Gets a local vector given a world vector.
* @param body body
* @param world_vector a vector in world coordinates.
* @returns vector the corresponding local vector.
* @see {@link https://defold.com/ref/stable/b2d.body/#b2d.body.get_local_vector|API Documentation}
*/
export function get_local_vector(
body: typeof b2d.body,
world_vector: vmath.vector3,
): vmath.vector3;
/**
* Get the total mass of the body.
* @param body body
* @returns mass the mass, usually in kilograms (kg).
* @see {@link https://defold.com/ref/stable/b2d.body/#b2d.body.get_mass|API Documentation}
*/
export function get_mass(body: typeof b2d.body): number;
/**
* Get the next body in the world's body list.
* @param body body
* @returns body the next body
* @see {@link https://defold.com/ref/stable/b2d.body/#b2d.body.get_next|API Documentation}
*/
export function get_next(body: typeof b2d.body): AnyNotNil | undefined;
/**
* Get the world body origin position.
* @param body body
* @returns position the world position of the body's origin.
* @see {@link https://defold.com/ref/stable/b2d.body/#b2d.body.get_position|API Documentation}
*/
export function get_position(body: typeof b2d.body): vmath.vector3;
/**
* Get the type of this body.
* @param body body
* @returns type the body type
* @see {@link https://defold.com/ref/stable/b2d.body/#b2d.body.get_type|API Documentation}
*/
export function get_type(body: typeof b2d.body): AnyNotNil | undefined;
/**
* Get the parent world of this body.
* @param body body
* @returns world
* @see {@link https://defold.com/ref/stable/b2d.body/#b2d.body.get_world|API Documentation}
*/
export function get_world(body: typeof b2d.body): AnyNotNil | undefined;
/**
* Get the angle in radians.
* @param body body
* @returns angle the current world rotation angle in radians.
* @see {@link https://defold.com/ref/stable/b2d.body/#b2d.body.get_world_center|API Documentation}
*/
export function get_world_center(body: typeof b2d.body): number;
/**
* Get the world position of the center of mass.
* @param body body
* @returns center Get the world position of the center of mass.
* @see {@link https://defold.com/ref/stable/b2d.body/#b2d.body.get_world_center|API Documentation}
*/
export function get_world_center(body: typeof b2d.body): vmath.vector3;
/**
* Get the world coordinates of a point given the local coordinates.
* @param body body
* @param local_vector localPoint a point on the body measured relative the the body's origin.
* @returns vector the same point expressed in world coordinates.
* @see {@link https://defold.com/ref/stable/b2d.body/#b2d.body.get_world_point|API Documentation}
*/
export function get_world_point(
body: typeof b2d.body,
local_vector: vmath.vector3,
): vmath.vector3;
/**
* Get the world coordinates of a vector given the local coordinates.
* @param body body
* @param local_vector a vector fixed in the body.
* @returns vector the same vector expressed in world coordinates.
* @see {@link https://defold.com/ref/stable/b2d.body/#b2d.body.get_world_vector|API Documentation}
*/
export function get_world_vector(
body: typeof b2d.body,
local_vector: vmath.vector3,
): vmath.vector3;
/**
* Get the active state of the body.
* @param body body
* @returns enabled is the body active
* @see {@link https://defold.com/ref/stable/b2d.body/#b2d.body.is_active|API Documentation}
*/
export function is_active(body: typeof b2d.body): AnyNotNil | undefined;
/**
* Get the sleeping state of this body.
* @param body body
* @returns enabled true if the body is awake, false if it's sleeping.
* @see {@link https://defold.com/ref/stable/b2d.body/#b2d.body.is_awake|API Documentation}
*/
export function is_awake(body: typeof b2d.body): AnyNotNil | undefined;
/**
* Is this body in bullet mode
* @param body body
* @returns enabled true if the body is in bullet mode
* @see {@link https://defold.com/ref/stable/b2d.body/#b2d.body.is_bullet|API Documentation}
*/
export function is_bullet(body: typeof b2d.body): AnyNotNil | undefined;
/**
* Does this body have fixed rotation?
* @param body body
* @returns enabled is the rotation fixed
* @see {@link https://defold.com/ref/stable/b2d.body/#b2d.body.is_fixed_rotation|API Documentation}
*/
export function is_fixed_rotation(
body: typeof b2d.body,
): AnyNotNil | undefined;
/**
* Is this body allowed to sleep
* @param body body
* @returns enabled true if the body is allowed to sleep
* @see {@link https://defold.com/ref/stable/b2d.body/#b2d.body.is_sleeping_allowed|API Documentation}
*/
export function is_sleeping_allowed(
body: typeof b2d.body,
): AnyNotNil | undefined;
/**
* This resets the mass properties to the sum of the mass properties of the fixtures.
* This normally does not need to be called unless you called SetMassData to override
* @param body body
* @see {@link https://defold.com/ref/stable/b2d.body/#b2d.body.reset_mass_data|API Documentation}
*/
export function reset_mass_data(body: typeof b2d.body): void;
/**
* Set the active state of the body. An inactive body is not
* simulated and cannot be collided with or woken up.
* If you pass a flag of true, all fixtures will be added to the
* broad-phase.
* If you pass a flag of false, all fixtures will be removed from
* the broad-phase and all contacts will be destroyed.
* Fixtures and joints are otherwise unaffected. You may continue
* to create/destroy fixtures and joints on inactive bodies.
* Fixtures on an inactive body are implicitly inactive and will
* not participate in collisions, ray-casts, or queries.
* Joints connected to an inactive body are implicitly inactive.
* An inactive body is still owned by a b2World object and remains
* in the body list.
* @param body body
* @param enable true if the body should be active
* @see {@link https://defold.com/ref/stable/b2d.body/#b2d.body.set_active|API Documentation}
*/
export function set_active(body: typeof b2d.body, enable: boolean): void;
/**
* Set the angular damping of the body.
* @param body body
* @param damping the damping
* @see {@link https://defold.com/ref/stable/b2d.body/#b2d.body.set_angular_damping|API Documentation}
*/
export function set_angular_damping(
body: typeof b2d.body,
damping: number,
): void;
/**
* Set the angular velocity.
* @param body body
* @param omega the new angular velocity in radians/second.
* @see {@link https://defold.com/ref/stable/b2d.body/#b2d.body.set_angular_velocity|API Documentation}
*/
export function set_angular_velocity(
body: typeof b2d.body,
omega: number,
): void;
/**
* Set the sleep state of the body. A sleeping body has very low CPU cost.
* @param body body
* @param enable flag set to false to put body to sleep, true to wake it.
* @see {@link https://defold.com/ref/stable/b2d.body/#b2d.body.set_awake|API Documentation}
*/
export function set_awake(body: typeof b2d.body, enable: boolean): void;
/**
* Should this body be treated like a bullet for continuous collision detection?
* @param body body
* @param enable if true, the body will be in bullet mode
* @see {@link https://defold.com/ref/stable/b2d.body/#b2d.body.set_bullet|API Documentation}
*/
export function set_bullet(body: typeof b2d.body, enable: boolean): void;
/**
* Set this body to have fixed rotation. This causes the mass to be reset.
* @param body body
* @param enable true if the rotation should be fixed
* @see {@link https://defold.com/ref/stable/b2d.body/#b2d.body.set_fixed_rotation|API Documentation}
*/
export function set_fixed_rotation(
body: typeof b2d.body,
enable: boolean,
): void;
/**
* Set the gravity scale of the body.
* @param body body
* @param scale the scale
* @see {@link https://defold.com/ref/stable/b2d.body/#b2d.body.set_gravity_scale|API Documentation}
*/
export function set_gravity_scale(body: typeof b2d.body, scale: number): void;
/**
* Set the linear damping of the body.
* @param body body
* @param damping the damping
* @see {@link https://defold.com/ref/stable/b2d.body/#b2d.body.set_linear_damping|API Documentation}
*/
export function set_linear_damping(
body: typeof b2d.body,
damping: number,
): void;
/**
* Set the linear velocity of the center of mass.
* @param body body
* @param velocity the new linear velocity of the center of mass.
* @see {@link https://defold.com/ref/stable/b2d.body/#b2d.body.set_linear_velocity|API Documentation}
*/
export function set_linear_velocity(
body: typeof b2d.body,
velocity: vmath.vector3,
): void;
/**
* You can disable sleeping on this body. If you disable sleeping, the body will be woken.
* @param body body
* @param enable if false, the body will never sleep, and consume more CPU
* @see {@link https://defold.com/ref/stable/b2d.body/#b2d.body.set_sleeping_allowed|API Documentation}
*/
export function set_sleeping_allowed(
body: typeof b2d.body,
enable: boolean,
): void;
/**
* Set the position of the body's origin and rotation.
* This breaks any contacts and wakes the other bodies.
* Manipulating a body's transform may cause non-physical behavior.
* @param body body
* @param position the world position of the body's local origin.
* @param angle the world position of the body's local origin.
* @see {@link https://defold.com/ref/stable/b2d.body/#b2d.body.set_transform|API Documentation}
*/
export function set_transform(
body: typeof b2d.body,
position: vmath.vector3,
angle: number,
): void;
/**
* Set the type of this body. This may alter the mass and velocity.
* @param body body
* @param type the body type
* @see {@link https://defold.com/ref/stable/b2d.body/#b2d.body.set_type|API Documentation}
*/
export function set_type(body: typeof b2d.body, type: BodyConstant): void;
}
// =^..^= =^..^= =^..^= =^..^= =^..^= =^..^= =^..^= //
/** @see {@link https://defold.com/ref/stable/crash/|API Documentation} */
declare namespace crash {
type UserFieldConstant = number & { readonly __brand: 'crash.USERFIELD' };
type SysFieldConstant = number & { readonly __brand: 'crash.SYSFIELD' };
/**
* android build fingerprint
*/
export const SYSFIELD_ANDROID_BUILD_FINGERPRINT: SysFieldConstant;
/**
* system device language as reported by sys.get_sys_info
*/
export const SYSFIELD_DEVICE_LANGUAGE: SysFieldConstant;
/**
* device model as reported by sys.get_sys_info
*/
export const SYSFIELD_DEVICE_MODEL: SysFieldConstant;
/**
* engine version as hash
*/
export const SYSFIELD_ENGINE_HASH: SysFieldConstant;
/**
* engine version as release number
*/
export const SYSFIELD_ENGINE_VERSION: SysFieldConstant;
/**
* system language as reported by sys.get_sys_info
*/
export const SYSFIELD_LANGUAGE: SysFieldConstant;
/**
* device manufacturer as reported by sys.get_sys_info
*/
export const SYSFIELD_MANUFACTURER: SysFieldConstant;
/**
* The max number of sysfields.
*/
export const SYSFIELD_MAX: SysFieldConstant;
/**
* system name as reported by sys.get_sys_info
*/
export const SYSFIELD_SYSTEM_NAME: SysFieldConstant;
/**
* system version as reported by sys.get_sys_info
*/
export const SYSFIELD_SYSTEM_VERSION: SysFieldConstant;
/**
* system territory as reported by sys.get_sys_info
*/
export const SYSFIELD_TERRITORY: SysFieldConstant;
/**
* The max number of user fields.
*/
export const USERFIELD_MAX: UserFieldConstant;
/**
* The max size of a single user field.
*/
export const USERFIELD_SIZE: UserFieldConstant;
/**
* A table is returned containing the addresses of the call stack.
* @param handle crash dump handle
* @returns backtrace table containing the backtrace
* @see {@link https://defold.com/ref/stable/crash/#crash.get_backtrace|API Documentation}
*/
export function get_backtrace(handle: number): AnyNotNil | undefined;
/**
* The format of read text blob is platform specific
* and not guaranteed
* but can be useful for manual inspection.
* @param handle crash dump handle
* @returns blob string with the platform specific data
* @see {@link https://defold.com/ref/stable/crash/#crash.get_extra_data|API Documentation}
*/
export function get_extra_data(handle: number): string;
/**
* The function returns a table containing entries with sub-tables that
* have fields 'name' and 'address' set for all loaded modules.
* @param handle crash dump handle
* @returns modules module table
* @see {@link https://defold.com/ref/stable/crash/#crash.get_modules|API Documentation}
*/
export function get_modules(
handle: number,
): { name: unknown; address: unknown }[];
/**
* read signal number from a crash report
* @param handle crash dump handle
* @returns signal signal number
* @see {@link https://defold.com/ref/stable/crash/#crash.get_signum|API Documentation}
*/
export function get_signum(handle: number): number;
/**
* reads a system field from a loaded crash dump
* @param handle crash dump handle
* @param index system field enum. Must be less than crash.SYSFIELD_MAX
* @returns value value recorded in the crash dump, or `undefined` if it didn't exist
* @see {@link https://defold.com/ref/stable/crash/#crash.get_sys_field|API Documentation}
*/
export function get_sys_field(
handle: number,
index: number,
): string | undefined;
/**
* reads user field from a loaded crash dump
* @param handle crash dump handle
* @param index user data slot index
* @returns value user data value recorded in the crash dump
* @see {@link https://defold.com/ref/stable/crash/#crash.get_user_field|API Documentation}
*/
export function get_user_field(handle: number, index: number): string;
/**
* The crash dump will be removed from disk upon a successful
* load, so loading is one-shot.
* @returns handle handle to the loaded dump, or `undefined` if no dump was found
* @see {@link https://defold.com/ref/stable/crash/#crash.load_previous|API Documentation}
*/
export function load_previous(): number | undefined;
/**
* releases a previously loaded crash dump
* @param handle handle to loaded crash dump
* @see {@link https://defold.com/ref/stable/crash/#crash.release|API Documentation}
*/
export function release(handle: number): void;
/**
* Crashes occuring before the path is set will be stored to a default engine location.
* @param path file path to use
* @see {@link https://defold.com/ref/stable/crash/#crash.set_file_path|API Documentation}
*/
export function set_file_path(path: string): void;
/**
* Store a user value that will get written to a crash dump when
* a crash occurs. This can be user id:s, breadcrumb data etc.
* There are 32 slots indexed from 0. Each slot stores at most 255 characters.
* @param index slot index. 0-indexed
* @param value string value to store
* @see {@link https://defold.com/ref/stable/crash/#crash.set_user_field|API Documentation}
*/
export function set_user_field(index: number, value: string): void;
/**
* Performs the same steps as if a crash had just occured but
* allows the program to continue.
* The generated dump can be read by crash.load_previous
* @see {@link https://defold.com/ref/stable/crash/#crash.write_dump|API Documentation}
*/
export function write_dump(): void;
}
// =^..^= =^..^= =^..^= =^..^= =^..^= =^..^= =^..^= //
/** @see {@link https://defold.com/ref/stable/go/|API Documentation} */
declare namespace go {
export type PlaybackConstant = number & { readonly __brand: 'go.PLAYBACK' };
type EasingConstant = number & { readonly __brand: 'go.EASING' };
/**
* Post this message to a game object instance to make that instance acquire the user input focus.
* User input is distributed by the engine to every instance that has
* requested it. The last instance to request focus will receive it first.
* This means that the scripts in the instance will have first-hand-chance
* at reacting on user input, possibly consuming it (by returning
* `true` from `on_input`) so that no other instances
* can react on it. The most common case is for a script to send this message
* to itself when it needs to respond to user input.
* A script belonging to an instance which has the user input focus will
* receive the input actions in its `on_input` callback function.
* See on_input for more information on how user input can be
* handled.
*/
export type acquire_input_focus = 'acquire_input_focus';
export type touch_input = {
id: number;
pressed: boolean;
released: boolean;
tap_count: number;
x: number;
y: number;
dx: number;
dy: number;
acc_x?: number;
acc_y?: number;
acc_z?: number;
};
export type input_message = {
value?: number;
pressed?: boolean;
released?: boolean;
repeated?: boolean;
x?: number;
y?: number;
screen_x?: number;
screen_y?: number;
dx?: number;
dy?: number;
screen_dx?: number;
screen_dy?: number;
gamepad?: number;
touch?: touch_input[];
};
/**
* This message disables the receiving component. All components are enabled by default, which means they will receive input, updates
* and be a part of the simulation. A component is disabled when it receives the `disable` message.
* undefined Components that currently supports this message are:
*
* - Camera
* - Collection Proxy
* - Collision Object
* - Gui
* - Label
* - Spine Model
* - Sprite
* - Tile Grid
* - Model
* - Mesh
*
*/
export type disable = 'disable';
/**
* This message enables the receiving component. All components are enabled by default, which means they will receive input, updates
* and be a part of the simulation. A component is disabled when it receives the `disable` message.
* undefined Components that currently supports this message are:
*
* - Camera
* - Collection Proxy
* - Collision Object
* - Gui
* - Label
* - Spine Model
* - Sprite
* - Tile Grid
* - Model
* - Mesh
*
*/
export type enable = 'enable';
/**
* The rotation of the game object expressed in Euler angles.
* Euler angles are specified in degrees in the interval (-360, 360).
* The type of the property is vector3.
*/
export let euler: vmath.vector3;
/**
* This is a callback-function, which is called by the engine at fixed intervals to update the state of a script
* component. The function will be called if 'Fixed Update Frequency' is enabled in the Engine section of game.project.
* It can for instance be used to update game logic with the physics simulation if using a fixed timestep for the
* physics (enabled by ticking 'Use Fixed Timestep' in the Physics section of game.project).
* @param self reference to the script state to be used for storing data
* @param dt the time-step of the frame update
*/
// export function fixed_update(self: object, dt: number): void
/**
* in-back
*/
export const EASING_INBACK: EasingConstant;
/**
* in-bounce
*/
export const EASING_INBOUNCE: EasingConstant;
/**
* in-circlic
*/
export const EASING_INCIRC: EasingConstant;
/**
* in-cubic
*/
export const EASING_INCUBIC: EasingConstant;
/**
* in-elastic
*/
export const EASING_INELASTIC: EasingConstant;
/**
* in-exponential