@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.
Files changed (59) hide show
  1. package/api-targets.json +1 -1
  2. package/generated/b2d.d.ts +3 -0
  3. package/generated/buffer.d.ts +44 -38
  4. package/generated/builtin-messages.d.ts +1 -1
  5. package/generated/camera.d.ts +3 -0
  6. package/generated/collectionfactory.d.ts +47 -40
  7. package/generated/collectionproxy.d.ts +23 -18
  8. package/generated/crash.d.ts +3 -0
  9. package/generated/factory.d.ts +32 -24
  10. package/generated/go.d.ts +293 -293
  11. package/generated/graphics.d.ts +3 -0
  12. package/generated/gui.d.ts +303 -283
  13. package/generated/http.d.ts +26 -16
  14. package/generated/iac.d.ts +3 -0
  15. package/generated/iap.d.ts +6 -3
  16. package/generated/image.d.ts +30 -26
  17. package/generated/json.d.ts +36 -32
  18. package/generated/kinds/gui-script.d.ts +7 -5
  19. package/generated/kinds/render-script.d.ts +7 -5
  20. package/generated/kinds/script.d.ts +7 -5
  21. package/generated/label.d.ts +16 -9
  22. package/generated/liveupdate.d.ts +29 -26
  23. package/generated/model.d.ts +57 -45
  24. package/generated/msg.d.ts +12 -9
  25. package/generated/particlefx.d.ts +50 -34
  26. package/generated/physics.d.ts +153 -133
  27. package/generated/profiler.d.ts +45 -41
  28. package/generated/push.d.ts +5 -2
  29. package/generated/render.d.ts +410 -349
  30. package/generated/resource.d.ts +619 -572
  31. package/generated/socket.d.ts +49 -33
  32. package/generated/sound.d.ts +83 -72
  33. package/generated/sprite.d.ts +36 -32
  34. package/generated/sys.d.ts +198 -189
  35. package/generated/tilemap.d.ts +43 -39
  36. package/generated/timer.d.ts +42 -36
  37. package/generated/vmath.d.ts +254 -229
  38. package/generated/webview.d.ts +3 -0
  39. package/generated/window.d.ts +23 -17
  40. package/generated/zlib.d.ts +15 -12
  41. package/index.d.ts +3 -1
  42. package/package.json +6 -2
  43. package/scripts/example-store-io.ts +18 -0
  44. package/scripts/fidelity-audit.ts +61 -1
  45. package/scripts/fidelity-baseline.json +10 -10
  46. package/scripts/ref-doc-delta.ts +143 -0
  47. package/scripts/regen.ts +23 -10
  48. package/src/core-types.ts +14 -0
  49. package/src/doc-comment.ts +2 -1
  50. package/src/emit-dts.ts +238 -18
  51. package/src/engine-globals.d.ts +2 -0
  52. package/src/example-store.ts +44 -0
  53. package/src/go-overloads.d.ts +73 -0
  54. package/src/index.ts +5 -0
  55. package/src/lifecycle.ts +157 -16
  56. package/src/message-dispatch.d.ts +21 -0
  57. package/src/message-guard.d.ts +19 -0
  58. package/src/msg-overloads.d.ts +20 -0
  59. package/src/publish-dts.ts +1 -1
@@ -1,5 +1,8 @@
1
1
  /** @noSelfInFile */
