@defold-typescript/types 0.5.4 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/api-targets.json +1 -1
- package/generated/b2d.d.ts +3 -0
- package/generated/buffer.d.ts +44 -38
- package/generated/builtin-messages.d.ts +1 -1
- package/generated/camera.d.ts +3 -0
- package/generated/collectionfactory.d.ts +47 -40
- package/generated/collectionproxy.d.ts +23 -18
- package/generated/crash.d.ts +3 -0
- package/generated/factory.d.ts +32 -24
- package/generated/go.d.ts +293 -293
- package/generated/graphics.d.ts +3 -0
- package/generated/gui.d.ts +303 -283
- package/generated/http.d.ts +26 -16
- package/generated/iac.d.ts +3 -0
- package/generated/iap.d.ts +6 -3
- package/generated/image.d.ts +30 -26
- package/generated/json.d.ts +36 -32
- package/generated/kinds/gui-script.d.ts +7 -5
- package/generated/kinds/render-script.d.ts +7 -5
- package/generated/kinds/script.d.ts +7 -5
- package/generated/label.d.ts +16 -9
- package/generated/liveupdate.d.ts +29 -26
- package/generated/model.d.ts +57 -45
- package/generated/msg.d.ts +12 -9
- package/generated/particlefx.d.ts +50 -34
- package/generated/physics.d.ts +153 -133
- package/generated/profiler.d.ts +45 -41
- package/generated/push.d.ts +5 -2
- package/generated/render.d.ts +410 -349
- package/generated/resource.d.ts +619 -572
- package/generated/socket.d.ts +49 -33
- package/generated/sound.d.ts +83 -72
- package/generated/sprite.d.ts +36 -32
- package/generated/sys.d.ts +198 -189
- package/generated/tilemap.d.ts +43 -39
- package/generated/timer.d.ts +42 -36
- package/generated/vmath.d.ts +254 -229
- package/generated/webview.d.ts +3 -0
- package/generated/window.d.ts +23 -17
- package/generated/zlib.d.ts +15 -12
- package/index.d.ts +3 -1
- package/package.json +6 -2
- package/scripts/example-store-io.ts +18 -0
- package/scripts/fidelity-audit.ts +61 -1
- package/scripts/fidelity-baseline.json +10 -10
- package/scripts/ref-doc-delta.ts +143 -0
- package/scripts/regen.ts +23 -10
- package/src/core-types.ts +14 -0
- package/src/doc-comment.ts +2 -1
- package/src/emit-dts.ts +238 -18
- package/src/engine-globals.d.ts +2 -0
- package/src/example-store.ts +44 -0
- package/src/go-overloads.d.ts +73 -0
- package/src/index.ts +5 -0
- package/src/lifecycle.ts +157 -16
- package/src/message-dispatch.d.ts +21 -0
- package/src/message-guard.d.ts +19 -0
- package/src/msg-overloads.d.ts +20 -0
- package/src/publish-dts.ts +1 -1
package/generated/go.d.ts
CHANGED
|
@@ -2,6 +2,11 @@
|
|
|
2
2
|
import type { Hash, Matrix4, Opaque, Quaternion, Url, Vector, Vector3, Vector4 } from "../src/core-types";
|
|
3
3
|
|
|
4
4
|
declare global {
|
|
5
|
+
/**
|
|
6
|
+
* Functions, core hooks, messages and constants for manipulation of
|
|
7
|
+
* game objects. The "go" namespace is accessible from game object script
|
|
8
|
+
* files.
|
|
9
|
+
*/
|
|
5
10
|
namespace go {
|
|
6
11
|
/**
|
|
7
12
|
* in-back
|
|
@@ -226,27 +231,22 @@ declare global {
|
|
|
226
231
|
* `property`
|
|
227
232
|
* hash The id of the animated property.
|
|
228
233
|
* @example
|
|
229
|
-
* ```
|
|
230
|
-
* Animate the position of a game object to x = 10 during 1 second, then
|
|
231
|
-
*
|
|
232
|
-
*
|
|
233
|
-
*
|
|
234
|
-
*
|
|
235
|
-
*
|
|
236
|
-
*
|
|
237
|
-
*
|
|
238
|
-
*
|
|
239
|
-
*
|
|
240
|
-
*
|
|
241
|
-
*
|
|
242
|
-
*
|
|
243
|
-
*
|
|
244
|
-
*
|
|
245
|
-
* 1, 1, 1, 1, 1, 1, 1, 1,
|
|
246
|
-
* 0, 0, 0, 0, 0, 0, 0, 0,
|
|
247
|
-
* 1, 1, 1, 1, 1, 1, 1, 1 }
|
|
248
|
-
* local vec = vmath.vector(values)
|
|
249
|
-
* go.animate("go", "position.y", go.PLAYBACK_LOOP_PINGPONG, 100, vec, 2.0)
|
|
234
|
+
* ```ts
|
|
235
|
+
* // Animate the position of a game object to x = 10 during 1 second, then
|
|
236
|
+
* // y = 20 during 1 second:
|
|
237
|
+
* go.animate(go.get_id(), "position.x", go.PLAYBACK_ONCE_FORWARD, 10, go.EASING_LINEAR, 1, 0, () => {
|
|
238
|
+
* go.animate(go.get_id(), "position.y", go.PLAYBACK_ONCE_FORWARD, 20, go.EASING_LINEAR, 1);
|
|
239
|
+
* });
|
|
240
|
+
*
|
|
241
|
+
* // Animate the y position of a game object using a crazy custom easing curve:
|
|
242
|
+
* const values = [
|
|
243
|
+
* 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
244
|
+
* 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
245
|
+
* 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
246
|
+
* 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
247
|
+
* ];
|
|
248
|
+
* const vec = vmath.vector(values);
|
|
249
|
+
* go.animate("go", "position.y", go.PLAYBACK_LOOP_PINGPONG, 100, vec, 2.0);
|
|
250
250
|
* ```
|
|
251
251
|
*/
|
|
252
252
|
export function animate(url: string | Hash | Url, property: string | Hash, playback: number & { readonly __brand: "go.PLAYBACK_ONCE_FORWARD" } | number & { readonly __brand: "go.PLAYBACK_ONCE_BACKWARD" } | number & { readonly __brand: "go.PLAYBACK_ONCE_PINGPONG" } | number & { readonly __brand: "go.PLAYBACK_LOOP_FORWARD" } | number & { readonly __brand: "go.PLAYBACK_LOOP_BACKWARD" } | number & { readonly __brand: "go.PLAYBACK_LOOP_PINGPONG" }, to: number | Vector3 | Vector4 | Quaternion, easing: Vector | number & { readonly __brand: "go.EASING_INBACK" } | number & { readonly __brand: "go.EASING_INBOUNCE" } | number & { readonly __brand: "go.EASING_INCIRC" } | number & { readonly __brand: "go.EASING_INCUBIC" } | number & { readonly __brand: "go.EASING_INELASTIC" } | number & { readonly __brand: "go.EASING_INEXPO" } | number & { readonly __brand: "go.EASING_INOUTBACK" } | number & { readonly __brand: "go.EASING_INOUTBOUNCE" } | number & { readonly __brand: "go.EASING_INOUTCIRC" } | number & { readonly __brand: "go.EASING_INOUTCUBIC" } | number & { readonly __brand: "go.EASING_INOUTELASTIC" } | number & { readonly __brand: "go.EASING_INOUTEXPO" } | number & { readonly __brand: "go.EASING_INOUTQUAD" } | number & { readonly __brand: "go.EASING_INOUTQUART" } | number & { readonly __brand: "go.EASING_INOUTQUINT" } | number & { readonly __brand: "go.EASING_INOUTSINE" } | number & { readonly __brand: "go.EASING_INQUAD" } | number & { readonly __brand: "go.EASING_INQUART" } | number & { readonly __brand: "go.EASING_INQUINT" } | number & { readonly __brand: "go.EASING_INSINE" } | number & { readonly __brand: "go.EASING_LINEAR" } | number & { readonly __brand: "go.EASING_OUTBACK" } | number & { readonly __brand: "go.EASING_OUTBOUNCE" } | number & { readonly __brand: "go.EASING_OUTCIRC" } | number & { readonly __brand: "go.EASING_OUTCUBIC" } | number & { readonly __brand: "go.EASING_OUTELASTIC" } | number & { readonly __brand: "go.EASING_OUTEXPO" } | number & { readonly __brand: "go.EASING_OUTINBACK" } | number & { readonly __brand: "go.EASING_OUTINBOUNCE" } | number & { readonly __brand: "go.EASING_OUTINCIRC" } | number & { readonly __brand: "go.EASING_OUTINCUBIC" } | number & { readonly __brand: "go.EASING_OUTINELASTIC" } | number & { readonly __brand: "go.EASING_OUTINEXPO" } | number & { readonly __brand: "go.EASING_OUTINQUAD" } | number & { readonly __brand: "go.EASING_OUTINQUART" } | number & { readonly __brand: "go.EASING_OUTINQUINT" } | number & { readonly __brand: "go.EASING_OUTINSINE" } | number & { readonly __brand: "go.EASING_OUTQUAD" } | number & { readonly __brand: "go.EASING_OUTQUART" } | number & { readonly __brand: "go.EASING_OUTQUINT" } | number & { readonly __brand: "go.EASING_OUTSINE" }, duration: number, delay?: number, complete_function?: (self: unknown, url: unknown, property: unknown) => void): void;
|
|
@@ -257,15 +257,15 @@ declare global {
|
|
|
257
257
|
* @param url - url of the game object or component
|
|
258
258
|
* @param property - optional id of the property to cancel
|
|
259
259
|
* @example
|
|
260
|
-
* ```
|
|
261
|
-
* Cancel the animation of the position of a game object:
|
|
262
|
-
* go.cancel_animations(go.get_id(), "position")
|
|
260
|
+
* ```ts
|
|
261
|
+
* // Cancel the animation of the position of a game object:
|
|
262
|
+
* go.cancel_animations(go.get_id(), "position");
|
|
263
263
|
*
|
|
264
|
-
* Cancel all property animations of the current game object:
|
|
265
|
-
* go.cancel_animations(".")
|
|
264
|
+
* // Cancel all property animations of the current game object:
|
|
265
|
+
* go.cancel_animations(".");
|
|
266
266
|
*
|
|
267
|
-
* Cancel all property animations of the sprite component of the current game object:
|
|
268
|
-
* go.cancel_animations("#sprite")
|
|
267
|
+
* // Cancel all property animations of the sprite component of the current game object:
|
|
268
|
+
* go.cancel_animations("#sprite");
|
|
269
269
|
* ```
|
|
270
270
|
*/
|
|
271
271
|
export function cancel_animations(url: string | Hash | Url, property?: string | Hash): void;
|
|
@@ -280,26 +280,27 @@ declare global {
|
|
|
280
280
|
* @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
|
|
281
281
|
* @param recursive - optional boolean, set to true to recursively delete child hiearchy in child to parent order
|
|
282
282
|
* @example
|
|
283
|
-
* ```
|
|
284
|
-
* This example demonstrates how to delete game objects
|
|
285
|
-
*
|
|
286
|
-
* go.delete()
|
|
287
|
-
*
|
|
288
|
-
*
|
|
289
|
-
* go.delete(id)
|
|
290
|
-
*
|
|
291
|
-
*
|
|
292
|
-
* go.delete(ids)
|
|
293
|
-
*
|
|
294
|
-
* This example demonstrates how to delete
|
|
295
|
-
*
|
|
296
|
-
*
|
|
297
|
-
*
|
|
298
|
-
*
|
|
299
|
-
* go.
|
|
300
|
-
*
|
|
301
|
-
*
|
|
302
|
-
*
|
|
283
|
+
* ```ts
|
|
284
|
+
* // This example demonstrates how to delete game objects:
|
|
285
|
+
* // Delete the script's own game object.
|
|
286
|
+
* go.delete();
|
|
287
|
+
* // Delete a game object with the id "my_game_object".
|
|
288
|
+
* const id = go.get_id("my_game_object");
|
|
289
|
+
* go.delete(id);
|
|
290
|
+
* // Delete a list of game objects.
|
|
291
|
+
* const ids = [hash("/my_object_1"), hash("/my_object_2"), hash("/my_object_3")];
|
|
292
|
+
* go.delete(ids);
|
|
293
|
+
*
|
|
294
|
+
* // This example demonstrates how to delete game objects and their children
|
|
295
|
+
* // (child-to-parent order):
|
|
296
|
+
* // Delete the script's own game object and its children.
|
|
297
|
+
* go.delete(true);
|
|
298
|
+
* // Delete a game object with the id "my_game_object" and its children.
|
|
299
|
+
* const id2 = go.get_id("my_game_object");
|
|
300
|
+
* go.delete(id2, true);
|
|
301
|
+
* // Delete a list of game objects and their children.
|
|
302
|
+
* const ids2 = [hash("/my_object_1"), hash("/my_object_2"), hash("/my_object_3")];
|
|
303
|
+
* go.delete(ids2, true);
|
|
303
304
|
* ```
|
|
304
305
|
*/
|
|
305
306
|
function _delete(id?: string | Hash | Url | (string | Hash | Url)[], recursive?: boolean): void;
|
|
@@ -310,12 +311,12 @@ declare global {
|
|
|
310
311
|
* @param url - url of the game object to check
|
|
311
312
|
* @returns true if the game object exists
|
|
312
313
|
* @example
|
|
313
|
-
* ```
|
|
314
|
-
* Check if game object "my_game_object" exists in the current collection
|
|
315
|
-
* go.exists("/my_game_object")
|
|
314
|
+
* ```ts
|
|
315
|
+
* // Check if game object "my_game_object" exists in the current collection:
|
|
316
|
+
* go.exists("/my_game_object");
|
|
316
317
|
*
|
|
317
|
-
* Check if game object exists in another collection
|
|
318
|
-
* go.exists("other_collection:/my_game_object")
|
|
318
|
+
* // Check if game object exists in another collection:
|
|
319
|
+
* go.exists("other_collection:/my_game_object");
|
|
319
320
|
* ```
|
|
320
321
|
*/
|
|
321
322
|
export function exists(url: string | Hash | Url): boolean;
|
|
@@ -326,11 +327,13 @@ declare global {
|
|
|
326
327
|
*
|
|
327
328
|
* @param self - reference to the script state to be used for storing data
|
|
328
329
|
* @example
|
|
329
|
-
* ```
|
|
330
|
-
*
|
|
331
|
-
*
|
|
332
|
-
*
|
|
333
|
-
*
|
|
330
|
+
* ```ts
|
|
331
|
+
* export default defineScript({
|
|
332
|
+
* final(self) {
|
|
333
|
+
* // report finalization
|
|
334
|
+
* msg.post("my_friend_instance", "im_dead", { my_stats: self.some_value });
|
|
335
|
+
* },
|
|
336
|
+
* });
|
|
334
337
|
* ```
|
|
335
338
|
*/
|
|
336
339
|
export function final(self: Opaque<"userdata">): void;
|
|
@@ -353,16 +356,17 @@ declare global {
|
|
|
353
356
|
* @param path - path of the instance for which to return the id
|
|
354
357
|
* @returns instance id
|
|
355
358
|
* @example
|
|
356
|
-
* ```
|
|
357
|
-
* For the instance with path /my_sub_collection/my_instance, the following calls
|
|
358
|
-
*
|
|
359
|
-
*
|
|
359
|
+
* ```ts
|
|
360
|
+
* // For the instance with path /my_sub_collection/my_instance, the following calls
|
|
361
|
+
* // are equivalent:
|
|
362
|
+
* const id = go.get_id(); // no path, defaults to the instance containing the calling script
|
|
363
|
+
* print(id); // => hash: [/my_sub_collection/my_instance]
|
|
360
364
|
*
|
|
361
|
-
*
|
|
362
|
-
* print(
|
|
365
|
+
* const id2 = go.get_id("/my_sub_collection/my_instance"); // absolute path
|
|
366
|
+
* print(id2); // => hash: [/my_sub_collection/my_instance]
|
|
363
367
|
*
|
|
364
|
-
*
|
|
365
|
-
* print(
|
|
368
|
+
* const id3 = go.get_id("my_instance"); // relative path
|
|
369
|
+
* print(id3); // => hash: [/my_sub_collection/my_instance]
|
|
366
370
|
* ```
|
|
367
371
|
*/
|
|
368
372
|
export function get_id(path?: string): Hash;
|
|
@@ -372,12 +376,12 @@ declare global {
|
|
|
372
376
|
* @param id - optional id of the game object instance to get parent for, defaults to the instance containing the calling script
|
|
373
377
|
* @returns parent instance or `nil`
|
|
374
378
|
* @example
|
|
375
|
-
* ```
|
|
376
|
-
* Get parent of the instance containing the calling script:
|
|
377
|
-
*
|
|
379
|
+
* ```ts
|
|
380
|
+
* // Get parent of the instance containing the calling script:
|
|
381
|
+
* const parent_id = go.get_parent();
|
|
378
382
|
*
|
|
379
|
-
* Get parent of the instance with id "x":
|
|
380
|
-
*
|
|
383
|
+
* // Get parent of the instance with id "x":
|
|
384
|
+
* const parent_id2 = go.get_parent("x");
|
|
381
385
|
* ```
|
|
382
386
|
*/
|
|
383
387
|
export function get_parent(id?: string | Hash | Url): Hash | unknown;
|
|
@@ -387,12 +391,12 @@ declare global {
|
|
|
387
391
|
* @param id - optional id of the game object instance to get the position for, by default the instance of the calling script
|
|
388
392
|
* @returns instance position
|
|
389
393
|
* @example
|
|
390
|
-
* ```
|
|
391
|
-
* Get the position of the game object
|
|
392
|
-
*
|
|
394
|
+
* ```ts
|
|
395
|
+
* // Get the position of the game object the script is attached to:
|
|
396
|
+
* const p = go.get_position();
|
|
393
397
|
*
|
|
394
|
-
* Get the position of another game object
|
|
395
|
-
*
|
|
398
|
+
* // Get the position of another game object "my_gameobject":
|
|
399
|
+
* const pos = go.get_position("my_gameobject");
|
|
396
400
|
* ```
|
|
397
401
|
*/
|
|
398
402
|
export function get_position(id?: string | Hash | Url): Vector3;
|
|
@@ -402,12 +406,12 @@ declare global {
|
|
|
402
406
|
* @param id - optional id of the game object instance to get the rotation for, by default the instance of the calling script
|
|
403
407
|
* @returns instance rotation
|
|
404
408
|
* @example
|
|
405
|
-
* ```
|
|
406
|
-
* Get the rotation of the game object
|
|
407
|
-
*
|
|
409
|
+
* ```ts
|
|
410
|
+
* // Get the rotation of the game object the script is attached to:
|
|
411
|
+
* const r = go.get_rotation();
|
|
408
412
|
*
|
|
409
|
-
* Get the rotation of another game object
|
|
410
|
-
*
|
|
413
|
+
* // Get the rotation of another game object with id "x":
|
|
414
|
+
* const r2 = go.get_rotation("x");
|
|
411
415
|
* ```
|
|
412
416
|
*/
|
|
413
417
|
export function get_rotation(id?: string | Hash | Url): Quaternion;
|
|
@@ -417,12 +421,12 @@ declare global {
|
|
|
417
421
|
* @param id - optional id of the game object instance to get the scale for, by default the instance of the calling script
|
|
418
422
|
* @returns instance scale factor
|
|
419
423
|
* @example
|
|
420
|
-
* ```
|
|
421
|
-
* Get the scale of the game object
|
|
422
|
-
*
|
|
424
|
+
* ```ts
|
|
425
|
+
* // Get the scale of the game object the script is attached to:
|
|
426
|
+
* const s = go.get_scale();
|
|
423
427
|
*
|
|
424
|
-
* Get the scale of another game object
|
|
425
|
-
*
|
|
428
|
+
* // Get the scale of another game object with id "x":
|
|
429
|
+
* const s2 = go.get_scale("x");
|
|
426
430
|
* ```
|
|
427
431
|
*/
|
|
428
432
|
export function get_scale(id?: string | Hash | Url): Vector3;
|
|
@@ -432,12 +436,12 @@ declare global {
|
|
|
432
436
|
* @param id - optional id of the game object instance to get the uniform scale for, by default the instance of the calling script
|
|
433
437
|
* @returns uniform instance scale factor
|
|
434
438
|
* @example
|
|
435
|
-
* ```
|
|
436
|
-
* Get the scale of the game object
|
|
437
|
-
*
|
|
439
|
+
* ```ts
|
|
440
|
+
* // Get the uniform scale of the game object the script is attached to:
|
|
441
|
+
* const s = go.get_scale_uniform();
|
|
438
442
|
*
|
|
439
|
-
* Get the uniform scale of another game object
|
|
440
|
-
*
|
|
443
|
+
* // Get the uniform scale of another game object with id "x":
|
|
444
|
+
* const s2 = go.get_scale_uniform("x");
|
|
441
445
|
* ```
|
|
442
446
|
*/
|
|
443
447
|
export function get_scale_uniform(id?: string | Hash | Url): number;
|
|
@@ -449,12 +453,12 @@ declare global {
|
|
|
449
453
|
* @param id - optional id of the game object instance to get the world position for, by default the instance of the calling script
|
|
450
454
|
* @returns instance world position
|
|
451
455
|
* @example
|
|
452
|
-
* ```
|
|
453
|
-
* Get the world position of the game object
|
|
454
|
-
*
|
|
456
|
+
* ```ts
|
|
457
|
+
* // Get the world position of the game object the script is attached to:
|
|
458
|
+
* const p = go.get_world_position();
|
|
455
459
|
*
|
|
456
|
-
* Get the world position of another game object
|
|
457
|
-
*
|
|
460
|
+
* // Get the world position of another game object with id "x":
|
|
461
|
+
* const p2 = go.get_world_position("x");
|
|
458
462
|
* ```
|
|
459
463
|
*/
|
|
460
464
|
export function get_world_position(id?: string | Hash | Url): Vector3;
|
|
@@ -466,12 +470,12 @@ declare global {
|
|
|
466
470
|
* @param id - optional id of the game object instance to get the world rotation for, by default the instance of the calling script
|
|
467
471
|
* @returns instance world rotation
|
|
468
472
|
* @example
|
|
469
|
-
* ```
|
|
470
|
-
* Get the world rotation of the game object
|
|
471
|
-
*
|
|
473
|
+
* ```ts
|
|
474
|
+
* // Get the world rotation of the game object the script is attached to:
|
|
475
|
+
* const r = go.get_world_rotation();
|
|
472
476
|
*
|
|
473
|
-
* Get the world rotation of another game object
|
|
474
|
-
*
|
|
477
|
+
* // Get the world rotation of another game object with id "x":
|
|
478
|
+
* const r2 = go.get_world_rotation("x");
|
|
475
479
|
* ```
|
|
476
480
|
*/
|
|
477
481
|
export function get_world_rotation(id?: string | Hash | Url): Quaternion;
|
|
@@ -485,12 +489,12 @@ declare global {
|
|
|
485
489
|
* @param id - optional id of the game object instance to get the world scale for, by default the instance of the calling script
|
|
486
490
|
* @returns instance world 3D scale factor
|
|
487
491
|
* @example
|
|
488
|
-
* ```
|
|
489
|
-
* Get the world 3D scale of the game object
|
|
490
|
-
*
|
|
492
|
+
* ```ts
|
|
493
|
+
* // Get the world 3D scale of the game object the script is attached to:
|
|
494
|
+
* const s = go.get_world_scale();
|
|
491
495
|
*
|
|
492
|
-
* Get the world scale of another game object
|
|
493
|
-
*
|
|
496
|
+
* // Get the world scale of another game object "x":
|
|
497
|
+
* const s2 = go.get_world_scale("x");
|
|
494
498
|
* ```
|
|
495
499
|
*/
|
|
496
500
|
export function get_world_scale(id?: string | Hash | Url): Vector3;
|
|
@@ -502,12 +506,12 @@ declare global {
|
|
|
502
506
|
* @param id - optional id of the game object instance to get the world scale for, by default the instance of the calling script
|
|
503
507
|
* @returns instance world scale factor
|
|
504
508
|
* @example
|
|
505
|
-
* ```
|
|
506
|
-
* Get the world scale of the game object
|
|
507
|
-
*
|
|
509
|
+
* ```ts
|
|
510
|
+
* // Get the world uniform scale of the game object the script is attached to:
|
|
511
|
+
* const s = go.get_world_scale_uniform();
|
|
508
512
|
*
|
|
509
|
-
* Get the world scale of another game object
|
|
510
|
-
*
|
|
513
|
+
* // Get the world uniform scale of another game object with id "x":
|
|
514
|
+
* const s2 = go.get_world_scale_uniform("x");
|
|
511
515
|
* ```
|
|
512
516
|
*/
|
|
513
517
|
export function get_world_scale_uniform(id?: string | Hash | Url): number;
|
|
@@ -518,12 +522,12 @@ declare global {
|
|
|
518
522
|
* @param id - optional id of the game object instance to get the world transform for, by default the instance of the calling script
|
|
519
523
|
* @returns instance world transform
|
|
520
524
|
* @example
|
|
521
|
-
* ```
|
|
522
|
-
* Get the world transform of the game object
|
|
523
|
-
*
|
|
525
|
+
* ```ts
|
|
526
|
+
* // Get the world transform of the game object the script is attached to:
|
|
527
|
+
* const m = go.get_world_transform();
|
|
524
528
|
*
|
|
525
|
-
* Get the world transform of another game object
|
|
526
|
-
*
|
|
529
|
+
* // Get the world transform of another game object with id "x":
|
|
530
|
+
* const m2 = go.get_world_transform("x");
|
|
527
531
|
* ```
|
|
528
532
|
*/
|
|
529
533
|
export function get_world_transform(id?: string | Hash | Url): Matrix4;
|
|
@@ -533,11 +537,13 @@ declare global {
|
|
|
533
537
|
*
|
|
534
538
|
* @param self - reference to the script state to be used for storing data
|
|
535
539
|
* @example
|
|
536
|
-
* ```
|
|
537
|
-
*
|
|
538
|
-
*
|
|
539
|
-
*
|
|
540
|
-
*
|
|
540
|
+
* ```ts
|
|
541
|
+
* export default defineScript({
|
|
542
|
+
* init() {
|
|
543
|
+
* // set up useful data
|
|
544
|
+
* return { my_value: 1 };
|
|
545
|
+
* },
|
|
546
|
+
* });
|
|
541
547
|
* ```
|
|
542
548
|
*/
|
|
543
549
|
export function init(self: Opaque<"userdata">): void;
|
|
@@ -649,32 +655,38 @@ declare global {
|
|
|
649
655
|
* @param action - a table containing the input data, see above for a description
|
|
650
656
|
* @returns optional boolean to signal if the input should be consumed (not passed on to others) or not, default is false
|
|
651
657
|
* @example
|
|
652
|
-
* ```
|
|
653
|
-
* This example demonstrates how a game object instance can be moved as a response to user input.
|
|
654
|
-
*
|
|
655
|
-
*
|
|
656
|
-
*
|
|
657
|
-
*
|
|
658
|
-
*
|
|
659
|
-
*
|
|
660
|
-
*
|
|
661
|
-
*
|
|
662
|
-
*
|
|
663
|
-
*
|
|
664
|
-
*
|
|
665
|
-
*
|
|
666
|
-
*
|
|
667
|
-
*
|
|
668
|
-
*
|
|
669
|
-
*
|
|
670
|
-
*
|
|
671
|
-
*
|
|
672
|
-
*
|
|
673
|
-
*
|
|
674
|
-
*
|
|
675
|
-
*
|
|
676
|
-
*
|
|
677
|
-
*
|
|
658
|
+
* ```ts
|
|
659
|
+
* // This example demonstrates how a game object instance can be moved as a response to user input.
|
|
660
|
+
* export default defineScript({
|
|
661
|
+
* init() {
|
|
662
|
+
* // acquire input focus
|
|
663
|
+
* msg.post(".", "acquire_input_focus");
|
|
664
|
+
* return {
|
|
665
|
+
* // maximum speed the instance can be moved
|
|
666
|
+
* max_speed: 2,
|
|
667
|
+
* // velocity of the instance, initially zero
|
|
668
|
+
* velocity: vmath.vector3(),
|
|
669
|
+
* };
|
|
670
|
+
* },
|
|
671
|
+
*
|
|
672
|
+
* update(self, dt) {
|
|
673
|
+
* // move the instance
|
|
674
|
+
* go.set_position(go.get_position().add(self.velocity.mul(dt)));
|
|
675
|
+
* },
|
|
676
|
+
*
|
|
677
|
+
* on_input(self, action_id, action) {
|
|
678
|
+
* // check for movement input
|
|
679
|
+
* if (action_id === hash("right")) {
|
|
680
|
+
* if (action.released) {
|
|
681
|
+
* // reset velocity if input was released
|
|
682
|
+
* self.velocity = vmath.vector3();
|
|
683
|
+
* } else {
|
|
684
|
+
* // update velocity
|
|
685
|
+
* self.velocity = vmath.vector3(action.value * self.max_speed, 0, 0);
|
|
686
|
+
* }
|
|
687
|
+
* }
|
|
688
|
+
* },
|
|
689
|
+
* });
|
|
678
690
|
* ```
|
|
679
691
|
*/
|
|
680
692
|
export function on_input(self: Opaque<"userdata">, action_id: Hash, action: Record<string | number, unknown>): boolean | unknown;
|
|
@@ -689,29 +701,34 @@ declare global {
|
|
|
689
701
|
* @param message - a table containing the message data
|
|
690
702
|
* @param sender - address of the sender
|
|
691
703
|
* @example
|
|
692
|
-
* ```
|
|
693
|
-
* This example demonstrates how a game object instance, called "a", can communicate with another instance, called "b". It
|
|
694
|
-
* is assumed that both script components of the instances has id "script".
|
|
695
|
-
*
|
|
696
|
-
*
|
|
697
|
-
*
|
|
698
|
-
*
|
|
699
|
-
*
|
|
700
|
-
*
|
|
701
|
-
*
|
|
702
|
-
*
|
|
703
|
-
*
|
|
704
|
-
*
|
|
705
|
-
*
|
|
706
|
-
*
|
|
707
|
-
*
|
|
708
|
-
*
|
|
709
|
-
*
|
|
710
|
-
*
|
|
711
|
-
*
|
|
712
|
-
*
|
|
713
|
-
*
|
|
714
|
-
*
|
|
704
|
+
* ```ts
|
|
705
|
+
* // This example demonstrates how a game object instance, called "a", can communicate with another instance, called "b". It
|
|
706
|
+
* // is assumed that both script components of the instances has id "script".
|
|
707
|
+
*
|
|
708
|
+
* // a.script — Script of instance "a":
|
|
709
|
+
* export default defineScript({
|
|
710
|
+
* init() {
|
|
711
|
+
* // let b know about some important data
|
|
712
|
+
* msg.post("b#script", "my_data", { important_value: 1 });
|
|
713
|
+
* },
|
|
714
|
+
* });
|
|
715
|
+
*
|
|
716
|
+
* // b.script — Script of instance "b":
|
|
717
|
+
* export default defineScript({
|
|
718
|
+
* init() {
|
|
719
|
+
* // store the url of instance "a" for later use, by specifying undefined as socket we
|
|
720
|
+
* // automatically use our own socket
|
|
721
|
+
* return { a_url: msg.url(undefined, go.get_id("a"), "script") };
|
|
722
|
+
* },
|
|
723
|
+
*
|
|
724
|
+
* on_message(self, message_id, message, sender) {
|
|
725
|
+
* // check message and sender
|
|
726
|
+
* if (message_id === hash("my_data") && sender === self.a_url) {
|
|
727
|
+
* // use the data in some way
|
|
728
|
+
* self.important_value = message.important_value;
|
|
729
|
+
* }
|
|
730
|
+
* },
|
|
731
|
+
* });
|
|
715
732
|
* ```
|
|
716
733
|
*/
|
|
717
734
|
export function on_message(self: Opaque<"userdata">, message_id: Hash, message: Record<string | number, unknown>, sender: Url): void;
|
|
@@ -721,67 +738,46 @@ declare global {
|
|
|
721
738
|
*
|
|
722
739
|
* @param self - reference to the script state to be used for storing data
|
|
723
740
|
* @example
|
|
724
|
-
* ```
|
|
725
|
-
* This example demonstrates how to tweak the speed of a game object instance that is moved on user input.
|
|
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
|
-
*
|
|
741
|
+
* ```ts
|
|
742
|
+
* // This example demonstrates how to tweak the speed of a game object instance that is moved on user input.
|
|
743
|
+
* export default defineScript({
|
|
744
|
+
* init() {
|
|
745
|
+
* // acquire input focus
|
|
746
|
+
* msg.post(".", "acquire_input_focus");
|
|
747
|
+
* return {
|
|
748
|
+
* // maximum speed the instance can be moved, this value is tweaked in the on_reload function below
|
|
749
|
+
* max_speed: 2,
|
|
750
|
+
* // velocity of the instance, initially zero
|
|
751
|
+
* velocity: vmath.vector3(),
|
|
752
|
+
* };
|
|
753
|
+
* },
|
|
754
|
+
*
|
|
755
|
+
* update(self, dt) {
|
|
756
|
+
* // move the instance
|
|
757
|
+
* go.set_position(go.get_position().add(self.velocity.mul(dt)));
|
|
758
|
+
* },
|
|
759
|
+
*
|
|
760
|
+
* on_input(self, action_id, action) {
|
|
761
|
+
* // check for movement input
|
|
762
|
+
* if (action_id === hash("right")) {
|
|
763
|
+
* if (action.released) {
|
|
764
|
+
* // reset velocity if input was released
|
|
765
|
+
* self.velocity = vmath.vector3();
|
|
766
|
+
* } else {
|
|
767
|
+
* // update velocity
|
|
768
|
+
* self.velocity = vmath.vector3(action.value * self.max_speed, 0, 0);
|
|
769
|
+
* }
|
|
770
|
+
* }
|
|
771
|
+
* },
|
|
772
|
+
*
|
|
773
|
+
* on_reload(self) {
|
|
774
|
+
* // edit this value and reload the script component
|
|
775
|
+
* self.max_speed = 100;
|
|
776
|
+
* },
|
|
777
|
+
* });
|
|
755
778
|
* ```
|
|
756
779
|
*/
|
|
757
780
|
export function on_reload(self: Opaque<"userdata">): void;
|
|
758
|
-
/**
|
|
759
|
-
* This function defines a property which can then be used in the script through the self-reference.
|
|
760
|
-
* The properties defined this way are automatically exposed in the editor in game objects and collections which use the script.
|
|
761
|
-
* Note that you can only use this function outside any callback-functions like init and update.
|
|
762
|
-
*
|
|
763
|
-
* @param name - the id of the property
|
|
764
|
-
* @param value - default value of the property. In the case of a url, only the empty constructor msg.url() is allowed. In the case of a resource one of the resource constructors (eg resource.atlas(), resource.font() etc) is expected.
|
|
765
|
-
* @example
|
|
766
|
-
* ```lua
|
|
767
|
-
* This example demonstrates how to define a property called "health" in a script.
|
|
768
|
-
* The health is decreased whenever someone sends a message called "take_damage" to the script.
|
|
769
|
-
* go.property("health", 100)
|
|
770
|
-
*
|
|
771
|
-
* function init(self)
|
|
772
|
-
* -- prints 100 to the output
|
|
773
|
-
* print(self.health)
|
|
774
|
-
* end
|
|
775
|
-
*
|
|
776
|
-
* function on_message(self, message_id, message, sender)
|
|
777
|
-
* if message_id == hash("take_damage") then
|
|
778
|
-
* self.health = self.health - message.damage
|
|
779
|
-
* print("Ouch! My health is now: " .. self.health)
|
|
780
|
-
* end
|
|
781
|
-
* end
|
|
782
|
-
* ```
|
|
783
|
-
*/
|
|
784
|
-
export function property(name: string, value: number | Hash | Url | Vector3 | Vector4 | Quaternion | Opaque<"resource"> | boolean): void;
|
|
785
781
|
/**
|
|
786
782
|
* Sets the parent for a game object instance. This means that the instance will exist in the geometrical space of its parent,
|
|
787
783
|
* 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
|
|
@@ -794,15 +790,15 @@ declare global {
|
|
|
794
790
|
* @param parent_id - optional id of the new parent game object, defaults to detaching game object from its parent
|
|
795
791
|
* @param keep_world_transform - optional boolean, set to true to maintain the world transform when changing spaces. Defaults to false.
|
|
796
792
|
* @example
|
|
797
|
-
* ```
|
|
798
|
-
* Attach myself to another instance "my_parent":
|
|
799
|
-
* go.set_parent(go.get_id(),go.get_id("my_parent"))
|
|
793
|
+
* ```ts
|
|
794
|
+
* // Attach myself to another instance "my_parent":
|
|
795
|
+
* go.set_parent(go.get_id(), go.get_id("my_parent"));
|
|
800
796
|
*
|
|
801
|
-
* Attach an instance "my_instance" to another instance "my_parent":
|
|
802
|
-
* go.set_parent(go.get_id("my_instance"),go.get_id("my_parent"))
|
|
797
|
+
* // Attach an instance "my_instance" to another instance "my_parent":
|
|
798
|
+
* go.set_parent(go.get_id("my_instance"), go.get_id("my_parent"));
|
|
803
799
|
*
|
|
804
|
-
* Detach an instance "my_instance" from its parent (if any):
|
|
805
|
-
* go.set_parent(go.get_id("my_instance"))
|
|
800
|
+
* // Detach an instance "my_instance" from its parent (if any):
|
|
801
|
+
* go.set_parent(go.get_id("my_instance"));
|
|
806
802
|
* ```
|
|
807
803
|
*/
|
|
808
804
|
export function set_parent(id?: string | Hash | Url, parent_id?: string | Hash | Url, keep_world_transform?: boolean): void;
|
|
@@ -812,14 +808,15 @@ declare global {
|
|
|
812
808
|
* @param position - position to set
|
|
813
809
|
* @param id - optional id of the game object instance to set the position for, by default the instance of the calling script
|
|
814
810
|
* @example
|
|
815
|
-
* ```
|
|
816
|
-
*
|
|
817
|
-
*
|
|
818
|
-
*
|
|
819
|
-
*
|
|
820
|
-
*
|
|
821
|
-
*
|
|
822
|
-
*
|
|
811
|
+
* ```ts
|
|
812
|
+
* // `p` is the desired position (a Vector3).
|
|
813
|
+
* const p = vmath.vector3();
|
|
814
|
+
*
|
|
815
|
+
* // Set the position of the game object the script is attached to:
|
|
816
|
+
* go.set_position(p);
|
|
817
|
+
*
|
|
818
|
+
* // Set the position of another game object with id "x":
|
|
819
|
+
* go.set_position(p, "x");
|
|
823
820
|
* ```
|
|
824
821
|
*/
|
|
825
822
|
export function set_position(position: Vector3, id?: string | Hash | Url): void;
|
|
@@ -829,14 +826,15 @@ declare global {
|
|
|
829
826
|
* @param rotation - rotation to set
|
|
830
827
|
* @param id - optional id of the game object instance to get the rotation for, by default the instance of the calling script
|
|
831
828
|
* @example
|
|
832
|
-
* ```
|
|
833
|
-
*
|
|
834
|
-
*
|
|
835
|
-
*
|
|
836
|
-
*
|
|
837
|
-
*
|
|
838
|
-
*
|
|
839
|
-
*
|
|
829
|
+
* ```ts
|
|
830
|
+
* // `r` is the desired rotation (a Quaternion).
|
|
831
|
+
* const r = vmath.quat();
|
|
832
|
+
*
|
|
833
|
+
* // Set the rotation of the game object the script is attached to:
|
|
834
|
+
* go.set_rotation(r);
|
|
835
|
+
*
|
|
836
|
+
* // Set the rotation of another game object with id "x":
|
|
837
|
+
* go.set_rotation(r, "x");
|
|
840
838
|
* ```
|
|
841
839
|
*/
|
|
842
840
|
export function set_rotation(rotation: Quaternion, id?: string | Hash | Url): void;
|
|
@@ -847,14 +845,14 @@ declare global {
|
|
|
847
845
|
* @param scale - vector or uniform scale factor, must be greater than 0
|
|
848
846
|
* @param id - optional id of the game object instance to get the scale for, by default the instance of the calling script
|
|
849
847
|
* @example
|
|
850
|
-
* ```
|
|
851
|
-
* Set the scale of the game object
|
|
852
|
-
*
|
|
853
|
-
* go.set_scale(s)
|
|
854
|
-
*
|
|
855
|
-
* Set the scale of another game object
|
|
856
|
-
*
|
|
857
|
-
* go.set_scale(
|
|
848
|
+
* ```ts
|
|
849
|
+
* // Set the scale of the game object the script is attached to:
|
|
850
|
+
* const s = vmath.vector3(2.0, 1.0, 1.0);
|
|
851
|
+
* go.set_scale(s);
|
|
852
|
+
*
|
|
853
|
+
* // Set the scale of another game object with id "obj_id":
|
|
854
|
+
* const s2 = 1.2;
|
|
855
|
+
* go.set_scale(s2, "obj_id");
|
|
858
856
|
* ```
|
|
859
857
|
*/
|
|
860
858
|
export function set_scale(scale: number | Vector3, id?: string | Hash | Url): void;
|
|
@@ -865,14 +863,14 @@ declare global {
|
|
|
865
863
|
* @param scale - vector or uniform scale factor, must be greater than 0
|
|
866
864
|
* @param id - optional id of the game object instance to get the scale for, by default the instance of the calling script
|
|
867
865
|
* @example
|
|
868
|
-
* ```
|
|
869
|
-
* Set the scale of the game object
|
|
870
|
-
*
|
|
871
|
-
* go.set_scale_xy(s)
|
|
872
|
-
*
|
|
873
|
-
* Set the scale of another game object
|
|
874
|
-
*
|
|
875
|
-
* go.set_scale_xy(
|
|
866
|
+
* ```ts
|
|
867
|
+
* // Set the scale of the game object the script is attached to:
|
|
868
|
+
* const s = vmath.vector3(2.0, 1.0, 5.0);
|
|
869
|
+
* go.set_scale_xy(s); // z will not be set here, only x and y
|
|
870
|
+
*
|
|
871
|
+
* // Set the scale of another game object with id "obj_id":
|
|
872
|
+
* const s2 = 1.2;
|
|
873
|
+
* go.set_scale_xy(s2, "obj_id"); // z will not be set here, only x and y
|
|
876
874
|
* ```
|
|
877
875
|
*/
|
|
878
876
|
export function set_scale_xy(scale: number | Vector3, id?: string | Hash | Url): void;
|
|
@@ -883,17 +881,19 @@ declare global {
|
|
|
883
881
|
* @param self - reference to the script state to be used for storing data
|
|
884
882
|
* @param dt - the time-step of the frame update
|
|
885
883
|
* @example
|
|
886
|
-
* ```
|
|
887
|
-
* This example demonstrates how to move a game object instance through the script component:
|
|
888
|
-
*
|
|
889
|
-
*
|
|
890
|
-
*
|
|
891
|
-
*
|
|
892
|
-
*
|
|
893
|
-
*
|
|
894
|
-
*
|
|
895
|
-
*
|
|
896
|
-
*
|
|
884
|
+
* ```ts
|
|
885
|
+
* // This example demonstrates how to move a game object instance through the script component:
|
|
886
|
+
* export default defineScript({
|
|
887
|
+
* init() {
|
|
888
|
+
* // set initial velocity to be 1 along world x-axis
|
|
889
|
+
* return { my_velocity: vmath.vector3(1, 0, 0) };
|
|
890
|
+
* },
|
|
891
|
+
*
|
|
892
|
+
* update(self, dt) {
|
|
893
|
+
* // move the game object instance
|
|
894
|
+
* go.set_position(go.get_position().add(self.my_velocity.mul(dt)));
|
|
895
|
+
* },
|
|
896
|
+
* });
|
|
897
897
|
* ```
|
|
898
898
|
*/
|
|
899
899
|
export function update(self: Opaque<"userdata">, dt: number): void;
|
|
@@ -908,12 +908,12 @@ declare global {
|
|
|
908
908
|
*
|
|
909
909
|
* @param id - optional id of the game object instance to update
|
|
910
910
|
* @example
|
|
911
|
-
* ```
|
|
912
|
-
* Update this game object's world transform:
|
|
913
|
-
* go.update_world_transform()
|
|
911
|
+
* ```ts
|
|
912
|
+
* // Update this game object's world transform:
|
|
913
|
+
* go.update_world_transform();
|
|
914
914
|
*
|
|
915
|
-
* Update another game object's world transform:
|
|
916
|
-
* go.update_world_transform("/other")
|
|
915
|
+
* // Update another game object's world transform:
|
|
916
|
+
* go.update_world_transform("/other");
|
|
917
917
|
* ```
|
|
918
918
|
*/
|
|
919
919
|
export function update_world_transform(id?: string | Hash | Url): void;
|
|
@@ -924,11 +924,11 @@ declare global {
|
|
|
924
924
|
* @param url - url of the game object which coordinate system convert to
|
|
925
925
|
* @returns converted position
|
|
926
926
|
* @example
|
|
927
|
-
* ```
|
|
928
|
-
* Convert position of "test" game object into coordinate space of "child" object.
|
|
929
|
-
*
|
|
930
|
-
*
|
|
931
|
-
*
|
|
927
|
+
* ```ts
|
|
928
|
+
* // Convert position of "test" game object into coordinate space of "child" object.
|
|
929
|
+
* const test_pos = go.get_world_position("/test");
|
|
930
|
+
* const child_pos = go.get_world_position("/child");
|
|
931
|
+
* const new_position = go.world_to_local_position(test_pos, "/child");
|
|
932
932
|
* ```
|
|
933
933
|
*/
|
|
934
934
|
export function world_to_local_position(position: Vector3, url: string | Hash | Url): Vector3;
|
|
@@ -939,11 +939,11 @@ declare global {
|
|
|
939
939
|
* @param url - url of the game object which coordinate system convert to
|
|
940
940
|
* @returns converted transformation
|
|
941
941
|
* @example
|
|
942
|
-
* ```
|
|
943
|
-
* Convert
|
|
944
|
-
*
|
|
945
|
-
*
|
|
946
|
-
*
|
|
942
|
+
* ```ts
|
|
943
|
+
* // Convert transform of "test" game object into coordinate space of "child" object.
|
|
944
|
+
* const test_transform = go.get_world_transform("/test");
|
|
945
|
+
* const child_transform = go.get_world_transform("/child");
|
|
946
|
+
* const result_transform = go.world_to_local_transform(test_transform, "/child");
|
|
947
947
|
* ```
|
|
948
948
|
*/
|
|
949
949
|
export function world_to_local_transform(transformation: Matrix4, url: string | Hash | Url): Matrix4;
|