@defold-typescript/types 0.51.0 → 0.52.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 (130) hide show
  1. package/api-availability.json +4 -58
  2. package/api-signatures.json +878 -1356
  3. package/api-targets.json +15 -5
  4. package/examples/translations.json +4 -56
  5. package/generated/b2d_world.d.ts +10 -10
  6. package/generated/buffer.d.ts +9 -9
  7. package/generated/bullet3d_collision_object.d.ts +1 -1
  8. package/generated/bullet3d_constraint.d.ts +109 -7
  9. package/generated/bullet3d_shape.d.ts +2 -2
  10. package/generated/go.d.ts +114 -220
  11. package/generated/graphics.d.ts +1 -0
  12. package/generated/gui.d.ts +148 -371
  13. package/generated/http.d.ts +2 -2
  14. package/generated/image.d.ts +55 -3
  15. package/generated/kinds/gui-script.d.ts +2 -0
  16. package/generated/kinds/render-script.d.ts +14 -15
  17. package/generated/liveupdate.d.ts +5 -1
  18. package/generated/material.d.ts +3 -3
  19. package/generated/particlefx.d.ts +20 -1
  20. package/generated/physics.d.ts +45 -1
  21. package/generated/render-script-modules/b2d.d.ts +711 -0
  22. package/generated/render-script-modules/bullet3d.d.ts +73 -0
  23. package/generated/render-script-modules/collectionfactory.d.ts +25 -0
  24. package/generated/render-script-modules/collectionproxy.d.ts +39 -0
  25. package/generated/render-script-modules/factory.d.ts +25 -0
  26. package/generated/render-script-modules/go.d.ts +436 -0
  27. package/generated/render-script-modules/label.d.ts +105 -0
  28. package/generated/render-script-modules/model.d.ts +89 -0
  29. package/generated/render-script-modules/particlefx.d.ts +59 -0
  30. package/generated/render-script-modules/physics.d.ts +333 -0
  31. package/generated/render-script-modules/resource.d.ts +1233 -0
  32. package/generated/render-script-modules/sound.d.ts +227 -0
  33. package/generated/render-script-modules/sprite.d.ts +68 -0
  34. package/generated/render-script-modules/tilemap.d.ts +43 -0
  35. package/generated/render.d.ts +134 -8
  36. package/generated/resource.d.ts +31 -10
  37. package/generated/sprite.d.ts +49 -1
  38. package/generated/sys.d.ts +70 -6
  39. package/generated/versions/defold-1.12.4/buffer.d.ts +8 -8
  40. package/generated/versions/defold-1.12.4/go.d.ts +115 -343
  41. package/generated/versions/defold-1.12.4/graphics.d.ts +1 -0
  42. package/generated/versions/defold-1.12.4/gui.d.ts +151 -513
  43. package/generated/versions/defold-1.12.4/http.d.ts +2 -2
  44. package/generated/versions/defold-1.12.4/image.d.ts +82 -2
  45. package/generated/versions/defold-1.12.4/index.d.ts +1 -0
  46. package/generated/versions/defold-1.12.4/liveupdate.d.ts +4 -0
  47. package/generated/versions/defold-1.12.4/particlefx.d.ts +22 -1
  48. package/generated/versions/defold-1.12.4/physics.d.ts +45 -1
  49. package/generated/versions/defold-1.12.4/render.d.ts +78 -2
  50. package/generated/versions/defold-1.12.4/resource.d.ts +43 -10
  51. package/generated/versions/defold-1.12.4/sprite.d.ts +58 -1
  52. package/generated/versions/defold-1.12.4/sys.d.ts +101 -6
  53. package/generated/versions/defold-1.12.4/vmath.d.ts +0 -24
  54. package/generated/versions/defold-1.13.0/buffer.d.ts +8 -8
  55. package/generated/versions/defold-1.13.0/go.d.ts +115 -370
  56. package/generated/versions/defold-1.13.0/graphics.d.ts +1 -0
  57. package/generated/versions/defold-1.13.0/gui.d.ts +151 -513
  58. package/generated/versions/defold-1.13.0/http.d.ts +2 -2
  59. package/generated/versions/defold-1.13.0/image.d.ts +82 -2
  60. package/generated/versions/defold-1.13.0/index.d.ts +1 -0
  61. package/generated/versions/defold-1.13.0/liveupdate.d.ts +4 -0
  62. package/generated/versions/defold-1.13.0/material.d.ts +3 -1
  63. package/generated/versions/defold-1.13.0/particlefx.d.ts +22 -1
  64. package/generated/versions/defold-1.13.0/physics.d.ts +45 -1
  65. package/generated/versions/defold-1.13.0/render.d.ts +142 -4
  66. package/generated/versions/defold-1.13.0/resource.d.ts +43 -10
  67. package/generated/versions/defold-1.13.0/sprite.d.ts +58 -1
  68. package/generated/versions/defold-1.13.0/sys.d.ts +101 -6
  69. package/generated/versions/defold-1.13.0/vmath.d.ts +0 -24
  70. package/generated/versions/defold-1.13.1/buffer.d.ts +8 -8
  71. package/generated/versions/defold-1.13.1/go.d.ts +115 -370
  72. package/generated/versions/defold-1.13.1/graphics.d.ts +1 -0
  73. package/generated/versions/defold-1.13.1/gui.d.ts +151 -529
  74. package/generated/versions/defold-1.13.1/http.d.ts +2 -2
  75. package/generated/versions/defold-1.13.1/image.d.ts +82 -2
  76. package/generated/versions/defold-1.13.1/index.d.ts +2 -0
  77. package/generated/versions/defold-1.13.1/liveupdate.d.ts +4 -0
  78. package/generated/versions/defold-1.13.1/material.d.ts +3 -1
  79. package/generated/versions/defold-1.13.1/particlefx.d.ts +22 -1
  80. package/generated/versions/defold-1.13.1/physics.d.ts +45 -1
  81. package/generated/versions/defold-1.13.1/render.d.ts +142 -4
  82. package/generated/versions/defold-1.13.1/resource.d.ts +43 -10
  83. package/generated/versions/defold-1.13.1/sprite.d.ts +58 -1
  84. package/generated/versions/defold-1.13.1/sys.d.ts +101 -6
  85. package/generated/versions/defold-1.13.1/vmath.d.ts +0 -24
  86. package/generated/versions/defold-1.13.2/b2d_world.d.ts +10 -10
  87. package/generated/versions/defold-1.13.2/buffer.d.ts +9 -9
  88. package/generated/versions/defold-1.13.2/bullet3d_collision_object.d.ts +1 -1
  89. package/generated/versions/defold-1.13.2/bullet3d_constraint.d.ts +109 -7
  90. package/generated/versions/defold-1.13.2/bullet3d_shape.d.ts +2 -2
  91. package/generated/versions/defold-1.13.2/go.d.ts +114 -220
  92. package/generated/versions/defold-1.13.2/graphics.d.ts +1 -0
  93. package/generated/versions/defold-1.13.2/gui.d.ts +148 -371
  94. package/generated/versions/defold-1.13.2/http.d.ts +2 -2
  95. package/generated/versions/defold-1.13.2/image.d.ts +55 -3
  96. package/generated/versions/defold-1.13.2/index.d.ts +2 -0
  97. package/generated/versions/defold-1.13.2/liveupdate.d.ts +5 -1
  98. package/generated/versions/defold-1.13.2/material.d.ts +3 -3
  99. package/generated/versions/defold-1.13.2/particlefx.d.ts +20 -1
  100. package/generated/versions/defold-1.13.2/physics.d.ts +45 -1
  101. package/generated/versions/defold-1.13.2/render.d.ts +123 -7
  102. package/generated/versions/defold-1.13.2/resource.d.ts +31 -10
  103. package/generated/versions/defold-1.13.2/sprite.d.ts +49 -1
  104. package/generated/versions/defold-1.13.2/sys.d.ts +70 -6
  105. package/generated/versions/defold-1.13.2/vmath.d.ts +0 -24
  106. package/generated/vmath.d.ts +0 -24
  107. package/identity-vocabulary.json +52 -7
  108. package/index.d.ts +2 -0
  109. package/package.json +2 -1
  110. package/scripts/generate-api-availability.ts +1 -21
  111. package/scripts/generate-api-signatures.ts +75 -14
  112. package/scripts/materialize-version.ts +48 -7
  113. package/scripts/regen.ts +214 -19
  114. package/scripts/signature-store-fs.ts +1 -0
  115. package/scripts/target-version.ts +26 -0
  116. package/src/api-doc.ts +26 -0
  117. package/src/component-properties.d.ts +89 -0
  118. package/src/core-types.ts +42 -15
  119. package/src/doc-corrections.ts +53 -5
  120. package/src/emit-dts.ts +758 -198
  121. package/src/engine-globals.d.ts +5 -1
  122. package/src/go-overloads.d.ts +68 -13
  123. package/src/gui-overloads.d.ts +489 -0
  124. package/src/gui-texture-removal.d.ts +41 -0
  125. package/src/index.ts +2 -0
  126. package/src/lifecycle.ts +30 -21
  127. package/src/msg-overloads.d.ts +25 -13
  128. package/src/signature-store.ts +50 -0
  129. package/src/timers.d.ts +2 -1
  130. package/src/vmath-overloads.d.ts +26 -0