2
2
  declare global {
3
+ /**
4
+ * Functions for performing HTTP and HTTPS requests.
5
+ */
3
6
  namespace http {
4
7
  /**
5
8
  * Perform a HTTP/HTTPS request.
@@ -33,22 +36,29 @@ declare global {
33
36
  * - boolean `chunked_transfer`: use chunked transfer encoding for https requests larger than 16kb. Defaults to true. Not available in HTML5 build
34
37
  * - boolean `report_progress`: when it is true, the amount of bytes sent and/or received for a request will be passed into the callback function
35
38
  * @example
36
- * ```lua
37
- * Basic HTTP-GET request. The callback receives a table with the response
38
- * in the fields status, the response (the data) and headers (a table).
39
- * local function http_result(self, _, response)
40
- * if response.bytes_total ~= nil then
41
- * update_my_progress_bar(self, response.bytes_received / response.bytes_total)
42
- * else
43
- * print(response.status)
44
- * print(response.response)
45
- * pprint(response.headers)
46
- * end
47
- * end
48
- *
49
- * function init(self)
50
- * http.request("http://www.google.com", "GET", http_result, nil, nil, { report_progress = true })
51
- * end
39
+ * ```ts
40
+ * // Basic HTTP-GET request. The callback receives a table with the response
41
+ * // in the fields status, the response (the data) and headers (a table).
42
+ * export default defineScript({
43
+ * init() {
44
+ * http.request(
45
+ * "http://www.google.com",
46
+ * "GET",
47
+ * (self, _id, response) => {
48
+ * if (response.bytes_total !== undefined) {
49
+ * update_my_progress_bar(self, response.bytes_received / response.bytes_total);
50
+ * } else {
51
+ * print(response.status);
52
+ * print(response.response);
53
+ * pprint(response.headers);
54
+ * }
55
+ * },
56
+ * undefined,
57
+ * undefined,
58
+ * { report_progress: true },
59
+ * );
60
+ * },
61
+ * });
52
62
  * ```
53
63
  */
54
64
  function request(url: string, method: string, callback: (self: unknown, id: unknown, response: unknown) => void, headers?: Record<string | number, unknown>, post_data?: string, options?: { timeout?: number; path?: string; ignore_cache?: boolean; chunked_transfer?: boolean; report_progress?: boolean }): void;
@@ -1,5 +1,8 @@
1
1
  /** @noSelfInFile */
2
2
  declare global {
3
+ /**
4
+ * Functions and constants for doing inter-app communication. Supported on iOS and Android. [icon:ios] [icon:android]
5
+ */
3
6
  namespace iac {
4
7
  /**
5
8
  * Sets the listener function for inter-app communication events.
@@ -2,26 +2,29 @@
2
2
  import type { Opaque } from "../src/core-types";
3
3
 
4
4
  declare global {
5
+ /**
6
+ * Functions and constants for doing in-app purchases. Supported on iOS, Android (Google Play and Amazon) and Facebook Canvas platforms. [icon:ios] [icon:googleplay] [icon:amazon] [icon:facebook]
7
+ */
5
8
  namespace iap {
6
9
  /**
7
10
  * Acknowledge a transaction. [icon:attention] Calling iap.acknowledge is required on a successful transaction on Google Play unless iap.finish is called. The transaction.state field must equal iap.TRANS_STATE_PURCHASED.
8
11
  *
9
12
  * @param transaction - transaction table parameter as supplied in listener callback
10
13
  */
11
- function acknowledge(transaction: Record<string | number, unknown>): void;
14
+ function acknowledge(transaction: { ident?: string; state?: number; trans_ident?: string; date?: string; original_trans?: string; receipt?: string; signature?: string; user_id?: string }): void;
12
15
  /**
13
16
  * Purchase a product.
14
17
  *
15
18
  * @param id - product to buy
16
19
  * @param options - optional parameters as properties. The following parameters can be set
17
20
  */
18
- function buy(id: string, options: Record<string | number, unknown>): void;
21
+ function buy(id: string, options: { request_id?: string; token?: string }): void;
19
22
  /**
20
23
  * Explicitly finish a product transaction. [icon:attention] Calling iap.finish is required on a successful transaction if `auto_finish_transactions` is disabled in project settings. Calling this function with `auto_finish_transactions` set will be ignored and a warning is printed. The `transaction.state` field must equal `iap.TRANS_STATE_PURCHASED`.
21
24
  *
22
25
  * @param transaction - transaction table parameter as supplied in listener callback
23
26
  */
24
- function finish(transaction: Record<string | number, unknown>): void;
27
+ function finish(transaction: { ident?: string; state?: number; trans_ident?: string; date?: string; original_trans?: string; receipt?: string; signature?: string; user_id?: string }): void;
25
28
  /**
26
29
  * Get current iap provider
27
30
  *
@@ -2,6 +2,9 @@
2
2
  import type { Opaque } from "../src/core-types";
3
3
 
4
4
  declare global {
5
+ /**
6
+ * Functions for creating image objects.
7
+ */
5
8
  namespace image {
6
9
  /**
7
10
  * luminance image type
@@ -31,11 +34,11 @@ declare global {
31
34
  * - number `block_size_y`: block size y
32
35
  * - number `block_size_z`: block size z
33
36
  * @example
34
- * ```lua
35
- * How to get the block size and dimensions from a .astc file
36
- * local s = sys.load_resource("/assets/cat.astc")
37
- * local header = image.get_astc_header(s)
38
- * pprint(s)
37
+ * ```ts
38
+ * // How to get the block size and dimensions from a .astc file
39
+ * const [s] = sys.load_resource("/assets/cat.astc");
40
+ * const header = image.get_astc_header(s);
41
+ * pprint(s);
39
42
  * ```
40
43
  */
41
44
  function get_astc_header(buffer: string): { width: number; height: number; depth: number; block_size_x: number; block_size_y: number; block_size_z: number } | unknown;
@@ -58,13 +61,13 @@ declare global {
58
61
  * - `image.TYPE_LUMINANCE_ALPHA`
59
62
  * - string `buffer`: the raw image data
60
63
  * @example
61
- * ```lua
62
- * How to load an image from an URL and create a GUI texture from it:
63
- * local imgurl = "http://www.site.com/image.png"
64
- * http.request(imgurl, "GET", function(self, id, response)
65
- * local img = image.load(response.response)
66
- * local tx = gui.new_texture("image_node", img.width, img.height, img.type, img.buffer)
67
- * end)
64
+ * ```ts
65
+ * // How to load an image from an URL and create a GUI texture from it:
66
+ * const imgurl = "http://www.site.com/image.png";
67
+ * http.request(imgurl, "GET", (self, id, response) => {
68
+ * const img = image.load(response.response);
69
+ * const tx = gui.new_texture("image_node", img.width, img.height, img.type, img.buffer);
70
+ * });
68
71
  * ```
69
72
  */
70
73
  function load(buffer: string, options?: { premultiply_alpha?: boolean; flip_vertically?: boolean }): { width: number; height: number; type: Opaque<"constant">; buffer: string } | unknown;
@@ -87,21 +90,22 @@ declare global {
87
90
  * - `image.TYPE_LUMINANCE_ALPHA`
88
91
  * - buffer `buffer`: the script buffer that holds the decompressed image data. See buffer.create how to use the buffer.
89
92
  * @example
90
- * ```lua
91
- * Load an image from an URL as a buffer and create a texture resource from it:
92
- * local imgurl = "http://www.site.com/image.png"
93
- * http.request(imgurl, "GET", function(self, id, response)
94
- * local img = image.load_buffer(response.response, { flip_vertically = true })
95
- * local tparams = {
96
- * width = img.width,
97
- * height = img.height,
98
- * type = graphics.TEXTURE_TYPE_2D,
99
- * format = graphics.TEXTURE_FORMAT_RGBA }
93
+ * ```ts
94
+ * // Load an image from an URL as a buffer and create a texture resource from it:
95
+ * const imgurl = "http://www.site.com/image.png";
96
+ * http.request(imgurl, "GET", (self, id, response) => {
97
+ * const img = image.load_buffer(response.response, { flip_vertically: true });
98
+ * const tparams = {
99
+ * width: img.width,
100
+ * height: img.height,
101
+ * type: graphics.TEXTURE_TYPE_2D,
102
+ * format: graphics.TEXTURE_FORMAT_RGBA,
103
+ * };
100
104
  *
101
- * local my_texture_id = resource.create_texture("/my_custom_texture.texturec", tparams, img.buffer)
102
- * -- Apply the texture to a model
103
- * go.set("/go1#model", "texture0", my_texture_id)
104
- * end)
105
+ * const my_texture_id = resource.create_texture("/my_custom_texture.texturec", tparams, img.buffer);
106
+ * // Apply the texture to a model
107
+ * go.set("/go1#model", "texture0", my_texture_id);
108
+ * });
105
109
  * ```
106
110
  */
107
111
  function load_buffer(buffer: string, options?: { premultiply_alpha?: boolean; flip_vertically?: boolean }): { width: number; height: number; type: Opaque<"constant">; buffer: Opaque<"buffer"> } | unknown;
@@ -1,5 +1,8 @@
1
1
  /** @noSelfInFile */
2
2
  declare global {
3
+ /**
4
+ * Manipulation of JSON data strings.
5
+ */
3
6
  namespace json {
4
7
  /**
5
8
  * Represents the null primitive from a json file
@@ -14,25 +17,27 @@ declare global {
14
17
  * - boolean `decode_null_as_userdata`: wether to decode a JSON null value as json.null or nil (default is nil)
15
18
  * @returns decoded json
16
19
  * @example
17
- * ```lua
18
- * Converting a string containing JSON data into a Lua table:
19
- * function init(self)
20
- * local jsonstring = '{"persons":[{"name":"John Doe"},{"name":"Darth Vader"}]}'
21
- * local data = json.decode(jsonstring)
22
- * pprint(data)
23
- * end
20
+ * ```ts
21
+ * // Converting a string containing JSON data into a table:
22
+ * export default defineScript({
23
+ * init() {
24
+ * const jsonstring = '{"persons":[{"name":"John Doe"},{"name":"Darth Vader"}]}';
25
+ * const data = json.decode(jsonstring);
26
+ * pprint(data);
27
+ * },
28
+ * });
24
29
  *
25
- * Results in the following printout:
26
- * {
27
- * persons = {
28
- * 1 = {
29
- * name = John Doe,
30
- * }
31
- * 2 = {
32
- * name = Darth Vader,
33
- * }
34
- * }
35
- * }
30
+ * // Results in the following printout:
31
+ * // {
32
+ * // persons = {
33
+ * // 1 = {
34
+ * // name = John Doe,
35
+ * // }
36
+ * // 2 = {
37
+ * // name = Darth Vader,
38
+ * // }
39
+ * // }
40
+ * // }
36
41
  * ```
37
42
  */
38
43
  export function decode(json: string, options?: { decode_null_as_userdata?: boolean }): Record<string | number, unknown>;
@@ -45,21 +50,20 @@ declare global {
45
50
  * - string `encode_empty_table_as_object`: wether to encode an empty table as an JSON object or array (default is object)
46
51
  * @returns encoded json
47
52
  * @example
48
- * ```lua
49
- * Convert a lua table to a JSON string:
50
- * function init(self)
51
- * local tbl = {
52
- * persons = {
53
- * { name = "John Doe"},
54
- * { name = "Darth Vader"}
55
- * }
56
- * }
57
- * local jsonstring = json.encode(tbl)
58
- * pprint(jsonstring)
59
- * end
53
+ * ```ts
54
+ * // Convert a table to a JSON string:
55
+ * export default defineScript({
56
+ * init() {
57
+ * const tbl = {
58
+ * persons: [{ name: "John Doe" }, { name: "Darth Vader" }],
59
+ * };
60
+ * const jsonstring = json.encode(tbl);
61
+ * pprint(jsonstring);
62
+ * },
63
+ * });
60
64
  *
61
- * Results in the following printout:
62
- * {"persons":[{"name":"John Doe"},{"name":"Darth Vader"}]}
65
+ * // Results in the following printout:
66
+ * // {"persons":[{"name":"John Doe"},{"name":"Darth Vader"}]}
63
67
  * ```
64
68
  */
65
69
  export function encode(tbl: Record<string | number, unknown>, options?: { encode_empty_table_as_object?: string }): string;
@@ -1,9 +1,5 @@
1
- import "../../src/go-overloads";
2
- import "../../src/message-guard";
3
- import "../../src/msg-overloads";
4
1
  import "../b2d";
5
2
  import "../buffer";
6
- import "../builtin-messages";
7
3
  import "../camera";
8
4
  import "../collectionfactory";
9
5
  import "../collectionproxy";
@@ -35,6 +31,12 @@ import "../vmath";
35
31
  import "../webview";
36
32
  import "../window";
37
33
  import "../zlib";
34
+ import "../../src/engine-globals";
35
+ import "../../src/go-overloads";
36
+ import "../../src/message-guard";
37
+ import "../../src/msg-overloads";
38
+ import "../builtin-messages";
38
39
  import "../gui";
39
40
 
40
- export {};
41
+ export { defineGuiScript } from "../../src/lifecycle";
42
+ export type { ScriptProperties, ScriptProperty } from "../../src/lifecycle";
@@ -1,9 +1,5 @@
1
- import "../../src/go-overloads";
2
- import "../../src/message-guard";
3
- import "../../src/msg-overloads";
4
1
  import "../b2d";
5
2
  import "../buffer";
6
- import "../builtin-messages";
7
3
  import "../camera";
8
4
  import "../collectionfactory";
9
5
  import "../collectionproxy";
@@ -35,6 +31,12 @@ import "../vmath";
35
31
  import "../webview";
36
32
  import "../window";
37
33
  import "../zlib";
34
+ import "../../src/engine-globals";
35
+ import "../../src/go-overloads";
36
+ import "../../src/message-guard";
37
+ import "../../src/msg-overloads";
38
+ import "../builtin-messages";
38
39
  import "../render";
39
40
 
40
- export {};
41
+ export { defineRenderScript } from "../../src/lifecycle";
42
+ export type { ScriptProperties, ScriptProperty } from "../../src/lifecycle";
@@ -1,9 +1,5 @@
1
- import "../../src/go-overloads";
2
- import "../../src/message-guard";
3
- import "../../src/msg-overloads";
4
1
  import "../b2d";
5
2
  import "../buffer";
6
- import "../builtin-messages";
7
3
  import "../camera";
8
4
  import "../collectionfactory";
9
5
  import "../collectionproxy";
@@ -35,5 +31,11 @@ import "../vmath";
35
31
  import "../webview";
36
32
  import "../window";
37
33
  import "../zlib";
34
+ import "../../src/engine-globals";
35
+ import "../../src/go-overloads";
36
+ import "../../src/message-guard";
37
+ import "../../src/msg-overloads";
38
+ import "../builtin-messages";
38
39
 
39
- export {};
40
+ export { defineScript } from "../../src/lifecycle";
41
+ export type { ScriptProperties, ScriptProperty } from "../../src/lifecycle";
@@ -2,6 +2,9 @@
2
2
  import type { Hash, Url, Vector3, Vector4 } from "../src/core-types";
3
3
 
4
4
  declare global {
5
+ /**
6
+ * Functions to manipulate a label component.
7
+ */
5
8
  namespace label {
6
9
  /**
7
10
  * Gets the text from a label component
@@ -9,11 +12,13 @@ declare global {
9
12
  * @param url - the label to get the text from
10
13
  * @returns the label text
11
14
  * @example
12
- * ```lua
13
- * function init(self)
14
- * local text = label.get_text("#label")
15
- * print(text)
16
- * end
15
+ * ```ts
16
+ * export default defineScript({
17
+ * init(self) {
18
+ * const text = label.get_text("#label");
19
+ * print(text);
20
+ * },
21
+ * });
17
22
  * ```
18
23
  */
19
24
  function get_text(url: string | Hash | Url): string;
@@ -25,10 +30,12 @@ declare global {
25
30
  * @param url - the label that should have a constant set
26
31
  * @param text - the text
27
32
  * @example
28
- * ```lua
29
- * function init(self)
30
- * label.set_text("#label", "Hello World!")
31
- * end
33
+ * ```ts
34
+ * export default defineScript({
35
+ * init(self) {
36
+ * label.set_text("#label", "Hello World!");
37
+ * },
38
+ * });
32
39
  * ```
33
40
  */
34
41
  function set_text(url: string | Hash | Url, text: string | number): void;
@@ -1,5 +1,8 @@
1
1
  /** @noSelfInFile */
2
2
  declare global {
3
+ /**
4
+ * Functions and constants to access resources.
5
+ */
3
6
  namespace liveupdate {
4
7
  /**
5
8
  * Mismatch between between expected bundled resources and actual bundled resources. The manifest expects a resource to be in the bundle, but it was not found in the bundle. This is typically the case when a non-excluded resource was modified between publishing the bundle and publishing the manifest.
@@ -64,11 +67,11 @@ declare global {
64
67
  * @param callback - Callback after the asynchronous request completed
65
68
  * @returns The result of the request
66
69
  * @example
67
- * ```lua
68
- * Add multiple mounts. Higher priority takes precedence.
69
- * liveupdate.add_mount("common", "zip:/path/to/common_stuff.zip", 10, function (result) end) -- base pack
70
- * liveupdate.add_mount("levelpack_1", "zip:/path/to/levels_1_to_20.zip", 20, function (result) end) -- level pack
71
- * liveupdate.add_mount("season_pack_1", "zip:/path/to/easter_pack_1.zip", 30, function (result) end) -- season pack, overriding content in the other packs
70
+ * ```ts
71
+ * // Add multiple mounts. Higher priority takes precedence.
72
+ * liveupdate.add_mount("common", "zip:/path/to/common_stuff.zip", 10, (result) => {}); // base pack
73
+ * liveupdate.add_mount("levelpack_1", "zip:/path/to/levels_1_to_20.zip", 20, (result) => {}); // level pack
74
+ * liveupdate.add_mount("season_pack_1", "zip:/path/to/easter_pack_1.zip", 30, (result) => {}); // season pack, overriding content in the other packs
72
75
  * ```
73
76
  */
74
77
  function add_mount(name: string, uri: string, priority: number, callback: (...args: unknown[]) => unknown): number;
@@ -78,27 +81,27 @@ declare global {
78
81
  *
79
82
  * @returns Array of mounts
80
83
  * @example
81
- * ```lua
82
- * Output the current resource mounts
83
- * pprint("MOUNTS", liveupdate.get_mounts())
84
+ * ```ts
85
+ * // Output the current resource mounts
86
+ * pprint("MOUNTS", liveupdate.get_mounts());
84
87
  *
85
- * Give an output like:
86
- * DEBUG:SCRIPT: MOUNTS,
87
- * { --[[0x119667bf0]]
88
- * 1 = { --[[0x119667c50]]
89
- * name = "liveupdate",
90
- * uri = "zip:/device/path/to/acchives/liveupdate.zip",
91
- * priority = 5
92
- * },
93
- * 2 = { --[[0x119667d50]]
94
- * name = "_base",
95
- * uri = "archive:build/default/game.dmanifest",
96
- * priority = -10
97
- * }
98
- * }
88
+ * // Give an output like:
89
+ * // DEBUG:SCRIPT: MOUNTS,
90
+ * // {
91
+ * // 1 = {
92
+ * // name = "liveupdate",
93
+ * // uri = "zip:/device/path/to/acchives/liveupdate.zip",
94
+ * // priority = 5
95
+ * // },
96
+ * // 2 = {
97
+ * // name = "_base",
98
+ * // uri = "archive:build/default/game.dmanifest",
99
+ * // priority = -10
100
+ * // }
101
+ * // }
99
102
  * ```
100
103
  */
101
- function get_mounts(): Record<string | number, unknown>;
104
+ function get_mounts(): { name: string; uri: string; priority: number }[];
102
105
  /**
103
106
  * Remove a mount the resource system.
104
107
  * The remaining mounts are persisted between sessions.
@@ -107,9 +110,9 @@ declare global {
107
110
  * @param name - Unique name of the mount
108
111
  * @returns The result of the call
109
112
  * @example
110
- * ```lua
111
- * Add multiple mounts. Higher priority takes precedence.
112
- * liveupdate.remove_mount("season_pack_1")
113
+ * ```ts
114
+ * // Add multiple mounts. Higher priority takes precedence.
115
+ * liveupdate.remove_mount("season_pack_1");
113
116
  * ```
114
117
  */
115
118
  function remove_mount(name: string): number;
@@ -1,7 +1,10 @@
1
1
  /** @noSelfInFile */
2
- import type { Hash, Opaque, Url } from "../src/core-types";
2
+ import type { Hash, Opaque, Url, Vector3 } from "../src/core-types";
3
3
 
4
4
  declare global {
5
+ /**
6
+ * Functions and messages for interacting with model components.
7
+ */
5
8
  namespace model {
6
9
  /**
7
10
  * Cancels all animation on a model component.
@@ -16,12 +19,12 @@ declare global {
16
19
  * @param url - the model
17
20
  * @returns A table containing AABB of the model. If model has no meshes - return vmath.vector3(0,0,0) for min and max fields.
18
21
  * @example
19
- * ```lua
20
- * model.get_aabb("#model") -> { min = vmath.vector3(-2.5, -3.0, 0), max = vmath.vector3(1.5, 5.5, 0) }
21
- * model.get_aabb("#empty") -> { min = vmath.vector3(0, 0, 0), max = vmath.vector3(0, 0, 0) }
22
+ * ```ts
23
+ * model.get_aabb("#model"); // => { min = vmath.vector3(-2.5, -3.0, 0), max = vmath.vector3(1.5, 5.5, 0) }
24
+ * model.get_aabb("#empty"); // => { min = vmath.vector3(0, 0, 0), max = vmath.vector3(0, 0, 0) }
22
25
  * ```
23
26
  */
24
- function get_aabb(url: string | Hash | Url): Record<string | number, unknown>;
27
+ function get_aabb(url: string | Hash | Url): { min: Vector3; max: Vector3 };
25
28
  /**
26
29
  * Gets the id of the game object that corresponds to a model skeleton bone.
27
30
  * The returned game object can be used for parenting and transform queries.
@@ -32,13 +35,16 @@ declare global {
32
35
  * @param bone_id - id of the corresponding bone
33
36
  * @returns id of the game object
34
37
  * @example
35
- * ```lua
36
- * The following examples assumes that the model component has id "model".
37
- * How to parent the game object of the calling script to the "right_hand" bone of the model in a player game object:
38
- * function init(self)
39
- * local parent = model.get_go("player#model", "right_hand")
40
- * msg.post(".", "set_parent", {parent_id = parent})
41
- * end
38
+ * ```ts
39
+ * // The following examples assume that the model component has id "model".
40
+ * // How to parent the game object of the calling script to the "right_hand" bone
41
+ * // of the model in a player game object:
42
+ * export default defineScript({
43
+ * init(self) {
44
+ * const parent = model.get_go("player#model", "right_hand");
45
+ * msg.post(".", "set_parent", { parent_id: parent });
46
+ * },
47
+ * });
42
48
  * ```
43
49
  */
44
50
  function get_go(url: string | Hash | Url, bone_id: string | Hash): Hash;
@@ -49,11 +55,11 @@ declare global {
49
55
  * @param url - the model
50
56
  * @returns A table containing info about all AABB in the format
51
57
  * @example
52
- * ```lua
53
- * model.get_mesh_aabb("#model") -> { hash("Sword") = { min = vmath.vector3(-0.5, -0.5, 0), max = vmath.vector3(0.5, 0.5, 0) }, hash("Shield") = { min = vmath.vector3(-0.5, -0.5, -0.5), max = vmath.vector3(0.5, 0.5, 0.5) } }
58
+ * ```ts
59
+ * model.get_mesh_aabb("#model"); // => { hash("Sword") = { min = vmath.vector3(-0.5, -0.5, 0), max = vmath.vector3(0.5, 0.5, 0) }, hash("Shield") = { min = vmath.vector3(-0.5, -0.5, -0.5), max = vmath.vector3(0.5, 0.5, 0.5) } }
54
60
  * ```
55
61
  */
56
- function get_mesh_aabb(url: string | Hash | Url): Record<string | number, unknown>;
62
+ function get_mesh_aabb(url: string | Hash | Url): LuaMap<Hash, { min: Vector3; max: Vector3 }>;
57
63
  /**
58
64
  * Get the enabled state of a mesh
59
65
  *
@@ -61,13 +67,15 @@ declare global {
61
67
  * @param mesh_id - the id of the mesh
62
68
  * @returns true if the mesh is visible, false otherwise
63
69
  * @example
64
- * ```lua
65
- * function init(self)
66
- * if model.get_mesh_enabled("#model", "Sword") then
67
- * -- set properties specific for the sword
68
- * self.weapon_properties = game.data.weapons["Sword"]
69
- * end
70
- * end
70
+ * ```ts
71
+ * export default defineScript({
72
+ * init(self) {
73
+ * if (model.get_mesh_enabled("#model", "Sword")) {
74
+ * // set properties specific for the sword
75
+ * self.weapon_properties = game.data.weapons["Sword"];
76
+ * }
77
+ * },
78
+ * });
71
79
  * ```
72
80
  */
73
81
  function get_mesh_enabled(url: string | Hash | Url, mesh_id: string | Hash | Url): boolean;
@@ -113,25 +121,27 @@ declare global {
113
121
  * `sender`
114
122
  * url The invoker of the callback: the model component.
115
123
  * @example
116
- * ```lua
117
- * The following examples assumes that the model has id "model".
118
- * How to play the "jump" animation followed by the "run" animation:
119
- * local function anim_done(self, message_id, message, sender)
120
- * if message_id == hash("model_animation_done") then
121
- * if message.animation_id == hash("jump") then
122
- * -- open animation done, chain with "run"
123
- * local properties = { blend_duration = 0.2 }
124
- * model.play_anim(url, "run", go.PLAYBACK_LOOP_FORWARD, properties, anim_done)
125
- * end
126
- * end
127
- * end
124
+ * ```ts
125
+ * // The following examples assume that the model has id "model".
126
+ * // How to play the "jump" animation followed by the "run" animation:
127
+ * function anim_done(self, message_id, message, sender) {
128
+ * if (message_id === hash("model_animation_done")) {
129
+ * if (message.animation_id === hash("jump")) {
130
+ * // open animation done, chain with "run"
131
+ * const properties = { blend_duration: 0.2 };
132
+ * model.play_anim(url, "run", go.PLAYBACK_LOOP_FORWARD, properties, anim_done);
133
+ * }
134
+ * }
135
+ * }
128
136
  *
129
- * function init(self)
130
- * local url = msg.url("#model")
131
- * local play_properties = { blend_duration = 0.1 }
132
- * -- first blend during 0.1 sec into the jump, then during 0.2 s into the run animation
133
- * model.play_anim(url, "jump", go.PLAYBACK_ONCE_FORWARD, play_properties, anim_done)
134
- * end
137
+ * export default defineScript({
138
+ * init(self) {
139
+ * const url = msg.url("#model");
140
+ * const play_properties = { blend_duration: 0.1 };
141
+ * // first blend during 0.1 sec into the jump, then during 0.2 s into the run animation
142
+ * model.play_anim(url, "jump", go.PLAYBACK_ONCE_FORWARD, play_properties, anim_done);
143
+ * },
144
+ * });
135
145
  * ```
136
146
  */
137
147
  function play_anim(url: string | Hash | Url, anim_id: string | Hash, playback: Opaque<"constant">, play_properties?: { blend_duration?: number; offset?: number; playback_rate?: number }, complete_function?: (self: unknown, message_id: unknown, message: unknown, sender: unknown) => void): void;
@@ -142,11 +152,13 @@ declare global {
142
152
  * @param mesh_id - the id of the mesh
143
153
  * @param enabled - true if the mesh should be visible, false if it should be hideen
144
154
  * @example
145
- * ```lua
146
- * function init(self)
147
- * model.set_mesh_enabled("#model", "Sword", false) -- hide the sword
148
- * model.set_mesh_enabled("#model", "Axe", true) -- show the axe
149
- * end
155
+ * ```ts
156
+ * export default defineScript({
157
+ * init(self) {
158
+ * model.set_mesh_enabled("#model", "Sword", false); // hide the sword
159
+ * model.set_mesh_enabled("#model", "Axe", true); // show the axe
160
+ * },
161
+ * });
150
162
  * ```
151
163
  */
152
164
  function set_mesh_enabled(url: string | Hash | Url, mesh_id: string | Hash | Url, enabled: boolean): void;