@defold-typescript/types 0.35.0 → 0.37.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-signatures.json +9406 -18
- package/examples/translations.json +11 -11
- package/generated/b2d.d.ts +1 -1
- package/generated/b2d_body.d.ts +6 -4
- package/generated/b2d_fixture.d.ts +6 -4
- package/generated/b2d_shape.d.ts +6 -4
- package/generated/factory.d.ts +11 -10
- package/generated/render.d.ts +5 -5
- package/generated/resource.d.ts +4 -4
- package/generated/sys.d.ts +2 -2
- package/generated/versions/defold-1.12.4/b2d.d.ts +1 -1
- package/generated/versions/defold-1.12.4/factory.d.ts +11 -10
- package/generated/versions/defold-1.12.4/render.d.ts +5 -5
- package/generated/versions/defold-1.12.4/resource.d.ts +4 -4
- package/generated/versions/defold-1.12.4/sys.d.ts +2 -2
- package/generated/versions/defold-1.12.4/window.d.ts +1 -1
- package/generated/versions/defold-1.12.4/zlib.d.ts +2 -1
- package/generated/versions/defold-1.13.0/b2d.d.ts +1 -1
- package/generated/versions/defold-1.13.0/b2d_body.d.ts +6 -4
- package/generated/versions/defold-1.13.0/b2d_fixture.d.ts +6 -4
- package/generated/versions/defold-1.13.0/b2d_shape.d.ts +6 -4
- package/generated/versions/defold-1.13.0/factory.d.ts +11 -10
- package/generated/versions/defold-1.13.0/render.d.ts +5 -5
- package/generated/versions/defold-1.13.0/resource.d.ts +4 -4
- package/generated/versions/defold-1.13.0/sys.d.ts +2 -2
- package/generated/versions/defold-1.13.0/window.d.ts +1 -1
- package/generated/versions/defold-1.13.0/zlib.d.ts +2 -1
- package/generated/window.d.ts +1 -1
- package/generated/zlib.d.ts +2 -1
- package/index.d.ts +1 -0
- package/package.json +5 -2
- package/scripts/generate-api-signatures.ts +33 -8
- package/src/emit-dts.ts +355 -71
- package/src/index.ts +1 -0
- package/src/render-overloads.d.ts +17 -0
- package/src/return-correction-provenance.ts +306 -0
|
@@ -8,19 +8,19 @@
|
|
|
8
8
|
"b2d.body.create_fixture": [
|
|
9
9
|
{
|
|
10
10
|
"sourceHash": "1f1d588d084c0e48",
|
|
11
|
-
"ts": "const body = b2d.get_body(\"#collisionobject\");\
|
|
11
|
+
"ts": "const body = b2d.get_body(\"#collisionobject\");\nif (body !== undefined) {\n const triangle = b2d.body.create_fixture(body, {\n density: 1.0, friction: 0.3,\n shape: { type: b2d.shape.SHAPE_TYPE_POLYGON, vertices: [vmath.vector3(-16, -16, 0), vmath.vector3(16, -16, 0), vmath.vector3(0, 16, 0)] },\n });\n}"
|
|
12
12
|
}
|
|
13
13
|
],
|
|
14
14
|
"b2d.fixture.set_shape": [
|
|
15
15
|
{
|
|
16
16
|
"sourceHash": "ff836b80569f5d30",
|
|
17
|
-
"ts": "const body = b2d.get_body(\"#collisionobject\");\
|
|
17
|
+
"ts": "const body = b2d.get_body(\"#collisionobject\");\nif (body !== undefined) {\n const circle = b2d.fixture.get_shape(body, 1);\n circle.center = vmath.vector3(24, 0, 0);\n b2d.fixture.set_shape(body, 1, circle, true);\n b2d.fixture.set_shape(body, 2, { type: b2d.shape.SHAPE_TYPE_EDGE, v1: vmath.vector3(-32, 0, 0), v2: vmath.vector3(32, 0, 0) });\n}"
|
|
18
18
|
}
|
|
19
19
|
],
|
|
20
20
|
"b2d.shape.set_shape": [
|
|
21
21
|
{
|
|
22
22
|
"sourceHash": "f31970e9ebb8d446",
|
|
23
|
-
"ts": "const body = b2d.get_body(\"#collisionobject\");\
|
|
23
|
+
"ts": "const body = b2d.get_body(\"#collisionobject\");\nif (body !== undefined) {\n const circle = b2d.shape.get_shape(body, 1);\n circle.center = vmath.vector3(24, 0, 0);\n b2d.shape.set_shape(body, 1, circle, true);\n b2d.shape.set_shape(body, 2, { type: b2d.shape.SHAPE_TYPE_SEGMENT, v1: vmath.vector3(-32, 0, 0), v2: vmath.vector3(32, 0, 0) });\n}"
|
|
24
24
|
}
|
|
25
25
|
],
|
|
26
26
|
"buffer.copy_buffer": [
|
|
@@ -206,7 +206,7 @@
|
|
|
206
206
|
"factory.create": [
|
|
207
207
|
{
|
|
208
208
|
"sourceHash": "d2cd2037a9127ec6",
|
|
209
|
-
"ts": "// How to create a new game object:\nexport default defineScript({\n init(self) {\n // create a new game object and provide property values\n
|
|
209
|
+
"ts": "// How to create a new game object:\nexport default defineScript({\n init(self) {\n // create a new game object and provide property values\n const created = factory.create(\"#factory\", undefined, undefined, { my_value: 1 });\n // communicate with the object\n msg.post(created, \"hello\");\n },\n});\n\n// And then let the new game object have a script attached, in its own file:\n//\n// go.property(\"my_value\", 0);\n//\n// export default defineScript({\n// init(self) {\n// // do something with self.my_value which is now one\n// },\n// });"
|
|
210
210
|
}
|
|
211
211
|
],
|
|
212
212
|
"factory.load": [
|
|
@@ -320,7 +320,7 @@
|
|
|
320
320
|
"go.get_world_position": [
|
|
321
321
|
{
|
|
322
322
|
"sourceHash": "ab804a5cdcfd4f7d",
|
|
323
|
-
"ts": "// Get the world position of the game object the script is attached to:\nconst p = go.get_world_position();\n\n// Reach a sibling game object by its id
|
|
323
|
+
"ts": "// Get the world position of the game object the script is attached to:\nconst p = go.get_world_position();\n\n// Reach a sibling game object by its id — relative addressing, no socket prefix:\nconst p2 = go.get_world_position(\"x\");"
|
|
324
324
|
}
|
|
325
325
|
],
|
|
326
326
|
"go.get_world_rotation": [
|
|
@@ -368,7 +368,7 @@
|
|
|
368
368
|
"go.set_position": [
|
|
369
369
|
{
|
|
370
370
|
"sourceHash": "ad83d0274d776e8f",
|
|
371
|
-
"ts": "// `p` is the desired position (a Vector3).\nconst p = vmath.vector3();\n\n// Set the position of the game object the script is attached to:\ngo.set_position(p);\n\n// Reach a sibling game object by its id
|
|
371
|
+
"ts": "// `p` is the desired position (a Vector3).\nconst p = vmath.vector3();\n\n// Set the position of the game object the script is attached to:\ngo.set_position(p);\n\n// Reach a sibling game object by its id — relative addressing, no socket prefix:\ngo.set_position(p, \"x\");"
|
|
372
372
|
}
|
|
373
373
|
],
|
|
374
374
|
"go.set_rotation": [
|
|
@@ -770,7 +770,7 @@
|
|
|
770
770
|
"on_message": [
|
|
771
771
|
{
|
|
772
772
|
"sourceHash": "bfed6bd72e3242e2",
|
|
773
|
-
"ts": "// This example demonstrates how a game object instance, called \"a\", can communicate with another instance, called \"b\". It\n// is assumed that both script components of the instances has id \"script\".\n\n// a.script
|
|
773
|
+
"ts": "// This example demonstrates how a game object instance, called \"a\", can communicate with another instance, called \"b\". It\n// is assumed that both script components of the instances has id \"script\".\n\n// a.script — Script of instance \"a\":\nexport default defineScript({\n init() {\n // let b know about some important data\n msg.post(\"b#script\", \"my_data\", { important_value: 1 });\n },\n});\n\n// b.script — Script of instance \"b\":\nexport default defineScript({\n init() {\n // store the url of instance \"a\" for later use, by specifying undefined as socket we\n // automatically use our own socket\n return { a_url: msg.url(undefined, go.get_id(\"a\"), \"script\") };\n },\n\n on_message(self, message_id, message, sender) {\n // check message and sender\n if (message_id === hash(\"my_data\") && sender === self.a_url) {\n // use the data in some way\n self.important_value = message.important_value;\n }\n },\n});"
|
|
774
774
|
}
|
|
775
775
|
],
|
|
776
776
|
"on_reload": [
|
|
@@ -928,7 +928,7 @@
|
|
|
928
928
|
"render.clear": [
|
|
929
929
|
{
|
|
930
930
|
"sourceHash": "70406f065fc91216",
|
|
931
|
-
"ts": "// Clear the color buffer and the depth buffer.\
|
|
931
|
+
"ts": "// Clear the color buffer and the depth buffer.\nconst buffers = new LuaMap<render.ClearBufferKey, number | Vector4>();\nbuffers.set(graphics.BUFFER_TYPE_COLOR0_BIT, vmath.vector4(0, 0, 0, 0));\nbuffers.set(graphics.BUFFER_TYPE_DEPTH_BIT, 1);\nrender.clear(buffers);"
|
|
932
932
|
}
|
|
933
933
|
],
|
|
934
934
|
"render.constant_buffer": [
|
|
@@ -1224,7 +1224,7 @@
|
|
|
1224
1224
|
"resource.get_render_target_info": [
|
|
1225
1225
|
{
|
|
1226
1226
|
"sourceHash": "5e526c539ed8ae25",
|
|
1227
|
-
"ts": "// Get the metadata from a render target resource\nexport default defineScript({\n init() {\n const info = resource.get_render_target_info(\"/my_render_target.render_targetc\");\n // the info table contains meta data about all the render target attachments\n // so it's not necessary to use resource.get_texture here, but we do it here\n // just to show that it's possible:\n const info_attachment_1 = resource.get_texture_info(info.attachments[0]
|
|
1227
|
+
"ts": "// Get the metadata from a render target resource\nexport default defineScript({\n init() {\n const info = resource.get_render_target_info(\"/my_render_target.render_targetc\");\n // the info table contains meta data about all the render target attachments\n // so it's not necessary to use resource.get_texture here, but we do it here\n // just to show that it's possible:\n const info_attachment_1 = resource.get_texture_info(info.attachments[0]!.handle);\n },\n});\n\n// Get a texture attachment from a render target and set it on a model component\nexport default defineScript({\n init() {\n const info = resource.get_render_target_info(\"/my_render_target.render_targetc\");\n const attachment = info.attachments[0]!.texture!;\n // you can also get texture info from the 'texture' field, since it's a resource hash\n const texture_info = resource.get_texture_info(attachment);\n go.set(\"#model\", \"texture0\", attachment);\n },\n});"
|
|
1228
1228
|
}
|
|
1229
1229
|
],
|
|
1230
1230
|
"resource.get_text_metrics": [
|
|
@@ -1254,7 +1254,7 @@
|
|
|
1254
1254
|
"resource.render_target": [
|
|
1255
1255
|
{
|
|
1256
1256
|
"sourceHash": "87231742204d2351",
|
|
1257
|
-
"ts": "// Set a render target color attachment as a model texture:\ngo.property(\"my_render_target\", resource.render_target(\"/rt.render_target\"));\n\nexport default defineScript({\n init(self) {\n const rt_info = resource.get_render_target_info(self.my_render_target);\n go.set(\"#model\", \"texture0\", rt_info.attachments[0]
|
|
1257
|
+
"ts": "// Set a render target color attachment as a model texture:\ngo.property(\"my_render_target\", resource.render_target(\"/rt.render_target\"));\n\nexport default defineScript({\n init(self) {\n const rt_info = resource.get_render_target_info(self.my_render_target);\n go.set(\"#model\", \"texture0\", rt_info.attachments[0]!.texture!);\n },\n});"
|
|
1258
1258
|
}
|
|
1259
1259
|
],
|
|
1260
1260
|
"resource.set": [
|
|
@@ -1978,7 +1978,7 @@
|
|
|
1978
1978
|
"zlib.inflate": [
|
|
1979
1979
|
{
|
|
1980
1980
|
"sourceHash": "6b8b8cc6d9afe679",
|
|
1981
|
-
"ts": "const data
|
|
1981
|
+
"ts": "const data =\n \"\\x78\\x5e\\x0b\\xc9\\xc8\\x2c\\x56\\x00\\xa2\\x44\\x85\\xe2\\x92\\xa2\\xcc\\xbc\\x74\\x85\\xf2\\xcc\\x92\\x0c\\x85\\xd2\\xbc\\xe4\\xfc\\xdc\\x82\\xa2\\xd4\\xe2\\xe2\\xd4\\x14\\x85\\x94\\xc4\\x92\\x44\\x3d\\x00\\x2c\\x43\\x0e\\xc9\";\nconst uncompressed_data = zlib.inflate(data);\nprint(uncompressed_data); //> This is a string with uncompressed data."
|
|
1982
1982
|
}
|
|
1983
1983
|
]
|
|
1984
1984
|
}
|
package/generated/b2d.d.ts
CHANGED
|
@@ -14,7 +14,7 @@ declare global {
|
|
|
14
14
|
* @param url - the url to the game object collision component
|
|
15
15
|
* @returns the body if successful. Otherwise `nil`.
|
|
16
16
|
*/
|
|
17
|
-
function get_body(url: string | Hash | Url): Opaque<"b2Body"
|
|
17
|
+
function get_body(url: string | Hash | Url): Opaque<"b2Body"> | undefined;
|
|
18
18
|
/**
|
|
19
19
|
* Get the Box2D version information for the active backend.
|
|
20
20
|
*
|
package/generated/b2d_body.d.ts
CHANGED
|
@@ -133,10 +133,12 @@ declare global {
|
|
|
133
133
|
* @example
|
|
134
134
|
* ```ts
|
|
135
135
|
* const body = b2d.get_body("#collisionobject");
|
|
136
|
-
*
|
|
137
|
-
*
|
|
138
|
-
*
|
|
139
|
-
* }
|
|
136
|
+
* if (body !== undefined) {
|
|
137
|
+
* const triangle = b2d.body.create_fixture(body, {
|
|
138
|
+
* density: 1.0, friction: 0.3,
|
|
139
|
+
* shape: { type: b2d.shape.SHAPE_TYPE_POLYGON, vertices: [vmath.vector3(-16, -16, 0), vmath.vector3(16, -16, 0), vmath.vector3(0, 16, 0)] },
|
|
140
|
+
* });
|
|
141
|
+
* }
|
|
140
142
|
* ```
|
|
141
143
|
*/
|
|
142
144
|
function create_fixture(body: Opaque<"b2Body">, definition: { shape?: { type?: number; radius?: number; center?: Vector3; v0?: Vector3; v1?: Vector3; v2?: Vector3; v3?: Vector3; vertices?: Vector3[]; hx?: number; hy?: number; angle?: number; loop?: boolean; prev_vertex?: Vector3; next_vertex?: Vector3 }; friction?: number; restitution?: number; density?: number; sensor?: boolean; filter?: { category_bits?: number; mask_bits?: number; group_index?: number } }): { index: number; type: number; sensor: boolean; density: number; friction: number; restitution: number; child_count: number };
|
|
@@ -134,10 +134,12 @@ declare global {
|
|
|
134
134
|
* @example
|
|
135
135
|
* ```ts
|
|
136
136
|
* const body = b2d.get_body("#collisionobject");
|
|
137
|
-
*
|
|
138
|
-
* circle
|
|
139
|
-
*
|
|
140
|
-
*
|
|
137
|
+
* if (body !== undefined) {
|
|
138
|
+
* const circle = b2d.fixture.get_shape(body, 1);
|
|
139
|
+
* circle.center = vmath.vector3(24, 0, 0);
|
|
140
|
+
* b2d.fixture.set_shape(body, 1, circle, true);
|
|
141
|
+
* b2d.fixture.set_shape(body, 2, { type: b2d.shape.SHAPE_TYPE_EDGE, v1: vmath.vector3(-32, 0, 0), v2: vmath.vector3(32, 0, 0) });
|
|
142
|
+
* }
|
|
141
143
|
* ```
|
|
142
144
|
*/
|
|
143
145
|
function set_shape(body: Opaque<"b2Body">, fixture_index: number, shape: { type?: number; radius?: number; center?: Vector3; v0?: Vector3; v1?: Vector3; v2?: Vector3; v3?: Vector3; vertices?: Vector3[]; hx?: number; hy?: number; angle?: number; loop?: boolean; prev_vertex?: Vector3; next_vertex?: Vector3 }, update_mass?: boolean): void;
|
package/generated/b2d_shape.d.ts
CHANGED
|
@@ -202,10 +202,12 @@ declare global {
|
|
|
202
202
|
* @example
|
|
203
203
|
* ```ts
|
|
204
204
|
* const body = b2d.get_body("#collisionobject");
|
|
205
|
-
*
|
|
206
|
-
* circle
|
|
207
|
-
*
|
|
208
|
-
*
|
|
205
|
+
* if (body !== undefined) {
|
|
206
|
+
* const circle = b2d.shape.get_shape(body, 1);
|
|
207
|
+
* circle.center = vmath.vector3(24, 0, 0);
|
|
208
|
+
* b2d.shape.set_shape(body, 1, circle, true);
|
|
209
|
+
* b2d.shape.set_shape(body, 2, { type: b2d.shape.SHAPE_TYPE_SEGMENT, v1: vmath.vector3(-32, 0, 0), v2: vmath.vector3(32, 0, 0) });
|
|
210
|
+
* }
|
|
209
211
|
* ```
|
|
210
212
|
*/
|
|
211
213
|
function set_shape(shape_id: Opaque<"b2Shape">, definition: { type?: number; radius?: number; center?: Vector3; v0?: Vector3; v1?: Vector3; v2?: Vector3; v3?: Vector3; vertices?: Vector3[]; hx?: number; hy?: number; angle?: number; loop?: boolean; prev_vertex?: Vector3; next_vertex?: Vector3 }, update_mass: boolean): void;
|
package/generated/factory.d.ts
CHANGED
|
@@ -39,20 +39,21 @@ declare global {
|
|
|
39
39
|
* export default defineScript({
|
|
40
40
|
* init(self) {
|
|
41
41
|
* // create a new game object and provide property values
|
|
42
|
-
*
|
|
42
|
+
* const created = factory.create("#factory", undefined, undefined, { my_value: 1 });
|
|
43
43
|
* // communicate with the object
|
|
44
|
-
* msg.post(
|
|
44
|
+
* msg.post(created, "hello");
|
|
45
45
|
* },
|
|
46
46
|
* });
|
|
47
47
|
*
|
|
48
|
-
* // And then let the new game object have a script attached:
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
* }
|
|
48
|
+
* // And then let the new game object have a script attached, in its own file:
|
|
49
|
+
* //
|
|
50
|
+
* // go.property("my_value", 0);
|
|
51
|
+
* //
|
|
52
|
+
* // export default defineScript({
|
|
53
|
+
* // init(self) {
|
|
54
|
+
* // // do something with self.my_value which is now one
|
|
55
|
+
* // },
|
|
56
|
+
* // });
|
|
56
57
|
* ```
|
|
57
58
|
*/
|
|
58
59
|
function create(url: string | Hash | Url, position?: Vector3, rotation?: Quaternion, properties?: Record<string | number, unknown>, scale?: number | Vector3): Hash;
|
package/generated/render.d.ts
CHANGED
|
@@ -38,13 +38,13 @@ declare global {
|
|
|
38
38
|
* @example
|
|
39
39
|
* ```ts
|
|
40
40
|
* // Clear the color buffer and the depth buffer.
|
|
41
|
-
* render.
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
41
|
+
* const buffers = new LuaMap<render.ClearBufferKey, number | Vector4>();
|
|
42
|
+
* buffers.set(graphics.BUFFER_TYPE_COLOR0_BIT, vmath.vector4(0, 0, 0, 0));
|
|
43
|
+
* buffers.set(graphics.BUFFER_TYPE_DEPTH_BIT, 1);
|
|
44
|
+
* render.clear(buffers);
|
|
45
45
|
* ```
|
|
46
46
|
*/
|
|
47
|
-
function clear(buffers: LuaMap<number, number | Vector4>): void;
|
|
47
|
+
function clear(buffers: LuaMap<number & { readonly __brand: "graphics.BUFFER_TYPE_COLOR0_BIT" } | number & { readonly __brand: "graphics.BUFFER_TYPE_DEPTH_BIT" } | number & { readonly __brand: "graphics.BUFFER_TYPE_STENCIL_BIT" }, number | Vector4>): void;
|
|
48
48
|
/**
|
|
49
49
|
* Constant buffers are used to set shader program variables and are optionally passed to the `render.draw()` function.
|
|
50
50
|
* The buffer's constant elements can be indexed like an ordinary Lua table, but you can't iterate over them with pairs() or ipairs().
|
package/generated/resource.d.ts
CHANGED
|
@@ -844,7 +844,7 @@ declare global {
|
|
|
844
844
|
* // the info table contains meta data about all the render target attachments
|
|
845
845
|
* // so it's not necessary to use resource.get_texture here, but we do it here
|
|
846
846
|
* // just to show that it's possible:
|
|
847
|
-
* const info_attachment_1 = resource.get_texture_info(info.attachments[0]
|
|
847
|
+
* const info_attachment_1 = resource.get_texture_info(info.attachments[0]!.handle);
|
|
848
848
|
* },
|
|
849
849
|
* });
|
|
850
850
|
*
|
|
@@ -852,7 +852,7 @@ declare global {
|
|
|
852
852
|
* export default defineScript({
|
|
853
853
|
* init() {
|
|
854
854
|
* const info = resource.get_render_target_info("/my_render_target.render_targetc");
|
|
855
|
-
* const attachment = info.attachments[0]
|
|
855
|
+
* const attachment = info.attachments[0]!.texture!;
|
|
856
856
|
* // you can also get texture info from the 'texture' field, since it's a resource hash
|
|
857
857
|
* const texture_info = resource.get_texture_info(attachment);
|
|
858
858
|
* go.set("#model", "texture0", attachment);
|
|
@@ -860,7 +860,7 @@ declare global {
|
|
|
860
860
|
* });
|
|
861
861
|
* ```
|
|
862
862
|
*/
|
|
863
|
-
function get_render_target_info(path: Hash | string | number): { handle: number; width: number; height: number; depth: number; mipmaps: number; type: number; buffer_type: number; texture
|
|
863
|
+
function get_render_target_info(path: Hash | string | number): { handle: number; attachments: { handle: number; width: number; height: number; depth: number; mipmaps: number; type: number; buffer_type: number; texture?: Hash }[] };
|
|
864
864
|
/**
|
|
865
865
|
* Gets the text metrics from a font
|
|
866
866
|
*
|
|
@@ -1051,7 +1051,7 @@ declare global {
|
|
|
1051
1051
|
* export default defineScript({
|
|
1052
1052
|
* init(self) {
|
|
1053
1053
|
* const rt_info = resource.get_render_target_info(self.my_render_target);
|
|
1054
|
-
* go.set("#model", "texture0", rt_info.attachments[0]
|
|
1054
|
+
* go.set("#model", "texture0", rt_info.attachments[0]!.texture!);
|
|
1055
1055
|
* },
|
|
1056
1056
|
* });
|
|
1057
1057
|
* ```
|
package/generated/sys.d.ts
CHANGED
|
@@ -294,7 +294,7 @@ declare global {
|
|
|
294
294
|
* }
|
|
295
295
|
* ```
|
|
296
296
|
*/
|
|
297
|
-
function get_ifaddrs(): { name: string; address
|
|
297
|
+
function get_ifaddrs(): { name: string; address?: string; mac?: string; up: boolean; running: boolean }[];
|
|
298
298
|
/**
|
|
299
299
|
* The save-file path is operating system specific and is typically located under the user's home directory.
|
|
300
300
|
* This function will raise a Lua error if unable to get the save file path.
|
|
@@ -365,7 +365,7 @@ declare global {
|
|
|
365
365
|
* }
|
|
366
366
|
* ```
|
|
367
367
|
*/
|
|
368
|
-
function get_sys_info(options?: { ignore_secure?: boolean }): { device_model
|
|
368
|
+
function get_sys_info(options?: { ignore_secure?: boolean }): { device_model?: string; manufacturer?: string; system_name: string; system_version: string; api_version: string; language: string; device_language: string; territory: string; gmt_offset: number; device_ident?: string; user_agent?: string };
|
|
369
369
|
/**
|
|
370
370
|
* If the file exists, it must have been created by `sys.save` to be loaded.
|
|
371
371
|
* This function will raise a Lua error if an error occurs while loading the file.
|
|
@@ -14,7 +14,7 @@ declare global {
|
|
|
14
14
|
* @param url - the url to the game object collision component
|
|
15
15
|
* @returns the body if successful. Otherwise `nil`.
|
|
16
16
|
*/
|
|
17
|
-
function get_body(url: string | Hash | Url): Opaque<"b2Body"
|
|
17
|
+
function get_body(url: string | Hash | Url): Opaque<"b2Body"> | undefined;
|
|
18
18
|
/**
|
|
19
19
|
* Get the Box2D world from the current collection
|
|
20
20
|
*
|
|
@@ -39,20 +39,21 @@ declare global {
|
|
|
39
39
|
* export default defineScript({
|
|
40
40
|
* init(self) {
|
|
41
41
|
* // create a new game object and provide property values
|
|
42
|
-
*
|
|
42
|
+
* const created = factory.create("#factory", undefined, undefined, { my_value: 1 });
|
|
43
43
|
* // communicate with the object
|
|
44
|
-
* msg.post(
|
|
44
|
+
* msg.post(created, "hello");
|
|
45
45
|
* },
|
|
46
46
|
* });
|
|
47
47
|
*
|
|
48
|
-
* // And then let the new game object have a script attached:
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
* }
|
|
48
|
+
* // And then let the new game object have a script attached, in its own file:
|
|
49
|
+
* //
|
|
50
|
+
* // go.property("my_value", 0);
|
|
51
|
+
* //
|
|
52
|
+
* // export default defineScript({
|
|
53
|
+
* // init(self) {
|
|
54
|
+
* // // do something with self.my_value which is now one
|
|
55
|
+
* // },
|
|
56
|
+
* // });
|
|
56
57
|
* ```
|
|
57
58
|
*/
|
|
58
59
|
function create(url: string | Hash | Url, position?: Vector3, rotation?: Quaternion, properties?: Record<string | number, unknown>, scale?: number | Vector3): Hash;
|
|
@@ -46,13 +46,13 @@ declare global {
|
|
|
46
46
|
* @example
|
|
47
47
|
* ```ts
|
|
48
48
|
* // Clear the color buffer and the depth buffer.
|
|
49
|
-
* render.
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
49
|
+
* const buffers = new LuaMap<render.ClearBufferKey, number | Vector4>();
|
|
50
|
+
* buffers.set(graphics.BUFFER_TYPE_COLOR0_BIT, vmath.vector4(0, 0, 0, 0));
|
|
51
|
+
* buffers.set(graphics.BUFFER_TYPE_DEPTH_BIT, 1);
|
|
52
|
+
* render.clear(buffers);
|
|
53
53
|
* ```
|
|
54
54
|
*/
|
|
55
|
-
function clear(buffers: LuaMap<number, number | Vector4>): void;
|
|
55
|
+
function clear(buffers: LuaMap<number & { readonly __brand: "graphics.BUFFER_TYPE_COLOR0_BIT" } | number & { readonly __brand: "graphics.BUFFER_TYPE_DEPTH_BIT" } | number & { readonly __brand: "graphics.BUFFER_TYPE_STENCIL_BIT" }, number | Vector4>): void;
|
|
56
56
|
/**
|
|
57
57
|
* Constant buffers are used to set shader program variables and are optionally passed to the `render.draw()` function.
|
|
58
58
|
* The buffer's constant elements can be indexed like an ordinary Lua table, but you can't iterate over them with pairs() or ipairs().
|
|
@@ -844,7 +844,7 @@ declare global {
|
|
|
844
844
|
* // the info table contains meta data about all the render target attachments
|
|
845
845
|
* // so it's not necessary to use resource.get_texture here, but we do it here
|
|
846
846
|
* // just to show that it's possible:
|
|
847
|
-
* const info_attachment_1 = resource.get_texture_info(info.attachments[0]
|
|
847
|
+
* const info_attachment_1 = resource.get_texture_info(info.attachments[0]!.handle);
|
|
848
848
|
* },
|
|
849
849
|
* });
|
|
850
850
|
*
|
|
@@ -852,7 +852,7 @@ declare global {
|
|
|
852
852
|
* export default defineScript({
|
|
853
853
|
* init() {
|
|
854
854
|
* const info = resource.get_render_target_info("/my_render_target.render_targetc");
|
|
855
|
-
* const attachment = info.attachments[0]
|
|
855
|
+
* const attachment = info.attachments[0]!.texture!;
|
|
856
856
|
* // you can also get texture info from the 'texture' field, since it's a resource hash
|
|
857
857
|
* const texture_info = resource.get_texture_info(attachment);
|
|
858
858
|
* go.set("#model", "texture0", attachment);
|
|
@@ -860,7 +860,7 @@ declare global {
|
|
|
860
860
|
* });
|
|
861
861
|
* ```
|
|
862
862
|
*/
|
|
863
|
-
function get_render_target_info(path: Hash | string | number): { handle: number; width: number; height: number; depth: number; mipmaps: number; type: number; buffer_type: number; texture
|
|
863
|
+
function get_render_target_info(path: Hash | string | number): { handle: number; attachments: { handle: number; width: number; height: number; depth: number; mipmaps: number; type: number; buffer_type: number; texture?: Hash }[] };
|
|
864
864
|
/**
|
|
865
865
|
* Gets the text metrics from a font
|
|
866
866
|
*
|
|
@@ -1051,7 +1051,7 @@ declare global {
|
|
|
1051
1051
|
* export default defineScript({
|
|
1052
1052
|
* init(self) {
|
|
1053
1053
|
* const rt_info = resource.get_render_target_info(self.my_render_target);
|
|
1054
|
-
* go.set("#model", "texture0", rt_info.attachments[0]
|
|
1054
|
+
* go.set("#model", "texture0", rt_info.attachments[0]!.texture!);
|
|
1055
1055
|
* },
|
|
1056
1056
|
* });
|
|
1057
1057
|
* ```
|
|
@@ -294,7 +294,7 @@ declare global {
|
|
|
294
294
|
* }
|
|
295
295
|
* ```
|
|
296
296
|
*/
|
|
297
|
-
function get_ifaddrs(): { name: string; address
|
|
297
|
+
function get_ifaddrs(): { name: string; address?: string; mac?: string; up: boolean; running: boolean }[];
|
|
298
298
|
/**
|
|
299
299
|
* The save-file path is operating system specific and is typically located under the user's home directory.
|
|
300
300
|
* This function will raise a Lua error if unable to get the save file path.
|
|
@@ -365,7 +365,7 @@ declare global {
|
|
|
365
365
|
* }
|
|
366
366
|
* ```
|
|
367
367
|
*/
|
|
368
|
-
function get_sys_info(options?: { ignore_secure?: boolean }): { device_model
|
|
368
|
+
function get_sys_info(options?: { ignore_secure?: boolean }): { device_model?: string; manufacturer?: string; system_name: string; system_version: string; api_version: string; language: string; device_language: string; territory: string; gmt_offset: number; device_ident?: string; user_agent?: string };
|
|
369
369
|
/**
|
|
370
370
|
* If the file exists, it must have been created by `sys.save` to be loaded.
|
|
371
371
|
* This function will raise a Lua error if an error occurs while loading the file.
|
|
@@ -95,7 +95,7 @@ declare global {
|
|
|
95
95
|
*
|
|
96
96
|
* - number `inset_bottom`
|
|
97
97
|
*/
|
|
98
|
-
function get_safe_area(): {
|
|
98
|
+
function get_safe_area(): { x: number; y: number; width: number; height: number; inset_left: number; inset_top: number; inset_right: number; inset_bottom: number };
|
|
99
99
|
/**
|
|
100
100
|
* This returns the current window size (width and height).
|
|
101
101
|
*/
|
|
@@ -28,7 +28,8 @@ declare global {
|
|
|
28
28
|
* @returns inflated buffer
|
|
29
29
|
* @example
|
|
30
30
|
* ```ts
|
|
31
|
-
* const data =
|
|
31
|
+
* const data =
|
|
32
|
+
* "\x78\x5e\x0b\xc9\xc8\x2c\x56\x00\xa2\x44\x85\xe2\x92\xa2\xcc\xbc\x74\x85\xf2\xcc\x92\x0c\x85\xd2\xbc\xe4\xfc\xdc\x82\xa2\xd4\xe2\xe2\xd4\x14\x85\x94\xc4\x92\x44\x3d\x00\x2c\x43\x0e\xc9";
|
|
32
33
|
* const uncompressed_data = zlib.inflate(data);
|
|
33
34
|
* print(uncompressed_data); //> This is a string with uncompressed data.
|
|
34
35
|
* ```
|
|
@@ -14,7 +14,7 @@ declare global {
|
|
|
14
14
|
* @param url - the url to the game object collision component
|
|
15
15
|
* @returns the body if successful. Otherwise `nil`.
|
|
16
16
|
*/
|
|
17
|
-
function get_body(url: string | Hash | Url): Opaque<"b2Body"
|
|
17
|
+
function get_body(url: string | Hash | Url): Opaque<"b2Body"> | undefined;
|
|
18
18
|
/**
|
|
19
19
|
* Get the Box2D version information for the active backend.
|
|
20
20
|
*
|
|
@@ -133,10 +133,12 @@ declare global {
|
|
|
133
133
|
* @example
|
|
134
134
|
* ```ts
|
|
135
135
|
* const body = b2d.get_body("#collisionobject");
|
|
136
|
-
*
|
|
137
|
-
*
|
|
138
|
-
*
|
|
139
|
-
* }
|
|
136
|
+
* if (body !== undefined) {
|
|
137
|
+
* const triangle = b2d.body.create_fixture(body, {
|
|
138
|
+
* density: 1.0, friction: 0.3,
|
|
139
|
+
* shape: { type: b2d.shape.SHAPE_TYPE_POLYGON, vertices: [vmath.vector3(-16, -16, 0), vmath.vector3(16, -16, 0), vmath.vector3(0, 16, 0)] },
|
|
140
|
+
* });
|
|
141
|
+
* }
|
|
140
142
|
* ```
|
|
141
143
|
*/
|
|
142
144
|
function create_fixture(body: Opaque<"b2Body">, definition: { shape?: { type?: number; radius?: number; center?: Vector3; v0?: Vector3; v1?: Vector3; v2?: Vector3; v3?: Vector3; vertices?: Vector3[]; hx?: number; hy?: number; angle?: number; loop?: boolean; prev_vertex?: Vector3; next_vertex?: Vector3 }; friction?: number; restitution?: number; density?: number; sensor?: boolean; filter?: { category_bits?: number; mask_bits?: number; group_index?: number } }): { index: number; type: number; sensor: boolean; density: number; friction: number; restitution: number; child_count: number };
|
|
@@ -134,10 +134,12 @@ declare global {
|
|
|
134
134
|
* @example
|
|
135
135
|
* ```ts
|
|
136
136
|
* const body = b2d.get_body("#collisionobject");
|
|
137
|
-
*
|
|
138
|
-
* circle
|
|
139
|
-
*
|
|
140
|
-
*
|
|
137
|
+
* if (body !== undefined) {
|
|
138
|
+
* const circle = b2d.fixture.get_shape(body, 1);
|
|
139
|
+
* circle.center = vmath.vector3(24, 0, 0);
|
|
140
|
+
* b2d.fixture.set_shape(body, 1, circle, true);
|
|
141
|
+
* b2d.fixture.set_shape(body, 2, { type: b2d.shape.SHAPE_TYPE_EDGE, v1: vmath.vector3(-32, 0, 0), v2: vmath.vector3(32, 0, 0) });
|
|
142
|
+
* }
|
|
141
143
|
* ```
|
|
142
144
|
*/
|
|
143
145
|
function set_shape(body: Opaque<"b2Body">, fixture_index: number, shape: { type?: number; radius?: number; center?: Vector3; v0?: Vector3; v1?: Vector3; v2?: Vector3; v3?: Vector3; vertices?: Vector3[]; hx?: number; hy?: number; angle?: number; loop?: boolean; prev_vertex?: Vector3; next_vertex?: Vector3 }, update_mass?: boolean): void;
|
|
@@ -202,10 +202,12 @@ declare global {
|
|
|
202
202
|
* @example
|
|
203
203
|
* ```ts
|
|
204
204
|
* const body = b2d.get_body("#collisionobject");
|
|
205
|
-
*
|
|
206
|
-
* circle
|
|
207
|
-
*
|
|
208
|
-
*
|
|
205
|
+
* if (body !== undefined) {
|
|
206
|
+
* const circle = b2d.shape.get_shape(body, 1);
|
|
207
|
+
* circle.center = vmath.vector3(24, 0, 0);
|
|
208
|
+
* b2d.shape.set_shape(body, 1, circle, true);
|
|
209
|
+
* b2d.shape.set_shape(body, 2, { type: b2d.shape.SHAPE_TYPE_SEGMENT, v1: vmath.vector3(-32, 0, 0), v2: vmath.vector3(32, 0, 0) });
|
|
210
|
+
* }
|
|
209
211
|
* ```
|
|
210
212
|
*/
|
|
211
213
|
function set_shape(shape_id: Opaque<"b2Shape">, definition: { type?: number; radius?: number; center?: Vector3; v0?: Vector3; v1?: Vector3; v2?: Vector3; v3?: Vector3; vertices?: Vector3[]; hx?: number; hy?: number; angle?: number; loop?: boolean; prev_vertex?: Vector3; next_vertex?: Vector3 }, update_mass: boolean): void;
|
|
@@ -39,20 +39,21 @@ declare global {
|
|
|
39
39
|
* export default defineScript({
|
|
40
40
|
* init(self) {
|
|
41
41
|
* // create a new game object and provide property values
|
|
42
|
-
*
|
|
42
|
+
* const created = factory.create("#factory", undefined, undefined, { my_value: 1 });
|
|
43
43
|
* // communicate with the object
|
|
44
|
-
* msg.post(
|
|
44
|
+
* msg.post(created, "hello");
|
|
45
45
|
* },
|
|
46
46
|
* });
|
|
47
47
|
*
|
|
48
|
-
* // And then let the new game object have a script attached:
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
* }
|
|
48
|
+
* // And then let the new game object have a script attached, in its own file:
|
|
49
|
+
* //
|
|
50
|
+
* // go.property("my_value", 0);
|
|
51
|
+
* //
|
|
52
|
+
* // export default defineScript({
|
|
53
|
+
* // init(self) {
|
|
54
|
+
* // // do something with self.my_value which is now one
|
|
55
|
+
* // },
|
|
56
|
+
* // });
|
|
56
57
|
* ```
|
|
57
58
|
*/
|
|
58
59
|
function create(url: string | Hash | Url, position?: Vector3, rotation?: Quaternion, properties?: Record<string | number, unknown>, scale?: number | Vector3): Hash;
|
|
@@ -38,13 +38,13 @@ declare global {
|
|
|
38
38
|
* @example
|
|
39
39
|
* ```ts
|
|
40
40
|
* // Clear the color buffer and the depth buffer.
|
|
41
|
-
* render.
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
41
|
+
* const buffers = new LuaMap<render.ClearBufferKey, number | Vector4>();
|
|
42
|
+
* buffers.set(graphics.BUFFER_TYPE_COLOR0_BIT, vmath.vector4(0, 0, 0, 0));
|
|
43
|
+
* buffers.set(graphics.BUFFER_TYPE_DEPTH_BIT, 1);
|
|
44
|
+
* render.clear(buffers);
|
|
45
45
|
* ```
|
|
46
46
|
*/
|
|
47
|
-
function clear(buffers: LuaMap<number, number | Vector4>): void;
|
|
47
|
+
function clear(buffers: LuaMap<number & { readonly __brand: "graphics.BUFFER_TYPE_COLOR0_BIT" } | number & { readonly __brand: "graphics.BUFFER_TYPE_DEPTH_BIT" } | number & { readonly __brand: "graphics.BUFFER_TYPE_STENCIL_BIT" }, number | Vector4>): void;
|
|
48
48
|
/**
|
|
49
49
|
* Constant buffers are used to set shader program variables and are optionally passed to the `render.draw()` function.
|
|
50
50
|
* The buffer's constant elements can be indexed like an ordinary Lua table, but you can't iterate over them with pairs() or ipairs().
|
|
@@ -844,7 +844,7 @@ declare global {
|
|
|
844
844
|
* // the info table contains meta data about all the render target attachments
|
|
845
845
|
* // so it's not necessary to use resource.get_texture here, but we do it here
|
|
846
846
|
* // just to show that it's possible:
|
|
847
|
-
* const info_attachment_1 = resource.get_texture_info(info.attachments[0]
|
|
847
|
+
* const info_attachment_1 = resource.get_texture_info(info.attachments[0]!.handle);
|
|
848
848
|
* },
|
|
849
849
|
* });
|
|
850
850
|
*
|
|
@@ -852,7 +852,7 @@ declare global {
|
|
|
852
852
|
* export default defineScript({
|
|
853
853
|
* init() {
|
|
854
854
|
* const info = resource.get_render_target_info("/my_render_target.render_targetc");
|
|
855
|
-
* const attachment = info.attachments[0]
|
|
855
|
+
* const attachment = info.attachments[0]!.texture!;
|
|
856
856
|
* // you can also get texture info from the 'texture' field, since it's a resource hash
|
|
857
857
|
* const texture_info = resource.get_texture_info(attachment);
|
|
858
858
|
* go.set("#model", "texture0", attachment);
|
|
@@ -860,7 +860,7 @@ declare global {
|
|
|
860
860
|
* });
|
|
861
861
|
* ```
|
|
862
862
|
*/
|
|
863
|
-
function get_render_target_info(path: Hash | string | number): { handle: number; width: number; height: number; depth: number; mipmaps: number; type: number; buffer_type: number; texture
|
|
863
|
+
function get_render_target_info(path: Hash | string | number): { handle: number; attachments: { handle: number; width: number; height: number; depth: number; mipmaps: number; type: number; buffer_type: number; texture?: Hash }[] };
|
|
864
864
|
/**
|
|
865
865
|
* Gets the text metrics from a font
|
|
866
866
|
*
|
|
@@ -1051,7 +1051,7 @@ declare global {
|
|
|
1051
1051
|
* export default defineScript({
|
|
1052
1052
|
* init(self) {
|
|
1053
1053
|
* const rt_info = resource.get_render_target_info(self.my_render_target);
|
|
1054
|
-
* go.set("#model", "texture0", rt_info.attachments[0]
|
|
1054
|
+
* go.set("#model", "texture0", rt_info.attachments[0]!.texture!);
|
|
1055
1055
|
* },
|
|
1056
1056
|
* });
|
|
1057
1057
|
* ```
|
|
@@ -294,7 +294,7 @@ declare global {
|
|
|
294
294
|
* }
|
|
295
295
|
* ```
|
|
296
296
|
*/
|
|
297
|
-
function get_ifaddrs(): { name: string; address
|
|
297
|
+
function get_ifaddrs(): { name: string; address?: string; mac?: string; up: boolean; running: boolean }[];
|
|
298
298
|
/**
|
|
299
299
|
* The save-file path is operating system specific and is typically located under the user's home directory.
|
|
300
300
|
* This function will raise a Lua error if unable to get the save file path.
|
|
@@ -365,7 +365,7 @@ declare global {
|
|
|
365
365
|
* }
|
|
366
366
|
* ```
|
|
367
367
|
*/
|
|
368
|
-
function get_sys_info(options?: { ignore_secure?: boolean }): { device_model
|
|
368
|
+
function get_sys_info(options?: { ignore_secure?: boolean }): { device_model?: string; manufacturer?: string; system_name: string; system_version: string; api_version: string; language: string; device_language: string; territory: string; gmt_offset: number; device_ident?: string; user_agent?: string };
|
|
369
369
|
/**
|
|
370
370
|
* If the file exists, it must have been created by `sys.save` to be loaded.
|
|
371
371
|
* This function will raise a Lua error if an error occurs while loading the file.
|
|
@@ -95,7 +95,7 @@ declare global {
|
|
|
95
95
|
*
|
|
96
96
|
* - number `inset_bottom`
|
|
97
97
|
*/
|
|
98
|
-
function get_safe_area(): {
|
|
98
|
+
function get_safe_area(): { x: number; y: number; width: number; height: number; inset_left: number; inset_top: number; inset_right: number; inset_bottom: number };
|
|
99
99
|
/**
|
|
100
100
|
* This returns the current window size (width and height).
|
|
101
101
|
*/
|