@defold-typescript/types 0.38.0 → 0.40.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/api-availability.json +117 -0
- package/api-signatures.json +586 -480
- package/examples/translations.json +356 -180
- package/generated/b2d_body.d.ts +7 -4
- package/generated/b2d_shape.d.ts +23 -1
- package/generated/buffer.d.ts +34 -19
- package/generated/camera.d.ts +3 -2
- package/generated/collectionfactory.d.ts +17 -12
- package/generated/collectionproxy.d.ts +2 -2
- package/generated/compute.d.ts +1 -1
- package/generated/factory.d.ts +2 -1
- package/generated/go.d.ts +150 -91
- package/generated/graphics.d.ts +54 -0
- package/generated/gui.d.ts +117 -71
- package/generated/html5.d.ts +4 -2
- package/generated/http.d.ts +8 -2
- package/generated/image.d.ts +24 -15
- package/generated/kinds/gui-script.d.ts +1 -0
- package/generated/kinds/render-script.d.ts +1 -0
- package/generated/kinds/script.d.ts +1 -0
- package/generated/material.d.ts +1 -1
- package/generated/model.d.ts +41 -7
- package/generated/particlefx.d.ts +1 -1
- package/generated/physics.d.ts +29 -20
- package/generated/profiler.d.ts +10 -3
- package/generated/render.d.ts +293 -111
- package/generated/resource.d.ts +243 -226
- package/generated/socket.d.ts +33 -18
- package/generated/sound.d.ts +6 -5
- package/generated/sprite.d.ts +9 -1
- package/generated/sys.d.ts +44 -27
- package/generated/tilemap.d.ts +25 -19
- package/generated/timer.d.ts +33 -24
- package/generated/versions/defold-1.12.4/buffer.d.ts +34 -19
- package/generated/versions/defold-1.12.4/camera.d.ts +3 -2
- package/generated/versions/defold-1.12.4/collectionfactory.d.ts +17 -12
- package/generated/versions/defold-1.12.4/collectionproxy.d.ts +1 -1
- package/generated/versions/defold-1.12.4/factory.d.ts +2 -1
- package/generated/versions/defold-1.12.4/go.d.ts +150 -91
- package/generated/versions/defold-1.12.4/graphics.d.ts +2 -0
- package/generated/versions/defold-1.12.4/gui.d.ts +109 -69
- package/generated/versions/defold-1.12.4/html5.d.ts +4 -2
- package/generated/versions/defold-1.12.4/http.d.ts +8 -2
- package/generated/versions/defold-1.12.4/image.d.ts +24 -15
- package/generated/versions/defold-1.12.4/index.d.ts +1 -0
- package/generated/versions/defold-1.12.4/model.d.ts +41 -7
- package/generated/versions/defold-1.12.4/particlefx.d.ts +1 -1
- package/generated/versions/defold-1.12.4/physics.d.ts +29 -20
- package/generated/versions/defold-1.12.4/profiler.d.ts +10 -3
- package/generated/versions/defold-1.12.4/render.d.ts +292 -110
- package/generated/versions/defold-1.12.4/resource.d.ts +243 -226
- package/generated/versions/defold-1.12.4/socket.d.ts +33 -18
- package/generated/versions/defold-1.12.4/sound.d.ts +6 -5
- package/generated/versions/defold-1.12.4/sprite.d.ts +9 -1
- package/generated/versions/defold-1.12.4/sys.d.ts +44 -27
- package/generated/versions/defold-1.12.4/tilemap.d.ts +25 -19
- package/generated/versions/defold-1.12.4/timer.d.ts +33 -24
- package/generated/versions/defold-1.12.4/vmath.d.ts +18 -10
- package/generated/versions/defold-1.12.4/window.d.ts +5 -3
- package/generated/versions/defold-1.13.0/b2d_body.d.ts +7 -4
- package/generated/versions/defold-1.13.0/b2d_shape.d.ts +23 -1
- package/generated/versions/defold-1.13.0/buffer.d.ts +34 -19
- package/generated/versions/defold-1.13.0/camera.d.ts +3 -2
- package/generated/versions/defold-1.13.0/collectionfactory.d.ts +17 -12
- package/generated/versions/defold-1.13.0/collectionproxy.d.ts +1 -1
- package/generated/versions/defold-1.13.0/compute.d.ts +1 -1
- package/generated/versions/defold-1.13.0/factory.d.ts +2 -1
- package/generated/versions/defold-1.13.0/go.d.ts +150 -91
- package/generated/versions/defold-1.13.0/graphics.d.ts +50 -0
- package/generated/versions/defold-1.13.0/gui.d.ts +109 -69
- package/generated/versions/defold-1.13.0/html5.d.ts +4 -2
- package/generated/versions/defold-1.13.0/http.d.ts +8 -2
- package/generated/versions/defold-1.13.0/image.d.ts +24 -15
- package/generated/versions/defold-1.13.0/index.d.ts +1 -0
- package/generated/versions/defold-1.13.0/material.d.ts +1 -1
- package/generated/versions/defold-1.13.0/model.d.ts +41 -7
- package/generated/versions/defold-1.13.0/particlefx.d.ts +1 -1
- package/generated/versions/defold-1.13.0/physics.d.ts +29 -20
- package/generated/versions/defold-1.13.0/profiler.d.ts +10 -3
- package/generated/versions/defold-1.13.0/render.d.ts +293 -111
- package/generated/versions/defold-1.13.0/resource.d.ts +243 -226
- package/generated/versions/defold-1.13.0/socket.d.ts +33 -18
- package/generated/versions/defold-1.13.0/sound.d.ts +6 -5
- package/generated/versions/defold-1.13.0/sprite.d.ts +9 -1
- package/generated/versions/defold-1.13.0/sys.d.ts +44 -27
- package/generated/versions/defold-1.13.0/tilemap.d.ts +25 -19
- package/generated/versions/defold-1.13.0/timer.d.ts +33 -24
- package/generated/versions/defold-1.13.0/vmath.d.ts +18 -10
- package/generated/versions/defold-1.13.0/window.d.ts +5 -3
- package/generated/vmath.d.ts +18 -10
- package/generated/window.d.ts +5 -3
- package/index.d.ts +1 -0
- package/package.json +2 -1
- package/scripts/generate-api-signatures.ts +2 -1
- package/scripts/prose-constants.ts +96 -0
- package/scripts/regen.ts +6 -2
- package/src/api-doc.ts +8 -0
- package/src/component-properties.d.ts +33 -0
- package/src/core-types.ts +4 -2
- package/src/custom-messages.d.ts +4 -3
- package/src/doc-comment.ts +247 -43
- package/src/emit-dts.ts +958 -57
- package/src/engine-globals.d.ts +2 -2
- package/src/example-store.ts +26 -0
- package/src/go-overloads.d.ts +11 -10
- package/src/index.ts +9 -0
- package/src/param-correction-provenance.ts +67 -0
- package/src/render-overloads.d.ts +15 -17
- package/src/script-api.ts +3 -1
|
@@ -47,6 +47,7 @@ declare global {
|
|
|
47
47
|
* @returns true if contact events are enabled
|
|
48
48
|
*/
|
|
49
49
|
function are_contact_events_enabled(shape_id: Opaque<"b2Shape">): boolean;
|
|
50
|
+
function are_contact_events_enabled(body: Opaque<"b2Body">, shape_index: number): boolean;
|
|
50
51
|
/**
|
|
51
52
|
* Check if hit events are enabled for a shape.
|
|
52
53
|
*
|
|
@@ -54,6 +55,7 @@ declare global {
|
|
|
54
55
|
* @returns true if hit events are enabled
|
|
55
56
|
*/
|
|
56
57
|
function are_hit_events_enabled(shape_id: Opaque<"b2Shape">): boolean;
|
|
58
|
+
function are_hit_events_enabled(body: Opaque<"b2Body">, shape_index: number): boolean;
|
|
57
59
|
/**
|
|
58
60
|
* Check if pre-solve events are enabled for a shape.
|
|
59
61
|
*
|
|
@@ -61,6 +63,7 @@ declare global {
|
|
|
61
63
|
* @returns true if pre-solve events are enabled
|
|
62
64
|
*/
|
|
63
65
|
function are_pre_solve_events_enabled(shape_id: Opaque<"b2Shape">): boolean;
|
|
66
|
+
function are_pre_solve_events_enabled(body: Opaque<"b2Body">, shape_index: number): boolean;
|
|
64
67
|
/**
|
|
65
68
|
* Check if sensor events are enabled for a shape.
|
|
66
69
|
*
|
|
@@ -68,6 +71,7 @@ declare global {
|
|
|
68
71
|
* @returns true if sensor events are enabled
|
|
69
72
|
*/
|
|
70
73
|
function are_sensor_events_enabled(shape_id: Opaque<"b2Shape">): boolean;
|
|
74
|
+
function are_sensor_events_enabled(body: Opaque<"b2Body">, shape_index: number): boolean;
|
|
71
75
|
/**
|
|
72
76
|
* Enable or disable contact events for a shape.
|
|
73
77
|
*
|
|
@@ -75,6 +79,7 @@ declare global {
|
|
|
75
79
|
* @param enable - true to enable contact events
|
|
76
80
|
*/
|
|
77
81
|
function enable_contact_events(shape_id: Opaque<"b2Shape">, enable: boolean): void;
|
|
82
|
+
function enable_contact_events(body: Opaque<"b2Body">, shape_index: number, enable: boolean): void;
|
|
78
83
|
/**
|
|
79
84
|
* Enable or disable hit events for a shape.
|
|
80
85
|
*
|
|
@@ -82,6 +87,7 @@ declare global {
|
|
|
82
87
|
* @param enable - true to enable hit events
|
|
83
88
|
*/
|
|
84
89
|
function enable_hit_events(shape_id: Opaque<"b2Shape">, enable: boolean): void;
|
|
90
|
+
function enable_hit_events(body: Opaque<"b2Body">, shape_index: number, enable: boolean): void;
|
|
85
91
|
/**
|
|
86
92
|
* Enable or disable pre-solve events for a shape.
|
|
87
93
|
*
|
|
@@ -89,6 +95,7 @@ declare global {
|
|
|
89
95
|
* @param enable - true to enable pre-solve events
|
|
90
96
|
*/
|
|
91
97
|
function enable_pre_solve_events(shape_id: Opaque<"b2Shape">, enable: boolean): void;
|
|
98
|
+
function enable_pre_solve_events(body: Opaque<"b2Body">, shape_index: number, enable: boolean): void;
|
|
92
99
|
/**
|
|
93
100
|
* Enable or disable sensor events for a shape.
|
|
94
101
|
*
|
|
@@ -96,6 +103,7 @@ declare global {
|
|
|
96
103
|
* @param enable - true to enable sensor events
|
|
97
104
|
*/
|
|
98
105
|
function enable_sensor_events(shape_id: Opaque<"b2Shape">, enable: boolean): void;
|
|
106
|
+
function enable_sensor_events(body: Opaque<"b2Body">, shape_index: number, enable: boolean): void;
|
|
99
107
|
/**
|
|
100
108
|
* Get the body owning a shape.
|
|
101
109
|
*
|
|
@@ -103,6 +111,7 @@ declare global {
|
|
|
103
111
|
* @returns owning body
|
|
104
112
|
*/
|
|
105
113
|
function get_body(shape_id: Opaque<"b2Shape">): Opaque<"b2Body">;
|
|
114
|
+
function get_body(body: Opaque<"b2Body">, shape_index: number): Opaque<"b2Body">;
|
|
106
115
|
/**
|
|
107
116
|
* Get the closest point on a shape.
|
|
108
117
|
*
|
|
@@ -111,6 +120,7 @@ declare global {
|
|
|
111
120
|
* @returns closest world point on the shape
|
|
112
121
|
*/
|
|
113
122
|
function get_closest_point(shape_id: Opaque<"b2Shape">, target: Vector3): Vector3;
|
|
123
|
+
function get_closest_point(body: Opaque<"b2Body">, shape_index: number, target: Vector3): Vector3;
|
|
114
124
|
/**
|
|
115
125
|
* Get shape contact capacity.
|
|
116
126
|
*
|
|
@@ -118,6 +128,7 @@ declare global {
|
|
|
118
128
|
* @returns maximum contact data count
|
|
119
129
|
*/
|
|
120
130
|
function get_contact_capacity(shape_id: Opaque<"b2Shape">): number;
|
|
131
|
+
function get_contact_capacity(body: Opaque<"b2Body">, shape_index: number): number;
|
|
121
132
|
/**
|
|
122
133
|
* Get touching contact data for a shape.
|
|
123
134
|
*
|
|
@@ -125,6 +136,7 @@ declare global {
|
|
|
125
136
|
* @returns array of contact tables
|
|
126
137
|
*/
|
|
127
138
|
function get_contact_data(shape_id: Opaque<"b2Shape">): Record<string | number, unknown>;
|
|
139
|
+
function get_contact_data(body: Opaque<"b2Body">, shape_index: number): Record<string | number, unknown>;
|
|
128
140
|
/**
|
|
129
141
|
* Get mass data for a shape.
|
|
130
142
|
*
|
|
@@ -132,6 +144,7 @@ declare global {
|
|
|
132
144
|
* @returns table with `mass`, `center`, and `inertia`
|
|
133
145
|
*/
|
|
134
146
|
function get_mass_data(shape_id: Opaque<"b2Shape">): { mass: number; center: Vector3; inertia: number };
|
|
147
|
+
function get_mass_data(body: Opaque<"b2Body">, shape_index: number): { mass: number; center: Vector3; inertia: number };
|
|
135
148
|
/**
|
|
136
149
|
* Get shape material id.
|
|
137
150
|
*
|
|
@@ -139,6 +152,7 @@ declare global {
|
|
|
139
152
|
* @returns shape material id
|
|
140
153
|
*/
|
|
141
154
|
function get_material(shape_id: Opaque<"b2Shape">): number;
|
|
155
|
+
function get_material(body: Opaque<"b2Body">, shape_index: number): number;
|
|
142
156
|
/**
|
|
143
157
|
* Get sensor overlap capacity.
|
|
144
158
|
*
|
|
@@ -146,6 +160,7 @@ declare global {
|
|
|
146
160
|
* @returns maximum sensor overlap count
|
|
147
161
|
*/
|
|
148
162
|
function get_sensor_capacity(shape_id: Opaque<"b2Shape">): number;
|
|
163
|
+
function get_sensor_capacity(body: Opaque<"b2Body">, shape_index: number): number;
|
|
149
164
|
/**
|
|
150
165
|
* Get sensor overlaps.
|
|
151
166
|
*
|
|
@@ -153,6 +168,7 @@ declare global {
|
|
|
153
168
|
* @returns array of shape info tables
|
|
154
169
|
*/
|
|
155
170
|
function get_sensor_overlaps(shape_id: Opaque<"b2Shape">): { shape_id: number }[];
|
|
171
|
+
function get_sensor_overlaps(body: Opaque<"b2Body">, shape_index: number): { shape_id: number }[];
|
|
156
172
|
/**
|
|
157
173
|
* Get a shape's geometry.
|
|
158
174
|
*
|
|
@@ -160,6 +176,7 @@ declare global {
|
|
|
160
176
|
* @returns shape table with numeric `type` from `b2d.shape.SHAPE_TYPE_*`
|
|
161
177
|
*/
|
|
162
178
|
function get_shape(shape_id: Opaque<"b2Shape">): { 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 };
|
|
179
|
+
function get_shape(body: Opaque<"b2Body">, shape_index: number): { 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 };
|
|
163
180
|
/**
|
|
164
181
|
* Get the world owning a shape.
|
|
165
182
|
*
|
|
@@ -167,6 +184,7 @@ declare global {
|
|
|
167
184
|
* @returns owning world
|
|
168
185
|
*/
|
|
169
186
|
function get_world(shape_id: Opaque<"b2Shape">): Opaque<"b2World">;
|
|
187
|
+
function get_world(body: Opaque<"b2Body">, shape_index: number): Opaque<"b2World">;
|
|
170
188
|
/**
|
|
171
189
|
* Validate a shape handle.
|
|
172
190
|
*
|
|
@@ -174,6 +192,7 @@ declare global {
|
|
|
174
192
|
* @returns true if the shape handle still refers to a live Box2D shape
|
|
175
193
|
*/
|
|
176
194
|
function is_valid(shape_id: Opaque<"b2Shape">): boolean;
|
|
195
|
+
function is_valid(body: Opaque<"b2Body">, shape_index: number): boolean;
|
|
177
196
|
/**
|
|
178
197
|
* Ray cast a shape directly.
|
|
179
198
|
*
|
|
@@ -184,6 +203,7 @@ declare global {
|
|
|
184
203
|
* @returns hit table with `point`, `normal`, `fraction`, and `iterations`, or nil
|
|
185
204
|
*/
|
|
186
205
|
function ray_cast(shape_id: Opaque<"b2Shape">, origin: Vector3, translation: Vector3, max_fraction?: number): { point: Vector3; normal: Vector3; fraction: number; iterations: number };
|
|
206
|
+
function ray_cast(body: Opaque<"b2Body">, shape_index: number, origin: Vector3, translation: Vector3, max_fraction?: number): { point: Vector3; normal: Vector3; fraction: number; iterations: number };
|
|
187
207
|
/**
|
|
188
208
|
* Set shape material id.
|
|
189
209
|
*
|
|
@@ -191,6 +211,7 @@ declare global {
|
|
|
191
211
|
* @param material - shape material id
|
|
192
212
|
*/
|
|
193
213
|
function set_material(shape_id: Opaque<"b2Shape">, material: number): void;
|
|
214
|
+
function set_material(body: Opaque<"b2Body">, shape_index: number, material: number): void;
|
|
194
215
|
/**
|
|
195
216
|
* This updates the shape geometry using the same table format as
|
|
196
217
|
* `b2d.body.create_shape` and `b2d.shape.get_shape`. The body mass is not
|
|
@@ -210,7 +231,8 @@ declare global {
|
|
|
210
231
|
* }
|
|
211
232
|
* ```
|
|
212
233
|
*/
|
|
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
|
|
234
|
+
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;
|
|
235
|
+
function set_shape(body: Opaque<"b2Body">, shape_index: number, 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;
|
|
214
236
|
}
|
|
215
237
|
}
|
|
216
238
|
|
|
@@ -6,6 +6,7 @@ declare global {
|
|
|
6
6
|
* Functions for manipulating buffers and streams
|
|
7
7
|
*/
|
|
8
8
|
namespace buffer {
|
|
9
|
+
type ValueType = typeof buffer.VALUE_TYPE_FLOAT32 | typeof buffer.VALUE_TYPE_INT16 | typeof buffer.VALUE_TYPE_INT32 | typeof buffer.VALUE_TYPE_INT64 | typeof buffer.VALUE_TYPE_INT8 | typeof buffer.VALUE_TYPE_UINT16 | typeof buffer.VALUE_TYPE_UINT32 | typeof buffer.VALUE_TYPE_UINT64 | typeof buffer.VALUE_TYPE_UINT8;
|
|
9
10
|
/**
|
|
10
11
|
* Float, single precision, 4 bytes
|
|
11
12
|
*/
|
|
@@ -56,11 +57,15 @@ declare global {
|
|
|
56
57
|
* @example
|
|
57
58
|
* ```ts
|
|
58
59
|
* // How to copy elements (e.g. vertices) from one buffer to another
|
|
60
|
+
* const element_count = 64;
|
|
61
|
+
* const srcbuffer = resource.get_buffer("/src.bufferc");
|
|
62
|
+
* const dstbuffer = resource.get_buffer("/dst.bufferc");
|
|
63
|
+
*
|
|
59
64
|
* // copy entire buffer
|
|
60
|
-
* buffer.copy_buffer(dstbuffer, 0, srcbuffer, 0,
|
|
65
|
+
* buffer.copy_buffer(dstbuffer, 0, srcbuffer, 0, element_count);
|
|
61
66
|
*
|
|
62
67
|
* // copy last 10 elements to the front of another buffer
|
|
63
|
-
* buffer.copy_buffer(dstbuffer, 0, srcbuffer,
|
|
68
|
+
* buffer.copy_buffer(dstbuffer, 0, srcbuffer, element_count - 10, 10);
|
|
64
69
|
* ```
|
|
65
70
|
*/
|
|
66
71
|
function copy_buffer(dst: Opaque<"buffer">, dstoffset: number, src: Opaque<"buffer">, srcoffset: number, count: number): void;
|
|
@@ -77,13 +82,16 @@ declare global {
|
|
|
77
82
|
* @example
|
|
78
83
|
* ```ts
|
|
79
84
|
* // How to update a texture of a sprite:
|
|
85
|
+
* const srcbuffer = resource.get_buffer("/src.bufferc");
|
|
86
|
+
* const dstbuffer = resource.get_buffer("/dst.bufferc");
|
|
87
|
+
*
|
|
80
88
|
* // copy entire stream
|
|
81
89
|
* const srcstream = buffer.get_stream(srcbuffer, hash("xyz"));
|
|
82
90
|
* const dststream = buffer.get_stream(dstbuffer, hash("xyz"));
|
|
83
|
-
* buffer.copy_stream(dststream, 0, srcstream, 0, srcstream.length);
|
|
91
|
+
* buffer.copy_stream(dststream, 0, srcstream, 0, srcstream.length());
|
|
84
92
|
* ```
|
|
85
93
|
*/
|
|
86
|
-
function copy_stream(dst: Opaque<"bufferstream"> & { [index: number]: number }, dstoffset: number, src: Opaque<"bufferstream"> & { [index: number]: number }, srcoffset: number, count: number): void;
|
|
94
|
+
function copy_stream(dst: Opaque<"bufferstream"> & { [index: number]: number; length: LuaLengthMethod<number> }, dstoffset: number, src: Opaque<"bufferstream"> & { [index: number]: number; length: LuaLengthMethod<number> }, srcoffset: number, count: number): void;
|
|
87
95
|
/**
|
|
88
96
|
* Create a new data buffer containing a specified set of streams. A data buffer
|
|
89
97
|
* can contain one or more streams with typed data. This is useful for managing
|
|
@@ -103,24 +111,27 @@ declare global {
|
|
|
103
111
|
* ```ts
|
|
104
112
|
* // How to create and initialize a buffer
|
|
105
113
|
* export default defineScript({
|
|
106
|
-
* init(
|
|
114
|
+
* init() {
|
|
107
115
|
* const size = 128;
|
|
108
|
-
*
|
|
109
|
-
*
|
|
110
|
-
*
|
|
111
|
-
*
|
|
112
|
-
*
|
|
113
|
-
*
|
|
114
|
-
*
|
|
115
|
-
*
|
|
116
|
-
*
|
|
116
|
+
* const [width, height] = [size, size];
|
|
117
|
+
* const [r, g, b] = [0xff, 0x80, 0x10];
|
|
118
|
+
* const image = buffer.create(size * size, [{ name: hash("rgb"), type: buffer.VALUE_TYPE_UINT8, count: 3 }]);
|
|
119
|
+
* const imagestream = buffer.get_stream(image, hash("rgb"));
|
|
120
|
+
*
|
|
121
|
+
* for (let y = 0; y < height; y++) {
|
|
122
|
+
* for (let x = 0; x < width; x++) {
|
|
123
|
+
* const index = y * width * 3 + x * 3;
|
|
124
|
+
* imagestream[index + 0] = r;
|
|
125
|
+
* imagestream[index + 1] = g;
|
|
126
|
+
* imagestream[index + 2] = b;
|
|
117
127
|
* }
|
|
118
128
|
* }
|
|
129
|
+
* return { image, imagestream };
|
|
119
130
|
* },
|
|
120
131
|
* });
|
|
121
132
|
* ```
|
|
122
133
|
*/
|
|
123
|
-
function create(element_count: number, declaration: { name?: Hash | string; type?:
|
|
134
|
+
function create(element_count: number, declaration: { name?: Hash | string; type?: buffer.ValueType; count?: number }[]): Opaque<"buffer">;
|
|
124
135
|
/**
|
|
125
136
|
* Get a copy of all the bytes from a specified stream as a Lua string.
|
|
126
137
|
*
|
|
@@ -128,7 +139,7 @@ declare global {
|
|
|
128
139
|
* @param stream_name - the name of the stream
|
|
129
140
|
* @returns the buffer data as a Lua string
|
|
130
141
|
*/
|
|
131
|
-
function get_bytes(buffer: Opaque<"buffer">, stream_name: Hash): string;
|
|
142
|
+
function get_bytes(buffer: Opaque<"buffer">, stream_name: Hash | string): string;
|
|
132
143
|
/**
|
|
133
144
|
* Get a named metadata entry from a buffer along with its type.
|
|
134
145
|
*
|
|
@@ -137,12 +148,14 @@ declare global {
|
|
|
137
148
|
* @example
|
|
138
149
|
* ```ts
|
|
139
150
|
* // How to get a metadata entry from a buffer
|
|
151
|
+
* const buf = resource.get_buffer("/my.bufferc");
|
|
152
|
+
*
|
|
140
153
|
* // retrieve a metadata entry named "somefloats" and its numeric type
|
|
141
154
|
* const [values, type] = buffer.get_metadata(buf, hash("somefloats"));
|
|
142
155
|
* if (values) print(`${values.length} values in 'somefloats'`);
|
|
143
156
|
* ```
|
|
144
157
|
*/
|
|
145
|
-
function get_metadata(buf: Opaque<"buffer">, metadata_name: Hash | string): LuaMultiReturn<[number[] | undefined,
|
|
158
|
+
function get_metadata(buf: Opaque<"buffer">, metadata_name: Hash | string): LuaMultiReturn<[number[] | undefined, buffer.ValueType | undefined]>;
|
|
146
159
|
/**
|
|
147
160
|
* Get a specified stream from a buffer.
|
|
148
161
|
*
|
|
@@ -150,7 +163,7 @@ declare global {
|
|
|
150
163
|
* @param stream_name - the stream name
|
|
151
164
|
* @returns the data stream
|
|
152
165
|
*/
|
|
153
|
-
function get_stream(buffer: Opaque<"buffer">, stream_name: Hash | string): Opaque<"bufferstream"> & { [index: number]: number };
|
|
166
|
+
function get_stream(buffer: Opaque<"buffer">, stream_name: Hash | string): Opaque<"bufferstream"> & { [index: number]: number; length: LuaLengthMethod<number> };
|
|
154
167
|
/**
|
|
155
168
|
* Creates or updates a metadata array entry on a buffer.
|
|
156
169
|
* The value type and count given when updating the entry should match those used when first creating it.
|
|
@@ -162,6 +175,8 @@ declare global {
|
|
|
162
175
|
* @example
|
|
163
176
|
* ```ts
|
|
164
177
|
* // How to set a metadata entry on a buffer
|
|
178
|
+
* const buf = resource.get_buffer("/my.bufferc");
|
|
179
|
+
*
|
|
165
180
|
* // create a new metadata entry with three floats
|
|
166
181
|
* buffer.set_metadata(buf, hash("somefloats"), [1.5, 3.2, 7.9], buffer.VALUE_TYPE_FLOAT32);
|
|
167
182
|
* // ...
|
|
@@ -169,7 +184,7 @@ declare global {
|
|
|
169
184
|
* buffer.set_metadata(buf, hash("somefloats"), [-2.5, 10.0, 32.2], buffer.VALUE_TYPE_FLOAT32);
|
|
170
185
|
* ```
|
|
171
186
|
*/
|
|
172
|
-
function set_metadata(buf: Opaque<"buffer">, metadata_name: Hash | string, values: number[], value_type:
|
|
187
|
+
function set_metadata(buf: Opaque<"buffer">, metadata_name: Hash | string, values: number[], value_type: buffer.ValueType): void;
|
|
173
188
|
}
|
|
174
189
|
}
|
|
175
190
|
|
|
@@ -47,6 +47,7 @@ declare global {
|
|
|
47
47
|
* @returns a table with all camera URLs
|
|
48
48
|
* @example
|
|
49
49
|
* ```ts
|
|
50
|
+
* const predicate = render.predicate([hash("my_tag")]);
|
|
50
51
|
* for (const camera_id of camera.get_cameras()) {
|
|
51
52
|
* render.set_camera(camera_id);
|
|
52
53
|
* render.draw(predicate);
|
|
@@ -136,7 +137,7 @@ declare global {
|
|
|
136
137
|
* export default defineScript({
|
|
137
138
|
* on_input(self, action_id, action) {
|
|
138
139
|
* if (action_id === hash("touch")) {
|
|
139
|
-
* if (action.pressed) {
|
|
140
|
+
* if (action.pressed && action.screen_x !== undefined && action.screen_y !== undefined) {
|
|
140
141
|
* const perspective_camera = msg.url("#perspective_camera");
|
|
141
142
|
* const random_z = math.random(
|
|
142
143
|
* camera.get_near_z(perspective_camera) + 0.01,
|
|
@@ -168,7 +169,7 @@ declare global {
|
|
|
168
169
|
* export default defineScript({
|
|
169
170
|
* on_input(self, action_id, action) {
|
|
170
171
|
* if (action_id === hash("touch")) {
|
|
171
|
-
* if (action.pressed) {
|
|
172
|
+
* if (action.pressed && action.screen_x !== undefined && action.screen_y !== undefined) {
|
|
172
173
|
* const world_position = camera.screen_xy_to_world(action.screen_x, action.screen_y);
|
|
173
174
|
* go.set_position(world_position, "/go1");
|
|
174
175
|
* }
|
|
@@ -7,6 +7,7 @@ declare global {
|
|
|
7
7
|
* used to dynamically spawn collections into the runtime.
|
|
8
8
|
*/
|
|
9
9
|
namespace collectionfactory {
|
|
10
|
+
type Status = typeof collectionfactory.STATUS_UNLOADED | typeof collectionfactory.STATUS_LOADING | typeof collectionfactory.STATUS_LOADED;
|
|
10
11
|
/**
|
|
11
12
|
* loaded
|
|
12
13
|
*/
|
|
@@ -45,18 +46,17 @@ declare global {
|
|
|
45
46
|
* ```ts
|
|
46
47
|
* // How to spawn a collection of game objects:
|
|
47
48
|
* export default defineScript({
|
|
48
|
-
* init(
|
|
49
|
+
* init() {
|
|
49
50
|
* // Spawn a small group of enemies.
|
|
50
51
|
* const pos = vmath.vector3(100, 12.5, 0);
|
|
51
52
|
* const rot = vmath.quat_rotation_z(Math.PI / 2);
|
|
52
53
|
* const scale = 0.5;
|
|
53
|
-
* const props =
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
* };
|
|
54
|
+
* const props = new LuaMap<Hash, Record<string, unknown>>();
|
|
55
|
+
* props.set(hash("/enemy_leader"), { health: 1000.0 });
|
|
56
|
+
* props.set(hash("/enemy_1"), { health: 200.0 });
|
|
57
|
+
* props.set(hash("/enemy_2"), { health: 400.0, color: hash("green") });
|
|
58
58
|
*
|
|
59
|
-
*
|
|
59
|
+
* const enemy_ids = collectionfactory.create("#enemyfactory", pos, rot, props, scale);
|
|
60
60
|
* // enemy_ids now map to the spawned instance ids:
|
|
61
61
|
* //
|
|
62
62
|
* // pprint(self.enemy_ids)
|
|
@@ -69,16 +69,21 @@ declare global {
|
|
|
69
69
|
* // }
|
|
70
70
|
*
|
|
71
71
|
* // Send "attack" message to the leader. First look up its instance id.
|
|
72
|
-
* const leader_id =
|
|
73
|
-
*
|
|
72
|
+
* const leader_id = enemy_ids.get(hash("/enemy_leader"));
|
|
73
|
+
* if (leader_id !== undefined) {
|
|
74
|
+
* msg.post(leader_id, "attack");
|
|
75
|
+
* }
|
|
76
|
+
* return { enemy_ids };
|
|
74
77
|
* },
|
|
75
78
|
* });
|
|
76
79
|
*
|
|
77
80
|
* // How to delete a spawned collection:
|
|
78
|
-
*
|
|
81
|
+
* function delete_enemies(self: { enemy_ids: Hash[] }) {
|
|
82
|
+
* go.delete(self.enemy_ids);
|
|
83
|
+
* }
|
|
79
84
|
* ```
|
|
80
85
|
*/
|
|
81
|
-
function create(url: string | Hash | Url, position?: Vector3, rotation?: Quaternion, properties?: Record<string | number, unknown
|
|
86
|
+
function create(url: string | Hash | Url, position?: Vector3, rotation?: Quaternion, properties?: LuaMap<Hash, Record<string | number, unknown>> | Record<string, Record<string | number, unknown>>, scale?: number | Vector3): LuaMap<Hash, Hash>;
|
|
82
87
|
/**
|
|
83
88
|
* This returns status of the collection factory.
|
|
84
89
|
* Calling this function when the factory is not marked as dynamic loading always returns COMP_COLLECTION_FACTORY_STATUS_LOADED.
|
|
@@ -92,7 +97,7 @@ declare global {
|
|
|
92
97
|
*
|
|
93
98
|
* - `collectionfactory.STATUS_LOADED`
|
|
94
99
|
*/
|
|
95
|
-
function get_status(url?: string | Hash | Url):
|
|
100
|
+
function get_status(url?: string | Hash | Url): collectionfactory.Status;
|
|
96
101
|
/**
|
|
97
102
|
* Resources loaded are referenced by the collection factory component until the existing (parent) collection is destroyed or collectionfactory.unload is called.
|
|
98
103
|
* Calling this function when the factory is not marked as dynamic loading does nothing.
|
|
@@ -32,7 +32,7 @@ declare global {
|
|
|
32
32
|
* collection was not excluded.
|
|
33
33
|
* @example
|
|
34
34
|
* ```ts
|
|
35
|
-
* function print_resources(self, cproxy) {
|
|
35
|
+
* function print_resources(self: unknown, cproxy: Url) {
|
|
36
36
|
* const resources = collectionproxy.get_resources(cproxy);
|
|
37
37
|
* for (const v of resources) {
|
|
38
38
|
* print(`Resource: ${v}`);
|
|
@@ -299,7 +299,7 @@ declare global {
|
|
|
299
299
|
* compute.set_textures("/my_compute.computec", { my_texture: resource.texture() });
|
|
300
300
|
* ```
|
|
301
301
|
*/
|
|
302
|
-
function set_textures(path: Hash | string, textures: LuaMap<string, Hash>): void;
|
|
302
|
+
function set_textures(path: Hash | string, textures: LuaMap<string, Hash> | Record<string, Hash>): void;
|
|
303
303
|
}
|
|
304
304
|
}
|
|
305
305
|
|
|
@@ -7,6 +7,7 @@ declare global {
|
|
|
7
7
|
* dynamically spawn game objects into the runtime.
|
|
8
8
|
*/
|
|
9
9
|
namespace factory {
|
|
10
|
+
type Status = typeof factory.STATUS_UNLOADED | typeof factory.STATUS_LOADING | typeof factory.STATUS_LOADED;
|
|
10
11
|
/**
|
|
11
12
|
* loaded
|
|
12
13
|
*/
|
|
@@ -71,7 +72,7 @@ declare global {
|
|
|
71
72
|
*
|
|
72
73
|
* - `factory.STATUS_LOADED`
|
|
73
74
|
*/
|
|
74
|
-
function get_status(url?: string | Hash | Url):
|
|
75
|
+
function get_status(url?: string | Hash | Url): factory.Status;
|
|
75
76
|
/**
|
|
76
77
|
* Resources are referenced by the factory component until the existing (parent) collection is destroyed or factory.unload is called.
|
|
77
78
|
* Calling this function when the factory is not marked as dynamic loading does nothing.
|