@@ -1,5 +1,5 @@
1
1
  /** @noSelfInFile */
2
- import type { Hash, Matrix4, Opaque, Quaternion, Url, Vector, Vector3, Vector4 } from "../../../src/core-types";
2
+ import type { Hash, Matrix4, Quaternion, Url, Vector, Vector3, Vector4 } from "../../../src/core-types";
3
3
 
4
4
  declare global {
5
5
  /**
@@ -259,7 +259,65 @@ declare global {
259
259
  * go.animate("go", "position.y", go.PLAYBACK_LOOP_PINGPONG, 100, vec, 2.0);
260
260
  * ```
261
261
  */
262
- export function animate(url: SceneAddress | Hash | Url, property: string | Hash, playback: go.Playback, to: number | Vector3 | Vector4 | Quaternion, easing: Vector | go.Easing, duration: number, delay?: number, complete_function?: (self: unknown, url: unknown, property: unknown) => void): void;
262
+ export function animate(url: SceneAddress | Hash | Url, property: string | Hash, playback: go.Playback, to: number | Vector3 | Vector4 | Quaternion, easing: Vector | go.Easing, duration: number): void;
263
+ /**
264
+ * This is only supported for numerical properties. If the node property is already being
265
+ * animated, that animation will be canceled and replaced by the new one.
266
+ * If a `complete_function` (lua function) is specified, that function will be called when the animation has completed.
267
+ * By starting a new animation in that function, several animations can be sequenced together. See the examples for more information.
268
+ * If you call `go.animate()` from a game object's `final()` function,
269
+ * any passed `complete_function` will be ignored and never called upon animation completion.
270
+ * See the properties guide for which properties can be animated and the animation guide for how
271
+ * them.
272
+ *
273
+ * @param url - url of the game object or component having the property
274
+ * @param property - id of the property to animate
275
+ * @param playback - playback mode of the animation
276
+ *
277
+ * - `go.PLAYBACK_ONCE_FORWARD`
278
+ * - `go.PLAYBACK_ONCE_BACKWARD`
279
+ * - `go.PLAYBACK_ONCE_PINGPONG`
280
+ * - `go.PLAYBACK_LOOP_FORWARD`
281
+ * - `go.PLAYBACK_LOOP_BACKWARD`
282
+ * - `go.PLAYBACK_LOOP_PINGPONG`
283
+ * @param to - target property value
284
+ * @param easing - easing to use during animation. Either specify a constant, see the animation guide for a complete list, or a vmath.vector with a curve
285
+ * @param duration - duration of the animation in seconds
286
+ * @param delay - delay before the animation starts in seconds
287
+ * @param complete_function - optional function to call when the animation has completed
288
+ *
289
+ * `self`
290
+ *
291
+ * object The current object.
292
+ *
293
+ * `url`
294
+ *
295
+ * url The game object or component instance for which the property is animated.
296
+ *
297
+ * `property`
298
+ *
299
+ * hash The id of the animated property.
300
+ * @example
301
+ * Animate the position of a game object to x = 10 during 1 second, then y = 20 during 1 second:
302
+ * ```ts
303
+ * go.animate(go.get_id(), "position.x", go.PLAYBACK_ONCE_FORWARD, 10, go.EASING_LINEAR, 1, 0, () => {
304
+ * go.animate(go.get_id(), "position.y", go.PLAYBACK_ONCE_FORWARD, 20, go.EASING_LINEAR, 1);
305
+ * });
306
+ * ```
307
+ * @example
308
+ * Animate the y position of a game object using a crazy custom easing curve:
309
+ * ```ts
310
+ * const values = [
311
+ * 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1,
312
+ * 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1,
313
+ * 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1,
314
+ * 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1,
315
+ * ];
316
+ * const vec = vmath.vector(values);
317
+ * go.animate("go", "position.y", go.PLAYBACK_LOOP_PINGPONG, 100, vec, 2.0);
318
+ * ```
319
+ */
320
+ export function animate(url: SceneAddress | Hash | Url, property: string | Hash, playback: go.Playback, to: number | Vector3 | Vector4 | Quaternion, easing: Vector | go.Easing, duration: number, delay: number, complete_function?: (self: unknown, url: unknown, property: unknown) => void): void;
263
321
  /**
264
322
  * By calling this function, all or specified stored property animations of the game object or component will be canceled.
265
323
  * See the properties guide for which properties can be animated and the animation guide for how to animate them.
@@ -318,7 +376,43 @@ declare global {
318
376
  * go.delete(ids, true);
319
377
  * ```
320
378
  */
321
- function _delete(id?: SceneGameObjectAddress | Hash | Url | (SceneGameObjectAddress | Hash | Url)[] | boolean, recursive?: boolean): void;
379
+ function _delete(id?: SceneGameObjectAddress | Hash | Url | (SceneGameObjectAddress | Hash | Url)[] | LuaPairsIterable<AnyNotNil, SceneGameObjectAddress | Hash | Url> | boolean): void;
380
+ /**
381
+ * Delete one or more game objects identified by id. Deletion is asynchronous meaning that
382
+ * the game object(s) are scheduled for deletion which will happen at the end of the current
383
+ * frame. Note that game objects scheduled for deletion will be counted against
384
+ * `max_instances` in "game.project" until they are actually removed.
385
+ * Deleting a game object containing a particle FX component emitting particles will not immediately stop the particle FX from emitting particles. You need to manually stop the particle FX using `particlefx.stop()`.
386
+ * Deleting a game object containing a sound component that is playing will not immediately stop the sound from playing. You need to manually stop the sound using `sound.stop()`.
387
+ *
388
+ * @param id - optional id or table of id's of the instance(s) to delete, the instance of the calling script is deleted by default
389
+ * @param recursive - optional boolean, set to true to recursively delete child hiearchy in child to parent order
390
+ * @example
391
+ * This example demonstrates how to delete game objects
392
+ * ```ts
393
+ * // Delete the script's own game object.
394
+ * go.delete();
395
+ * // Delete a game object with the id "my_game_object".
396
+ * const id = go.get_id("my_game_object"); // retrieve the id of the game object to be deleted
397
+ * go.delete(id);
398
+ * // Delete a list of game objects.
399
+ * const ids = [hash("/my_object_1"), hash("/my_object_2"), hash("/my_object_3")];
400
+ * go.delete(ids);
401
+ * ```
402
+ * @example
403
+ * This example demonstrates how to delete a game objects and their children (child to parent order)
404
+ * ```ts
405
+ * // Delete the script's own game object and its children.
406
+ * go.delete(true);
407
+ * // Delete a game object with the id "my_game_object" and its children.
408
+ * const id = go.get_id("my_game_object"); // retrieve the id of the game object to be deleted
409
+ * go.delete(id, true);
410
+ * // Delete a list of game objects and their children.
411
+ * const ids = [hash("/my_object_1"), hash("/my_object_2"), hash("/my_object_3")];
412
+ * go.delete(ids, true);
413
+ * ```
414
+ */
415
+ function _delete(id: SceneGameObjectAddress | Hash | Url | (SceneGameObjectAddress | Hash | Url)[] | LuaPairsIterable<AnyNotNil, SceneGameObjectAddress | Hash | Url>, recursive: boolean): void;
322
416
  /**
323
417
  * This function can check for game objects in any collection by specifying
324
418
  * the collection name in the URL.
@@ -338,36 +432,29 @@ declare global {
338
432
  */
339
433
  export function exists(url: SceneGameObjectAddress | Hash | Url): boolean;
340
434
  /**
341
- * This is a callback-function, which is called by the engine when a script component is finalized (destroyed). It can
342
- * be used to e.g. take some last action, report the finalization to other game object instances, delete spawned objects
343
- * or release user input focus (see release_input_focus).
435
+ * Returns or constructs an instance identifier. The instance id is a hash
436
+ * of the absolute path to the instance.
344
437
  *
345
- * @param self - reference to the script state to be used for storing data
438
+ * - If `path` is specified, it can either be absolute or relative to the instance of the calling script.
439
+ * - If `path` is not specified, the id of the game object instance the script is attached to will be returned.
440
+ *
441
+ * @param path - path of the instance for which to return the id
442
+ * @returns instance id
346
443
  * @example
347
444
  * ```ts
348
- * export default defineScript({
349
- * init() {
350
- * return { some_value: 0 };
351
- * },
445
+ * // For the instance with path /my_sub_collection/my_instance, the following calls
446
+ * // are equivalent:
447
+ * const id = go.get_id(); // no path, defaults to the instance containing the calling script
448
+ * print(id); // => hash: [/my_sub_collection/my_instance]
352
449
  *
353
- * final(self) {
354
- * // report finalization
355
- * msg.post("my_friend_instance", "im_dead", { my_stats: self.some_value });
356
- * },
357
- * });
358
- * ```
359
- */
360
- export function final(self: Opaque<"userdata">): void;
361
- /**
362
- * This is a callback-function, which is called by the engine at fixed intervals to update the state of a script
363
- * component. The function will be called if 'Fixed Update Frequency' is enabled in the Engine section of game.project.
364
- * It can for instance be used to update game logic with the physics simulation if using a fixed timestep for the
365
- * physics (enabled by ticking 'Use Fixed Timestep' in the Physics section of game.project).
450
+ * const id2 = go.get_id("/my_sub_collection/my_instance"); // absolute path
451
+ * print(id2); // => hash: [/my_sub_collection/my_instance]
366
452
  *
367
- * @param self - reference to the script state to be used for storing data
368
- * @param dt - the time-step of the frame update
453
+ * const id3 = go.get_id("my_instance"); // relative path
454
+ * print(id3); // => hash: [/my_sub_collection/my_instance]
455
+ * ```
369
456
  */
370
- export function fixed_update(self: Opaque<"userdata">, dt: number): void;
457
+ export function get_id(): Hash;
371
458
  /**
372
459
  * Returns or constructs an instance identifier. The instance id is a hash
373
460
  * of the absolute path to the instance.
@@ -391,7 +478,7 @@ declare global {
391
478
  * print(id3); // => hash: [/my_sub_collection/my_instance]
392
479
  * ```
393
480
  */
394
- export function get_id(path?: string): Hash;
481
+ export function get_id(path: string): Hash;
395
482
  /**
396
483
  * Get the parent for a game object instance.
397
484
  *
@@ -574,298 +661,6 @@ declare global {
574
661
  * ```
575
662
  */
576
663
  export function get_world_transform(id?: SceneGameObjectAddress | Hash | Url): Matrix4;
577
- /**
578
- * This is a callback-function, which is called by the engine when a script component is initialized. It can be used
579
- * to set the initial state of the script.
580
- *
581
- * @param self - reference to the script state to be used for storing data
582
- * @example
583
- * ```ts
584
- * export default defineScript({
585
- * init() {
586
- * // set up useful data
587
- * return { my_value: 1 };
588
- * },
589
- * });
590
- * ```
591
- */
592
- export function init(self: Opaque<"userdata">): void;
593
- /**
594
- * This is a callback-function, which is called by the engine at the end of the frame to update the state of a script
595
- * component. Use it to make final adjustments to the game object instance.
596
- *
597
- * @param self - reference to the script state to be used for storing data
598
- * @param dt - the time-step of the frame update
599
- */
600
- export function late_update(self: Opaque<"userdata">, dt: number): void;
601
- /**
602
- * This is a callback-function, which is called by the engine when user input is sent to the game object instance of the script.
603
- * It can be used to take action on the input, e.g. move the instance according to the input.
604
- * For an instance to obtain user input, it must first acquire input focus
605
- * through the message `acquire_input_focus`.
606
- * Any instance that has obtained input will be put on top of an
607
- * input stack. Input is sent to all listeners on the stack until the
608
- * end of stack is reached, or a listener returns `true`
609
- * to signal that it wants input to be consumed.
610
- * See the documentation of acquire_input_focus for more
611
- * information.
612
- * The `action` parameter is a table containing data about the input mapped to the
613
- * `action_id`.
614
- * For mapped actions it specifies the value of the input and if it was just pressed or released.
615
- * Actions are mapped to input in an input_binding-file.
616
- * Mouse movement is specifically handled and uses `nil` as its `action_id`.
617
- * The `action` only contains positional parameters in this case, such as x and y of the pointer.
618
- * Here is a brief description of the available table fields:
619
- *
620
- * Field
621
- * Description
622
- *
623
- * `value`
624
- * The amount of input given by the user. This is usually 1 for buttons and 0-1 for analogue inputs. This is not present for mouse movement and text input.
625
- *
626
- * `pressed`
627
- * If the input was pressed this frame. This is not present for mouse movement and text input.
628
- *
629
- * `released`
630
- * If the input was released this frame. This is not present for mouse movement and text input.
631
- *
632
- * `repeated`
633
- * If the input was repeated this frame. This is similar to how a key on a keyboard is repeated when you hold it down. This is not present for mouse movement and text input.
634
- *
635
- * `x`
636
- * The x value of a pointer device, if present. This is not present for gamepad, key and text input.
637
- *
638
- * `y`
639
- * The y value of a pointer device, if present. This is not present for gamepad, key and text input.
640
- *
641
- * `screen_x`
642
- * The screen space x value of a pointer device, if present. This is not present for gamepad, key and text input.
643
- *
644
- * `screen_y`
645
- * The screen space y value of a pointer device, if present. This is not present for gamepad, key and text input.
646
- *
647
- * `dx`
648
- * The change in x value of a pointer device, if present. This is not present for gamepad, key and text input.
649
- *
650
- * `dy`
651
- * The change in y value of a pointer device, if present. This is not present for gamepad, key and text input.
652
- *
653
- * `screen_dx`
654
- * The change in screen space x value of a pointer device, if present. This is not present for gamepad, key and text input.
655
- *
656
- * `screen_dy`
657
- * The change in screen space y value of a pointer device, if present. This is not present for gamepad, key and text input.
658
- *
659
- * `gamepad`
660
- * The index of the gamepad device that provided the input. See table below about gamepad input.
661
- *
662
- * `touch`
663
- * List of touch input, one element per finger, if present. See table below about touch input
664
- *
665
- * `text`
666
- * Text input from a (virtual) keyboard or similar.
667
- *
668
- * `marked_text`
669
- * Sequence of entered symbols while entering a symbol combination, for example Japanese Kana.
670
- *
671
- * Gamepad specific fields:
672
- *
673
- * Field
674
- * Description
675
- *
676
- * `gamepad`
677
- * The index of the gamepad device that provided the input.
678
- *
679
- * `userid`
680
- * Id of the user associated with the controller. Usually only relevant on consoles.
681
- *
682
- * `gamepad_unknown`
683
- * True if the inout originated from an unknown/unmapped gamepad.
684
- *
685
- * `gamepad_name`
686
- * Name of the gamepad
687
- *
688
- * `gamepad_axis`
689
- * List of gamepad axis values. For raw gamepad input only.
690
- *
691
- * `gamepadhats`
692
- * List of gamepad hat values. For raw gamepad input only.
693
- *
694
- * `gamepad_buttons`
695
- * List of gamepad button values. For raw gamepad input only.
696
- *
697
- * Touch input table:
698
- *
699
- * Field
700
- * Description
701
- *
702
- * `id`
703
- * A number identifying the touch input during its duration.
704
- *
705
- * `pressed`
706
- * True if the finger was pressed this frame.
707
- *
708
- * `released`
709
- * True if the finger was released this frame.
710
- *
711
- * `tap_count`
712
- * Number of taps, one for single, two for double-tap, etc
713
- *
714
- * `x`
715
- * The x touch location.
716
- *
717
- * `y`
718
- * The y touch location.
719
- *
720
- * `dx`
721
- * The change in x value.
722
- *
723
- * `dy`
724
- * The change in y value.
725
- *
726
- * `acc_x`
727
- * Accelerometer x value (if present).
728
- *
729
- * `acc_y`
730
- * Accelerometer y value (if present).
731
- *
732
- * `acc_z`
733
- * Accelerometer z value (if present).
734
- *
735
- * @param self - reference to the script state to be used for storing data
736
- * @param action_id - id of the received input action, as mapped in the input_binding-file
737
- * @param action - a table containing the input data, see above for a description. **0️⃣ `gamepad` is 0-based; passed to Defold unchanged.**
738
- * @returns optional boolean to signal if the input should be consumed (not passed on to others) or not, default is false
739
- * @example
740
- * ```ts
741
- * // This example demonstrates how a game object instance can be moved as a response to user input.
742
- * export default defineScript({
743
- * init() {
744
- * // acquire input focus
745
- * msg.post(".", "acquire_input_focus");
746
- * return {
747
- * // maximum speed the instance can be moved
748
- * max_speed: 2,
749
- * // velocity of the instance, initially zero
750
- * velocity: vmath.vector3(),
751
- * };
752
- * },
753
- *
754
- * update(self, dt) {
755
- * // move the instance
756
- * go.set_position(go.get_position().add(self.velocity.mul(dt)));
757
- * },
758
- *
759
- * on_input(self, action_id, action) {
760
- * // check for movement input
761
- * if (action_id === hash("right")) {
762
- * if (action.released) {
763
- * // reset velocity if input was released
764
- * self.velocity = vmath.vector3();
765
- * } else {
766
- * // update velocity
767
- * self.velocity = vmath.vector3((action.value ?? 0) * self.max_speed, 0, 0);
768
- * }
769
- * }
770
- * },
771
- * });
772
- * ```
773
- */
774
- export function on_input(self: Opaque<"userdata">, action_id: Hash, action: { 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; gamepad_axis?: Vector3; touch?: { 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 }[]; text?: string }): boolean | undefined;
775
- /**
776
- * This is a callback-function, which is called by the engine whenever a message has been sent to the script component.
777
- * It can be used to take action on the message, e.g. send a response back to the sender of the message.
778
- * The `message` parameter is a table containing the message data. If the message is sent from the engine, the
779
- * documentation of the message specifies which data is supplied.
780
- *
781
- * @param self - reference to the script state to be used for storing data
782
- * @param message_id - id of the received message
783
- * @param message - a table containing the message data
784
- * @param sender - address of the sender
785
- * @example
786
- * This example demonstrates how a game object instance, called "a", can communicate with another instance, called "b". It
787
- * is assumed that both script components of the instances has id "script".
788
- * Script of instance "a":
789
- * ```ts
790
- * // This example demonstrates how a game object instance, called "a", can communicate with another instance, called "b". It
791
- * // is assumed that both script components of the instances has id "script".
792
- *
793
- * // a.script — Script of instance "a":
794
- * export default defineScript({
795
- * init() {
796
- * // let b know about some important data
797
- * msg.post("b#script", "my_data", { important_value: 1 });
798
- * },
799
- * });
800
- * ```
801
- * @example
802
- * Script of instance "b":
803
- * ```ts
804
- * // b.script — Script of instance "b":
805
- * export default defineScript({
806
- * init() {
807
- * // store the url of instance "a" for later use, by specifying undefined as socket we
808
- * // automatically use our own socket
809
- * return { a_url: msg.url(undefined, go.get_id("a"), "script"), important_value: 0 };
810
- * },
811
- *
812
- * on_message(self, message_id, message, sender) {
813
- * // check message and sender
814
- * if (message_id === hash("my_data") && sender === self.a_url && typeof message.important_value === "number") {
815
- * // use the data in some way
816
- * self.important_value = message.important_value;
817
- * }
818
- * },
819
- * });
820
- * ```
821
- */
822
- export function on_message(self: Opaque<"userdata">, message_id: Hash, message: Record<string | number, unknown>, sender: Url): void;
823
- /**
824
- * This is a callback-function, which is called by the engine when the script component is reloaded, e.g. from the editor.
825
- * It can be used for live development, e.g. to tweak constants or set up the state properly for the instance.
826
- *
827
- * @param self - reference to the script state to be used for storing data
828
- * @example
829
- * ```ts
830
- * // This example demonstrates how to tweak the speed of a game object instance that is moved on user input.
831
- * export default defineScript({
832
- * init() {
833
- * // acquire input focus
834
- * msg.post(".", "acquire_input_focus");
835
- * return {
836
- * // maximum speed the instance can be moved, this value is tweaked in the on_reload function below
837
- * max_speed: 2,
838
- * // velocity of the instance, initially zero
839
- * velocity: vmath.vector3(),
840
- * };
841
- * },
842
- *
843
- * update(self, dt) {
844
- * // move the instance
845
- * go.set_position(go.get_position().add(self.velocity.mul(dt)));
846
- * },
847
- *
848
- * on_input(self, action_id, action) {
849
- * // check for movement input
850
- * if (action_id === hash("right")) {
851
- * if (action.released) {
852
- * // reset velocity if input was released
853
- * self.velocity = vmath.vector3();
854
- * } else {
855
- * // update velocity
856
- * self.velocity = vmath.vector3((action.value ?? 0) * self.max_speed, 0, 0);
857
- * }
858
- * }
859
- * },
860
- *
861
- * on_reload(self) {
862
- * // edit this value and reload the script component
863
- * self.max_speed = 100;
864
- * },
865
- * });
866
- * ```
867
- */
868
- export function on_reload(self: Opaque<"userdata">): void;
869
664
  /**
870
665
  * Sets the parent for a game object instance. This means that the instance will exist in the geometrical space of its parent,
871
666
  * like a basic transformation hierarchy or scene graph. If no parent is specified, the instance will be detached from any parent and exist in world
@@ -978,29 +773,6 @@ declare global {
978
773
  * ```
979
774
  */
980
775
  export function set_scale_xy(scale: number | Vector3, id?: SceneGameObjectAddress | Hash | Url): void;
981
- /**
982
- * This is a callback-function, which is called by the engine every frame to update the state of a script component.
983
- * It can be used to perform any kind of game related tasks, e.g. moving the game object instance.
984
- *
985
- * @param self - reference to the script state to be used for storing data
986
- * @param dt - the time-step of the frame update
987
- * @example
988
- * ```ts
989
- * // This example demonstrates how to move a game object instance through the script component:
990
- * export default defineScript({
991
- * init() {
992
- * // set initial velocity to be 1 along world x-axis
993
- * return { my_velocity: vmath.vector3(1, 0, 0) };
994
- * },
995
- *
996
- * update(self, dt) {
997
- * // move the game object instance
998
- * go.set_position(go.get_position().add(self.my_velocity.mul(dt)));
999
- * },
1000
- * });
1001
- * ```
1002
- */
1003
- export function update(self: Opaque<"userdata">, dt: number): void;
1004
776
  /**
1005
777
  * Recalculates and updates the cached world transform immediately for the target instance
1006
778
  * and its ancestors (parent chain up to the collection root). Descendants (children) are
@@ -4,6 +4,7 @@ declare global {
4
4
  * Graphics functions and constants.
5
5
  */
6
6
  namespace graphics {
7
+ type BlendFactor = typeof graphics.BLEND_FACTOR_ZERO | typeof graphics.BLEND_FACTOR_ONE | typeof graphics.BLEND_FACTOR_SRC_COLOR | typeof graphics.BLEND_FACTOR_ONE_MINUS_SRC_COLOR | typeof graphics.BLEND_FACTOR_DST_COLOR | typeof graphics.BLEND_FACTOR_ONE_MINUS_DST_COLOR | typeof graphics.BLEND_FACTOR_SRC_ALPHA | typeof graphics.BLEND_FACTOR_ONE_MINUS_SRC_ALPHA | typeof graphics.BLEND_FACTOR_DST_ALPHA | typeof graphics.BLEND_FACTOR_ONE_MINUS_DST_ALPHA | typeof graphics.BLEND_FACTOR_SRC_ALPHA_SATURATE | typeof graphics.BLEND_FACTOR_CONSTANT_COLOR | typeof graphics.BLEND_FACTOR_ONE_MINUS_CONSTANT_COLOR | typeof graphics.BLEND_FACTOR_CONSTANT_ALPHA | typeof graphics.BLEND_FACTOR_ONE_MINUS_CONSTANT_ALPHA;
7
8
  type BufferType = typeof graphics.BUFFER_TYPE_COLOR0_BIT | typeof graphics.BUFFER_TYPE_COLOR1_BIT | typeof graphics.BUFFER_TYPE_COLOR2_BIT | typeof graphics.BUFFER_TYPE_COLOR3_BIT | typeof graphics.BUFFER_TYPE_DEPTH_BIT | typeof graphics.BUFFER_TYPE_STENCIL_BIT;
8
9
  type State = typeof graphics.STATE_DEPTH_TEST | typeof graphics.STATE_STENCIL_TEST | typeof graphics.STATE_BLEND | typeof graphics.STATE_ALPHA_TEST | typeof graphics.STATE_CULL_FACE | typeof graphics.STATE_POLYGON_OFFSET_FILL;
9
10
  const BLEND_FACTOR_CONSTANT_ALPHA: number & { readonly __brand: "graphics.BLEND_FACTOR_CONSTANT_ALPHA" };