@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.
- package/api-availability.json +4 -58
- package/api-signatures.json +878 -1356
- package/api-targets.json +15 -5
- package/examples/translations.json +4 -56
- package/generated/b2d_world.d.ts +10 -10
- package/generated/buffer.d.ts +9 -9
- package/generated/bullet3d_collision_object.d.ts +1 -1
- package/generated/bullet3d_constraint.d.ts +109 -7
- package/generated/bullet3d_shape.d.ts +2 -2
- package/generated/go.d.ts +114 -220
- package/generated/graphics.d.ts +1 -0
- package/generated/gui.d.ts +148 -371
- package/generated/http.d.ts +2 -2
- package/generated/image.d.ts +55 -3
- package/generated/kinds/gui-script.d.ts +2 -0
- package/generated/kinds/render-script.d.ts +14 -15
- package/generated/liveupdate.d.ts +5 -1
- package/generated/material.d.ts +3 -3
- package/generated/particlefx.d.ts +20 -1
- package/generated/physics.d.ts +45 -1
- package/generated/render-script-modules/b2d.d.ts +711 -0
- package/generated/render-script-modules/bullet3d.d.ts +73 -0
- package/generated/render-script-modules/collectionfactory.d.ts +25 -0
- package/generated/render-script-modules/collectionproxy.d.ts +39 -0
- package/generated/render-script-modules/factory.d.ts +25 -0
- package/generated/render-script-modules/go.d.ts +436 -0
- package/generated/render-script-modules/label.d.ts +105 -0
- package/generated/render-script-modules/model.d.ts +89 -0
- package/generated/render-script-modules/particlefx.d.ts +59 -0
- package/generated/render-script-modules/physics.d.ts +333 -0
- package/generated/render-script-modules/resource.d.ts +1233 -0
- package/generated/render-script-modules/sound.d.ts +227 -0
- package/generated/render-script-modules/sprite.d.ts +68 -0
- package/generated/render-script-modules/tilemap.d.ts +43 -0
- package/generated/render.d.ts +134 -8
- package/generated/resource.d.ts +31 -10
- package/generated/sprite.d.ts +49 -1
- package/generated/sys.d.ts +70 -6
- package/generated/versions/defold-1.12.4/buffer.d.ts +8 -8
- package/generated/versions/defold-1.12.4/go.d.ts +115 -343
- package/generated/versions/defold-1.12.4/graphics.d.ts +1 -0
- package/generated/versions/defold-1.12.4/gui.d.ts +151 -513
- package/generated/versions/defold-1.12.4/http.d.ts +2 -2
- package/generated/versions/defold-1.12.4/image.d.ts +82 -2
- package/generated/versions/defold-1.12.4/index.d.ts +1 -0
- package/generated/versions/defold-1.12.4/liveupdate.d.ts +4 -0
- package/generated/versions/defold-1.12.4/particlefx.d.ts +22 -1
- package/generated/versions/defold-1.12.4/physics.d.ts +45 -1
- package/generated/versions/defold-1.12.4/render.d.ts +78 -2
- package/generated/versions/defold-1.12.4/resource.d.ts +43 -10
- package/generated/versions/defold-1.12.4/sprite.d.ts +58 -1
- package/generated/versions/defold-1.12.4/sys.d.ts +101 -6
- package/generated/versions/defold-1.12.4/vmath.d.ts +0 -24
- package/generated/versions/defold-1.13.0/buffer.d.ts +8 -8
- package/generated/versions/defold-1.13.0/go.d.ts +115 -370
- package/generated/versions/defold-1.13.0/graphics.d.ts +1 -0
- package/generated/versions/defold-1.13.0/gui.d.ts +151 -513
- package/generated/versions/defold-1.13.0/http.d.ts +2 -2
- package/generated/versions/defold-1.13.0/image.d.ts +82 -2
- package/generated/versions/defold-1.13.0/index.d.ts +1 -0
- package/generated/versions/defold-1.13.0/liveupdate.d.ts +4 -0
- package/generated/versions/defold-1.13.0/material.d.ts +3 -1
- package/generated/versions/defold-1.13.0/particlefx.d.ts +22 -1
- package/generated/versions/defold-1.13.0/physics.d.ts +45 -1
- package/generated/versions/defold-1.13.0/render.d.ts +142 -4
- package/generated/versions/defold-1.13.0/resource.d.ts +43 -10
- package/generated/versions/defold-1.13.0/sprite.d.ts +58 -1
- package/generated/versions/defold-1.13.0/sys.d.ts +101 -6
- package/generated/versions/defold-1.13.0/vmath.d.ts +0 -24
- package/generated/versions/defold-1.13.1/buffer.d.ts +8 -8
- package/generated/versions/defold-1.13.1/go.d.ts +115 -370
- package/generated/versions/defold-1.13.1/graphics.d.ts +1 -0
- package/generated/versions/defold-1.13.1/gui.d.ts +151 -529
- package/generated/versions/defold-1.13.1/http.d.ts +2 -2
- package/generated/versions/defold-1.13.1/image.d.ts +82 -2
- package/generated/versions/defold-1.13.1/index.d.ts +2 -0
- package/generated/versions/defold-1.13.1/liveupdate.d.ts +4 -0
- package/generated/versions/defold-1.13.1/material.d.ts +3 -1
- package/generated/versions/defold-1.13.1/particlefx.d.ts +22 -1
- package/generated/versions/defold-1.13.1/physics.d.ts +45 -1
- package/generated/versions/defold-1.13.1/render.d.ts +142 -4
- package/generated/versions/defold-1.13.1/resource.d.ts +43 -10
- package/generated/versions/defold-1.13.1/sprite.d.ts +58 -1
- package/generated/versions/defold-1.13.1/sys.d.ts +101 -6
- package/generated/versions/defold-1.13.1/vmath.d.ts +0 -24
- package/generated/versions/defold-1.13.2/b2d_world.d.ts +10 -10
- package/generated/versions/defold-1.13.2/buffer.d.ts +9 -9
- package/generated/versions/defold-1.13.2/bullet3d_collision_object.d.ts +1 -1
- package/generated/versions/defold-1.13.2/bullet3d_constraint.d.ts +109 -7
- package/generated/versions/defold-1.13.2/bullet3d_shape.d.ts +2 -2
- package/generated/versions/defold-1.13.2/go.d.ts +114 -220
- package/generated/versions/defold-1.13.2/graphics.d.ts +1 -0
- package/generated/versions/defold-1.13.2/gui.d.ts +148 -371
- package/generated/versions/defold-1.13.2/http.d.ts +2 -2
- package/generated/versions/defold-1.13.2/image.d.ts +55 -3
- package/generated/versions/defold-1.13.2/index.d.ts +2 -0
- package/generated/versions/defold-1.13.2/liveupdate.d.ts +5 -1
- package/generated/versions/defold-1.13.2/material.d.ts +3 -3
- package/generated/versions/defold-1.13.2/particlefx.d.ts +20 -1
- package/generated/versions/defold-1.13.2/physics.d.ts +45 -1
- package/generated/versions/defold-1.13.2/render.d.ts +123 -7
- package/generated/versions/defold-1.13.2/resource.d.ts +31 -10
- package/generated/versions/defold-1.13.2/sprite.d.ts +49 -1
- package/generated/versions/defold-1.13.2/sys.d.ts +70 -6
- package/generated/versions/defold-1.13.2/vmath.d.ts +0 -24
- package/generated/vmath.d.ts +0 -24
- package/identity-vocabulary.json +52 -7
- package/index.d.ts +2 -0
- package/package.json +2 -1
- package/scripts/generate-api-availability.ts +1 -21
- package/scripts/generate-api-signatures.ts +75 -14
- package/scripts/materialize-version.ts +48 -7
- package/scripts/regen.ts +214 -19
- package/scripts/signature-store-fs.ts +1 -0
- package/scripts/target-version.ts +26 -0
- package/src/api-doc.ts +26 -0
- package/src/component-properties.d.ts +89 -0
- package/src/core-types.ts +42 -15
- package/src/doc-corrections.ts +53 -5
- package/src/emit-dts.ts +758 -198
- package/src/engine-globals.d.ts +5 -1
- package/src/go-overloads.d.ts +68 -13
- package/src/gui-overloads.d.ts +489 -0
- package/src/gui-texture-removal.d.ts +41 -0
- package/src/index.ts +2 -0
- package/src/lifecycle.ts +30 -21
- package/src/msg-overloads.d.ts +25 -13
- package/src/signature-store.ts +50 -0
- package/src/timers.d.ts +2 -1
- package/src/vmath-overloads.d.ts +26 -0
package/generated/go.d.ts
CHANGED
|
@@ -276,7 +276,65 @@ declare global {
|
|
|
276
276
|
* go.animate("go", "position.y", go.PLAYBACK_LOOP_PINGPONG, 100, vec, 2.0);
|
|
277
277
|
* ```
|
|
278
278
|
*/
|
|
279
|
-
export function animate(url: SceneAddress | Hash | Url, property: string | Hash, playback: go.PLAYBACK, to: number | Vector3 | Vector4 | Quaternion, easing: Vector | go.EASING, duration: number
|
|
279
|
+
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;
|
|
280
|
+
/**
|
|
281
|
+
* This is only supported for numerical properties. If the node property is already being
|
|
282
|
+
* animated, that animation will be canceled and replaced by the new one.
|
|
283
|
+
* If a `complete_function` (lua function) is specified, that function will be called when the animation has completed.
|
|
284
|
+
* By starting a new animation in that function, several animations can be sequenced together. See the examples for more information.
|
|
285
|
+
* If you call `go.animate()` from a game object's `final()` function,
|
|
286
|
+
* any passed `complete_function` will be ignored and never called upon animation completion.
|
|
287
|
+
* See the properties guide for which properties can be animated and the animation guide for how
|
|
288
|
+
* them.
|
|
289
|
+
*
|
|
290
|
+
* @param url - url of the game object or component having the property
|
|
291
|
+
* @param property - id of the property to animate
|
|
292
|
+
* @param playback - playback mode of the animation
|
|
293
|
+
*
|
|
294
|
+
* - `go.PLAYBACK_ONCE_FORWARD`
|
|
295
|
+
* - `go.PLAYBACK_ONCE_BACKWARD`
|
|
296
|
+
* - `go.PLAYBACK_ONCE_PINGPONG`
|
|
297
|
+
* - `go.PLAYBACK_LOOP_FORWARD`
|
|
298
|
+
* - `go.PLAYBACK_LOOP_BACKWARD`
|
|
299
|
+
* - `go.PLAYBACK_LOOP_PINGPONG`
|
|
300
|
+
* @param to - target property value
|
|
301
|
+
* @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
|
|
302
|
+
* @param duration - duration of the animation in seconds
|
|
303
|
+
* @param delay - delay before the animation starts in seconds
|
|
304
|
+
* @param complete_function - optional function to call when the animation has completed
|
|
305
|
+
*
|
|
306
|
+
* `self`
|
|
307
|
+
*
|
|
308
|
+
* script_instance The current script instance.
|
|
309
|
+
*
|
|
310
|
+
* `url`
|
|
311
|
+
*
|
|
312
|
+
* url The game object or component instance for which the property is animated.
|
|
313
|
+
*
|
|
314
|
+
* `property`
|
|
315
|
+
*
|
|
316
|
+
* hash The id of the animated property.
|
|
317
|
+
* @example
|
|
318
|
+
* Animate the position of a game object to x = 10 during 1 second, then y = 20 during 1 second:
|
|
319
|
+
* ```ts
|
|
320
|
+
* go.animate(go.get_id(), "position.x", go.PLAYBACK_ONCE_FORWARD, 10, go.EASING_LINEAR, 1, 0, () => {
|
|
321
|
+
* go.animate(go.get_id(), "position.y", go.PLAYBACK_ONCE_FORWARD, 20, go.EASING_LINEAR, 1);
|
|
322
|
+
* });
|
|
323
|
+
* ```
|
|
324
|
+
* @example
|
|
325
|
+
* Animate the y position of a game object using a crazy custom easing curve:
|
|
326
|
+
* ```ts
|
|
327
|
+
* const values = [
|
|
328
|
+
* 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
329
|
+
* 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
330
|
+
* 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
331
|
+
* 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
332
|
+
* ];
|
|
333
|
+
* const vec = vmath.vector(values);
|
|
334
|
+
* go.animate("go", "position.y", go.PLAYBACK_LOOP_PINGPONG, 100, vec, 2.0);
|
|
335
|
+
* ```
|
|
336
|
+
*/
|
|
337
|
+
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: Url, property: Hash) => void): void;
|
|
280
338
|
/**
|
|
281
339
|
* By calling this function, all or specified stored property animations of the game object or component will be canceled.
|
|
282
340
|
* See the properties guide for which properties can be animated and the animation guide for how to animate them.
|
|
@@ -335,7 +393,43 @@ declare global {
|
|
|
335
393
|
* go.delete(ids, true);
|
|
336
394
|
* ```
|
|
337
395
|
*/
|
|
338
|
-
function _delete(id?: SceneGameObjectAddress | Hash | Url | (
|
|
396
|
+
function _delete(id?: SceneGameObjectAddress | Hash | Url | (SceneGameObjectAddress | Hash | Url)[] | LuaPairsIterable<AnyNotNil, SceneGameObjectAddress | Hash | Url> | boolean): void;
|
|
397
|
+
/**
|
|
398
|
+
* Delete one or more game objects identified by id. Deletion is asynchronous meaning that
|
|
399
|
+
* the game object(s) are scheduled for deletion which will happen at the end of the current
|
|
400
|
+
* frame. Note that game objects scheduled for deletion will be counted against
|
|
401
|
+
* `max_instances` in "game.project" until they are actually removed.
|
|
402
|
+
* 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()`.
|
|
403
|
+
* 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()`.
|
|
404
|
+
*
|
|
405
|
+
* @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
|
|
406
|
+
* @param recursive - optional boolean, set to true to recursively delete child hiearchy in child to parent order
|
|
407
|
+
* @example
|
|
408
|
+
* This example demonstrates how to delete game objects
|
|
409
|
+
* ```ts
|
|
410
|
+
* // Delete the script's own game object.
|
|
411
|
+
* go.delete();
|
|
412
|
+
* // Delete a game object with the id "my_game_object".
|
|
413
|
+
* const id = go.get_id("my_game_object"); // retrieve the id of the game object to be deleted
|
|
414
|
+
* go.delete(id);
|
|
415
|
+
* // Delete a list of game objects.
|
|
416
|
+
* const ids = [hash("/my_object_1"), hash("/my_object_2"), hash("/my_object_3")];
|
|
417
|
+
* go.delete(ids);
|
|
418
|
+
* ```
|
|
419
|
+
* @example
|
|
420
|
+
* This example demonstrates how to delete a game objects and their children (child to parent order)
|
|
421
|
+
* ```ts
|
|
422
|
+
* // Delete the script's own game object and its children.
|
|
423
|
+
* go.delete(true);
|
|
424
|
+
* // Delete a game object with the id "my_game_object" and its children.
|
|
425
|
+
* const id = go.get_id("my_game_object"); // retrieve the id of the game object to be deleted
|
|
426
|
+
* go.delete(id, true);
|
|
427
|
+
* // Delete a list of game objects and their children.
|
|
428
|
+
* const ids = [hash("/my_object_1"), hash("/my_object_2"), hash("/my_object_3")];
|
|
429
|
+
* go.delete(ids, true);
|
|
430
|
+
* ```
|
|
431
|
+
*/
|
|
432
|
+
function _delete(id: SceneGameObjectAddress | Hash | Url | (SceneGameObjectAddress | Hash | Url)[] | LuaPairsIterable<AnyNotNil, SceneGameObjectAddress | Hash | Url>, recursive: boolean): void;
|
|
339
433
|
/**
|
|
340
434
|
* This function can check for game objects in any collection by specifying
|
|
341
435
|
* the collection name in the URL.
|
|
@@ -355,36 +449,29 @@ declare global {
|
|
|
355
449
|
*/
|
|
356
450
|
export function exists(url: SceneGameObjectAddress | Hash | Url): boolean;
|
|
357
451
|
/**
|
|
358
|
-
*
|
|
359
|
-
*
|
|
360
|
-
*
|
|
452
|
+
* Returns or constructs an instance identifier. The instance id is a hash
|
|
453
|
+
* of the absolute path to the instance.
|
|
454
|
+
*
|
|
455
|
+
* - If `path` is specified, it can either be absolute or relative to the instance of the calling script.
|
|
456
|
+
* - If `path` is not specified, the id of the game object instance the script is attached to will be returned.
|
|
361
457
|
*
|
|
362
|
-
* @param
|
|
458
|
+
* @param path - path of the instance for which to return the id
|
|
459
|
+
* @returns instance id
|
|
363
460
|
* @example
|
|
364
461
|
* ```ts
|
|
365
|
-
*
|
|
366
|
-
*
|
|
367
|
-
*
|
|
368
|
-
*
|
|
462
|
+
* // For the instance with path /my_sub_collection/my_instance, the following calls
|
|
463
|
+
* // are equivalent:
|
|
464
|
+
* const id = go.get_id(); // no path, defaults to the instance containing the calling script
|
|
465
|
+
* print(id); // => hash: [/my_sub_collection/my_instance]
|
|
369
466
|
*
|
|
370
|
-
*
|
|
371
|
-
*
|
|
372
|
-
* msg.post("my_friend_instance", "im_dead", { my_stats: self.some_value });
|
|
373
|
-
* },
|
|
374
|
-
* });
|
|
375
|
-
* ```
|
|
376
|
-
*/
|
|
377
|
-
export function final(self: unknown): void;
|
|
378
|
-
/**
|
|
379
|
-
* This is a callback-function, which is called by the engine at fixed intervals to update the state of a script
|
|
380
|
-
* component. The function will be called if 'Fixed Update Frequency' is enabled in the Engine section of game.project.
|
|
381
|
-
* It can for instance be used to update game logic with the physics simulation if using a fixed timestep for the
|
|
382
|
-
* physics (enabled by ticking 'Use Fixed Timestep' in the Physics section of game.project).
|
|
467
|
+
* const id2 = go.get_id("/my_sub_collection/my_instance"); // absolute path
|
|
468
|
+
* print(id2); // => hash: [/my_sub_collection/my_instance]
|
|
383
469
|
*
|
|
384
|
-
*
|
|
385
|
-
*
|
|
470
|
+
* const id3 = go.get_id("my_instance"); // relative path
|
|
471
|
+
* print(id3); // => hash: [/my_sub_collection/my_instance]
|
|
472
|
+
* ```
|
|
386
473
|
*/
|
|
387
|
-
export function
|
|
474
|
+
export function get_id(): Hash;
|
|
388
475
|
/**
|
|
389
476
|
* Returns or constructs an instance identifier. The instance id is a hash
|
|
390
477
|
* of the absolute path to the instance.
|
|
@@ -408,7 +495,7 @@ declare global {
|
|
|
408
495
|
* print(id3); // => hash: [/my_sub_collection/my_instance]
|
|
409
496
|
* ```
|
|
410
497
|
*/
|
|
411
|
-
export function get_id(path
|
|
498
|
+
export function get_id(path: string): Hash;
|
|
412
499
|
/**
|
|
413
500
|
* Get the parent for a game object instance.
|
|
414
501
|
*
|
|
@@ -591,176 +678,6 @@ declare global {
|
|
|
591
678
|
* ```
|
|
592
679
|
*/
|
|
593
680
|
export function get_world_transform(id?: SceneGameObjectAddress | Hash | Url): Matrix4;
|
|
594
|
-
/**
|
|
595
|
-
* This is a callback-function, which is called by the engine when a script component is initialized. It can be used
|
|
596
|
-
* to set the initial state of the script.
|
|
597
|
-
*
|
|
598
|
-
* @param self - script instance used for storing state
|
|
599
|
-
* @example
|
|
600
|
-
* ```ts
|
|
601
|
-
* export default defineScript({
|
|
602
|
-
* init() {
|
|
603
|
-
* // set up useful data
|
|
604
|
-
* return { my_value: 1 };
|
|
605
|
-
* },
|
|
606
|
-
* });
|
|
607
|
-
* ```
|
|
608
|
-
*/
|
|
609
|
-
export function init(self: unknown): void;
|
|
610
|
-
/**
|
|
611
|
-
* This is a callback-function, which is called by the engine at the end of the frame to update the state of a script
|
|
612
|
-
* component. Use it to make final adjustments to the game object instance.
|
|
613
|
-
*
|
|
614
|
-
* @param self - script instance used for storing state
|
|
615
|
-
* @param dt - the time-step of the frame update
|
|
616
|
-
*/
|
|
617
|
-
export function late_update(self: unknown, dt: number): void;
|
|
618
|
-
/**
|
|
619
|
-
* This is a callback-function, which is called by the engine when user input is sent to the game object instance of the script.
|
|
620
|
-
* It can be used to take action on the input, e.g. move the instance according to the input.
|
|
621
|
-
* For an instance to obtain user input, it must first acquire input focus
|
|
622
|
-
* through the message `acquire_input_focus`.
|
|
623
|
-
* Any instance that has obtained input will be put on top of an
|
|
624
|
-
* input stack. Input is sent to all listeners on the stack until the
|
|
625
|
-
* end of stack is reached, or a listener returns `true`
|
|
626
|
-
* to signal that it wants input to be consumed.
|
|
627
|
-
* See the documentation of acquire_input_focus for more
|
|
628
|
-
* information.
|
|
629
|
-
*
|
|
630
|
-
* @param self - script instance used for storing state
|
|
631
|
-
* @param action_id - id of the received input action, as mapped in the input_binding-file, or `nil` for mouse movement
|
|
632
|
-
* @param action - input data for the action. **0️⃣ `gamepad` is 0-based; passed to Defold unchanged.**
|
|
633
|
-
* @returns optional boolean to signal if the input should be consumed (not passed on to others) or not, default is false
|
|
634
|
-
* @example
|
|
635
|
-
* ```ts
|
|
636
|
-
* // This example demonstrates how a game object instance can be moved as a response to user input.
|
|
637
|
-
* export default defineScript({
|
|
638
|
-
* init() {
|
|
639
|
-
* // acquire input focus
|
|
640
|
-
* msg.post(".", "acquire_input_focus");
|
|
641
|
-
* return {
|
|
642
|
-
* // maximum speed the instance can be moved
|
|
643
|
-
* max_speed: 2,
|
|
644
|
-
* // velocity of the instance, initially zero
|
|
645
|
-
* velocity: vmath.vector3(),
|
|
646
|
-
* };
|
|
647
|
-
* },
|
|
648
|
-
*
|
|
649
|
-
* update(self, dt) {
|
|
650
|
-
* // move the instance
|
|
651
|
-
* go.set_position(go.get_position().add(self.velocity.mul(dt)));
|
|
652
|
-
* },
|
|
653
|
-
*
|
|
654
|
-
* on_input(self, action_id, action) {
|
|
655
|
-
* // check for movement input
|
|
656
|
-
* if (action_id === hash("right")) {
|
|
657
|
-
* if (action.released) {
|
|
658
|
-
* // reset velocity if input was released
|
|
659
|
-
* self.velocity = vmath.vector3();
|
|
660
|
-
* } else {
|
|
661
|
-
* // update velocity
|
|
662
|
-
* self.velocity = vmath.vector3((action.value ?? 0) * self.max_speed, 0, 0);
|
|
663
|
-
* }
|
|
664
|
-
* }
|
|
665
|
-
* },
|
|
666
|
-
* });
|
|
667
|
-
* ```
|
|
668
|
-
*/
|
|
669
|
-
export function on_input(self: unknown, action_id: Hash | undefined, action: go.on_input.action): boolean | undefined;
|
|
670
|
-
/**
|
|
671
|
-
* This is a callback-function, which is called by the engine whenever a message has been sent to the script component.
|
|
672
|
-
* It can be used to take action on the message, e.g. send a response back to the sender of the message.
|
|
673
|
-
* The `message` parameter is a table containing the message data. If the message is sent from the engine, the
|
|
674
|
-
* documentation of the message specifies which data is supplied.
|
|
675
|
-
*
|
|
676
|
-
* @param self - script instance used for storing state
|
|
677
|
-
* @param message_id - id of the received message
|
|
678
|
-
* @param message - a table containing the message data
|
|
679
|
-
* @param sender - address of the sender
|
|
680
|
-
* @example
|
|
681
|
-
* This example demonstrates how a game object instance, called "a", can communicate with another instance, called "b". It
|
|
682
|
-
* is assumed that both script components of the instances has id "script".
|
|
683
|
-
* Script of instance "a":
|
|
684
|
-
* ```ts
|
|
685
|
-
* // This example demonstrates how a game object instance, called "a", can communicate with another instance, called "b". It
|
|
686
|
-
* // is assumed that both script components of the instances has id "script".
|
|
687
|
-
*
|
|
688
|
-
* // a.script — Script of instance "a":
|
|
689
|
-
* export default defineScript({
|
|
690
|
-
* init() {
|
|
691
|
-
* // let b know about some important data
|
|
692
|
-
* msg.post("b#script", "my_data", { important_value: 1 });
|
|
693
|
-
* },
|
|
694
|
-
* });
|
|
695
|
-
* ```
|
|
696
|
-
* @example
|
|
697
|
-
* Script of instance "b":
|
|
698
|
-
* ```ts
|
|
699
|
-
* // b.script — Script of instance "b":
|
|
700
|
-
* export default defineScript({
|
|
701
|
-
* init() {
|
|
702
|
-
* // store the url of instance "a" for later use, by specifying undefined as socket we
|
|
703
|
-
* // automatically use our own socket
|
|
704
|
-
* return { a_url: msg.url(undefined, go.get_id("a"), "script"), important_value: 0 };
|
|
705
|
-
* },
|
|
706
|
-
*
|
|
707
|
-
* on_message(self, message_id, message, sender) {
|
|
708
|
-
* // check message and sender
|
|
709
|
-
* if (message_id === hash("my_data") && sender === self.a_url && typeof message.important_value === "number") {
|
|
710
|
-
* // use the data in some way
|
|
711
|
-
* self.important_value = message.important_value;
|
|
712
|
-
* }
|
|
713
|
-
* },
|
|
714
|
-
* });
|
|
715
|
-
* ```
|
|
716
|
-
*/
|
|
717
|
-
export function on_message(self: unknown, message_id: Hash, message: LuaMap<AnyNotNil, unknown> | Record<string, unknown>, sender: Url): void;
|
|
718
|
-
/**
|
|
719
|
-
* This is a callback-function, which is called by the engine when the script component is reloaded, e.g. from the editor.
|
|
720
|
-
* It can be used for live development, e.g. to tweak constants or set up the state properly for the instance.
|
|
721
|
-
*
|
|
722
|
-
* @param self - script instance used for storing state
|
|
723
|
-
* @example
|
|
724
|
-
* ```ts
|
|
725
|
-
* // This example demonstrates how to tweak the speed of a game object instance that is moved on user input.
|
|
726
|
-
* export default defineScript({
|
|
727
|
-
* init() {
|
|
728
|
-
* // acquire input focus
|
|
729
|
-
* msg.post(".", "acquire_input_focus");
|
|
730
|
-
* return {
|
|
731
|
-
* // maximum speed the instance can be moved, this value is tweaked in the on_reload function below
|
|
732
|
-
* max_speed: 2,
|
|
733
|
-
* // velocity of the instance, initially zero
|
|
734
|
-
* velocity: vmath.vector3(),
|
|
735
|
-
* };
|
|
736
|
-
* },
|
|
737
|
-
*
|
|
738
|
-
* update(self, dt) {
|
|
739
|
-
* // move the instance
|
|
740
|
-
* go.set_position(go.get_position().add(self.velocity.mul(dt)));
|
|
741
|
-
* },
|
|
742
|
-
*
|
|
743
|
-
* on_input(self, action_id, action) {
|
|
744
|
-
* // check for movement input
|
|
745
|
-
* if (action_id === hash("right")) {
|
|
746
|
-
* if (action.released) {
|
|
747
|
-
* // reset velocity if input was released
|
|
748
|
-
* self.velocity = vmath.vector3();
|
|
749
|
-
* } else {
|
|
750
|
-
* // update velocity
|
|
751
|
-
* self.velocity = vmath.vector3((action.value ?? 0) * self.max_speed, 0, 0);
|
|
752
|
-
* }
|
|
753
|
-
* }
|
|
754
|
-
* },
|
|
755
|
-
*
|
|
756
|
-
* on_reload(self) {
|
|
757
|
-
* // edit this value and reload the script component
|
|
758
|
-
* self.max_speed = 100;
|
|
759
|
-
* },
|
|
760
|
-
* });
|
|
761
|
-
* ```
|
|
762
|
-
*/
|
|
763
|
-
export function on_reload(self: unknown): void;
|
|
764
681
|
/**
|
|
765
682
|
* Sets the parent for a game object instance. This means that the instance will exist in the geometrical space of its parent,
|
|
766
683
|
* 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
|
|
@@ -873,29 +790,6 @@ declare global {
|
|
|
873
790
|
* ```
|
|
874
791
|
*/
|
|
875
792
|
export function set_scale_xy(scale: number | Vector3, id?: SceneGameObjectAddress | Hash | Url): void;
|
|
876
|
-
/**
|
|
877
|
-
* This is a callback-function, which is called by the engine every frame to update the state of a script component.
|
|
878
|
-
* It can be used to perform any kind of game related tasks, e.g. moving the game object instance.
|
|
879
|
-
*
|
|
880
|
-
* @param self - script instance used for storing state
|
|
881
|
-
* @param dt - the time-step of the frame update
|
|
882
|
-
* @example
|
|
883
|
-
* ```ts
|
|
884
|
-
* // This example demonstrates how to move a game object instance through the script component:
|
|
885
|
-
* export default defineScript({
|
|
886
|
-
* init() {
|
|
887
|
-
* // set initial velocity to be 1 along world x-axis
|
|
888
|
-
* return { my_velocity: vmath.vector3(1, 0, 0) };
|
|
889
|
-
* },
|
|
890
|
-
*
|
|
891
|
-
* update(self, dt) {
|
|
892
|
-
* // move the game object instance
|
|
893
|
-
* go.set_position(go.get_position().add(self.my_velocity.mul(dt)));
|
|
894
|
-
* },
|
|
895
|
-
* });
|
|
896
|
-
* ```
|
|
897
|
-
*/
|
|
898
|
-
export function update(self: unknown, dt: number): void;
|
|
899
793
|
/**
|
|
900
794
|
* Recalculates and updates the cached world transform immediately for the target instance
|
|
901
795
|
* and its ancestors (parent chain up to the collection root). Descendants (children) are
|
package/generated/graphics.d.ts
CHANGED
|
@@ -114,6 +114,7 @@ declare global {
|
|
|
114
114
|
*/
|
|
115
115
|
max_storage_buffers_per_stage: number;
|
|
116
116
|
}
|
|
117
|
+
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;
|
|
117
118
|
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;
|
|
118
119
|
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;
|
|
119
120
|
type BLEND_EQUATION = typeof graphics.BLEND_EQUATION_ADD | typeof graphics.BLEND_EQUATION_MAX | typeof graphics.BLEND_EQUATION_MIN | typeof graphics.BLEND_EQUATION_REVERSE_SUBTRACT | typeof graphics.BLEND_EQUATION_SUBTRACT;
|