@ts-defold/types 1.2.73 → 1.2.74

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 (2) hide show
  1. package/index.d.ts +122 -36
  2. package/package.json +1 -1
package/index.d.ts CHANGED
@@ -3,8 +3,35 @@
3
3
  /// <reference types="lua-types/5.1" />
4
4
  /// <reference types="lua-types/special/jit-only" />
5
5
 
6
- // DEFOLD. stable version 1.11.0 (7c81792859a6da7f7401c0ac37a4cc83bb500ff6)
6
+ // DEFOLD. stable version 1.11.1 (758dfc0ea71dca26d169fddd0c5a1bc6dd0be4b3)
7
7
 
8
+ /**
9
+ * All ids in the engine are represented as hashes, so a string needs to be hashed
10
+ before it can be compared with an id.
11
+ * @param s string to hash
12
+ * @returns a hashed string
13
+ * @example To compare a message_id in an on-message callback function:
14
+ ```lua
15
+ function on_message(self, message_id, message, sender)
16
+ if message_id == hash("my_message") then
17
+ -- Act on the message here
18
+ end
19
+ end
20
+ ```
21
+ */
22
+ declare function hash(s: string): hash;
23
+ /**
24
+ * Returns a hexadecimal representation of a hash value.
25
+ The returned string is always padded with leading zeros.
26
+ * @param h hash value to get hex string for
27
+ * @returns hex representation of the hash
28
+ * @example ```lua
29
+ local h = hash("my_hash")
30
+ local hexstr = hash_to_hex(h)
31
+ print(hexstr) --> a2bc06d97f580aab
32
+ ```
33
+ */
34
+ declare function hash_to_hex(h: hash): string;
8
35
  /**
9
36
  * Pretty printing of Lua values. This function prints Lua values
10
37
  in a manner similar to +print()+, but will also recurse into tables
@@ -34,33 +61,6 @@ Lua tables is undefined):
34
61
  ```
35
62
  */
36
63
  declare function pprint(...v: any[]): void;
37
- /**
38
- * All ids in the engine are represented as hashes, so a string needs to be hashed
39
- before it can be compared with an id.
40
- * @param s string to hash
41
- * @returns a hashed string
42
- * @example To compare a message_id in an on-message callback function:
43
- ```lua
44
- function on_message(self, message_id, message, sender)
45
- if message_id == hash("my_message") then
46
- -- Act on the message here
47
- end
48
- end
49
- ```
50
- */
51
- declare function hash(s: string): hash;
52
- /**
53
- * Returns a hexadecimal representation of a hash value.
54
- The returned string is always padded with leading zeros.
55
- * @param h hash value to get hex string for
56
- * @returns hex representation of the hash
57
- * @example ```lua
58
- local h = hash("my_hash")
59
- local hexstr = hash_to_hex(h)
60
- print(hexstr) --> a2bc06d97f580aab
61
- ```
62
- */
63
- declare function hash_to_hex(h: hash): string;
64
64
  /**
65
65
  * A unique identifier used to reference resources, messages, properties, and other entities within the game.
66
66
  */
@@ -546,6 +546,20 @@ export function set_metadata(buf: buffer, metadata_name: hash | string, values:
546
546
  }
547
547
 
548
548
  declare namespace camera {
549
+ /**
550
+ * Computes zoom so the original display area covers the entire window while preserving aspect ratio.
551
+ Equivalent to using max(window_width/width, window_height/height).
552
+ */
553
+ export const ORTHO_MODE_AUTO_COVER: number;
554
+ /**
555
+ * Computes zoom so the original display area (game.project width/height) fits inside the window
556
+ while preserving aspect ratio. Equivalent to using min(window_width/width, window_height/height).
557
+ */
558
+ export const ORTHO_MODE_AUTO_FIT: number;
559
+ /**
560
+ * Uses the manually set orthographic zoom value (camera.set_orthographic_zoom).
561
+ */
562
+ export const ORTHO_MODE_FIXED: number;
549
563
  /**
550
564
  * Gets the effective aspect ratio of the camera. If auto aspect ratio is enabled,
551
565
  returns the aspect ratio calculated from the current render target dimensions.
@@ -598,6 +612,13 @@ export function get_fov(camera: url | number | undefined): number;
598
612
  * @returns the near z.
599
613
  */
600
614
  export function get_near_z(camera: url | number | undefined): number;
615
+ /**
616
+ * get orthographic zoom mode
617
+ * @param camera camera id
618
+ * @returns one of camera.ORTHO_MODE_FIXED, camera.ORTHO_MODE_AUTO_FIT or
619
+ camera.ORTHO_MODE_AUTO_COVER
620
+ */
621
+ export function get_orthographic_mode(camera: url | number | undefined): number;
601
622
  /**
602
623
  * get orthographic zoom
603
624
  * @param camera camera id
@@ -650,6 +671,12 @@ export function set_fov(camera: url | number | undefined, fov: number): void;
650
671
  * @param near_z the near z.
651
672
  */
652
673
  export function set_near_z(camera: url | number | undefined, near_z: number): void;
674
+ /**
675
+ * set orthographic zoom mode
676
+ * @param camera camera id
677
+ * @param mode camera.ORTHO_MODE_FIXED, camera.ORTHO_MODE_AUTO_FIT or camera.ORTHO_MODE_AUTO_COVER
678
+ */
679
+ export function set_orthographic_mode(camera: url | number | undefined, mode: number): void;
653
680
  /**
654
681
  * set orthographic zoom
655
682
  * @param camera camera id
@@ -1643,6 +1670,7 @@ local s = go.get_scale_uniform("x")
1643
1670
  export function get_scale_uniform(id?: string | hash | url): number;
1644
1671
  /**
1645
1672
  * The function will return the world position calculated at the end of the previous frame.
1673
+ To recalculate it within the current frame, use go.update_world_transform on the instance before calling this.
1646
1674
  Use go.get_position to retrieve the position relative to the parent.
1647
1675
  * @param id optional id of the game object instance to get the world position for, by default the instance of the calling script
1648
1676
  * @returns instance world position
@@ -1659,6 +1687,7 @@ local p = go.get_world_position("x")
1659
1687
  export function get_world_position(id?: string | hash | url): vmath.vector3;
1660
1688
  /**
1661
1689
  * The function will return the world rotation calculated at the end of the previous frame.
1690
+ To recalculate it within the current frame, use go.update_world_transform on the instance before calling this.
1662
1691
  Use go.get_rotation to retrieve the rotation relative to the parent.
1663
1692
  * @param id optional id of the game object instance to get the world rotation for, by default the instance of the calling script
1664
1693
  * @returns instance world rotation
@@ -1675,6 +1704,7 @@ local r = go.get_world_rotation("x")
1675
1704
  export function get_world_rotation(id?: string | hash | url): vmath.quaternion;
1676
1705
  /**
1677
1706
  * The function will return the world 3D scale factor calculated at the end of the previous frame.
1707
+ To recalculate it within the current frame, use go.update_world_transform on the instance before calling this.
1678
1708
  Use go.get_scale to retrieve the 3D scale factor relative to the parent.
1679
1709
  This vector is derived by decomposing the transformation matrix and should be used with care.
1680
1710
  For most cases it should be fine to use go.get_world_scale_uniform instead.
@@ -1693,6 +1723,7 @@ local s = go.get_world_scale("x")
1693
1723
  export function get_world_scale(id?: string | hash | url): vmath.vector3;
1694
1724
  /**
1695
1725
  * The function will return the world scale factor calculated at the end of the previous frame.
1726
+ To recalculate it within the current frame, use go.update_world_transform on the instance before calling this.
1696
1727
  Use go.get_scale_uniform to retrieve the scale factor relative to the parent.
1697
1728
  * @param id optional id of the game object instance to get the world scale for, by default the instance of the calling script
1698
1729
  * @returns instance world scale factor
@@ -1709,6 +1740,7 @@ local s = go.get_world_scale_uniform("x")
1709
1740
  export function get_world_scale_uniform(id?: string | hash | url): number;
1710
1741
  /**
1711
1742
  * The function will return the world transform matrix calculated at the end of the previous frame.
1743
+ To recalculate it within the current frame, use go.update_world_transform on the instance before calling this.
1712
1744
  * @param id optional id of the game object instance to get the world transform for, by default the instance of the calling script
1713
1745
  * @returns instance world transform
1714
1746
  * @example Get the world transform of the game object instance the script is attached to:
@@ -2213,6 +2245,26 @@ end
2213
2245
  ```
2214
2246
  */
2215
2247
  export function update(this: LuaUserdata, dt: number): void;
2248
+ /**
2249
+ * Recalculates and updates the cached world transform immediately for the target instance
2250
+ and its ancestors (parent chain up to the collection root). Descendants (children) are
2251
+ not updated by this function.
2252
+ If no id is provided, the instance of the calling script is used.
2253
+ ⚠ Use this after changing local transform mid-frame when you need the
2254
+ new world transform right away (e.g. before end-of-frame updates). Note that child
2255
+ instances will still have last-frame world transforms until the regular update.
2256
+ * @param id optional id of the game object instance to update
2257
+ * @example Update this game object's world transform:
2258
+ ```lua
2259
+ go.update_world_transform()
2260
+ ```
2261
+
2262
+ Update another game object's world transform:
2263
+ ```lua
2264
+ go.update_world_transform("/other")
2265
+ ```
2266
+ */
2267
+ export function update_world_transform(id?: string | hash | url): void;
2216
2268
  /**
2217
2269
  * ⚠ The function uses world transformation calculated at the end of previous frame.
2218
2270
  * @param position position which need to be converted
@@ -2415,7 +2467,7 @@ export const TEXTURE_FORMAT_RGBA_16BPP: number;
2415
2467
  /**
2416
2468
  * May be nil if the graphics driver doesn't support it
2417
2469
  */
2418
- export let TEXTURE_FORMAT_RGBA_ASTC_4x4: number;
2470
+ export const TEXTURE_FORMAT_RGBA_ASTC_4X4: number;
2419
2471
  /**
2420
2472
  * May be nil if the graphics driver doesn't support it
2421
2473
  */
@@ -3344,6 +3396,12 @@ export function get_layer(node: node): hash;
3344
3396
  * @returns layout id
3345
3397
  */
3346
3398
  export function get_layout(): hash;
3399
+ /**
3400
+ * Returns a table mapping each layout id hash to a vector3(width, height, 0). For the default layout,
3401
+ the current scene resolution is returned. If a layout name is not present in the Display Profiles (or when
3402
+ no display profiles are assigned), the width/height pair is 0.
3403
+ */
3404
+ export function get_layouts(): LuaMap<hash, vmath.vector3>;
3347
3405
  /**
3348
3406
  * Returns the leading value for a text node.
3349
3407
  * @param node node from where to get the leading
@@ -4279,6 +4337,14 @@ export function set_inner_radius(node: node, radius: number): void;
4279
4337
  * @param layer layer id
4280
4338
  */
4281
4339
  export function set_layer(node: node, layer: string | hash): void;
4340
+ /**
4341
+ * Applies a named layout on the GUI scene. This re-applies per-layout node descriptors
4342
+ and, if a matching Display Profile exists, updates the scene resolution. Emits
4343
+ the "layout_changed" message to the scene script when the layout actually changes.
4344
+ * @param layout the layout id to apply
4345
+ * @returns true if the layout exists in the scene and was applied, false otherwise
4346
+ */
4347
+ export function set_layout(layout: string | hash): boolean;
4282
4348
  /**
4283
4349
  * Sets the leading value for a text node. This value is used to
4284
4350
  scale the line spacing of text.
@@ -6237,6 +6303,18 @@ declare namespace render {
6237
6303
  export const FRUSTUM_PLANES_ALL: number;
6238
6304
  export const FRUSTUM_PLANES_SIDES: number;
6239
6305
  export const RENDER_TARGET_DEFAULT: number;
6306
+ /**
6307
+ * Depth sort far-to-near (default; good for transparent passes).
6308
+ */
6309
+ export const SORT_BACK_TO_FRONT: number;
6310
+ /**
6311
+ * Depth sort near-to-far (good for opaque passes to reduce overdraw).
6312
+ */
6313
+ export const SORT_FRONT_TO_BACK: number;
6314
+ /**
6315
+ * No per-call sorting; draw entries in insertion order.
6316
+ */
6317
+ export const SORT_NONE: number;
6240
6318
  /**
6241
6319
  * Clear buffers in the currently enabled render target with specified value. If the render target has been created with multiple
6242
6320
  color attachments, all buffers will be cleared with the same value.
@@ -6405,6 +6483,8 @@ render.FRUSTUM_PLANES_ALL : All 6 sides of the frustum.
6405
6483
 
6406
6484
  `constants`
6407
6485
  constant_buffer optional constants to use while rendering
6486
+ `sort_order`
6487
+ int How to sort draw order for world-ordered entries. Default uses the renderer's preferred world sorting (back-to-front).
6408
6488
 
6409
6489
  * @example ```lua
6410
6490
  function init(self)
@@ -7527,6 +7607,7 @@ export function create_atlas(path: string, table: { texture: string | hash; anim
7527
7607
  height: number;
7528
7608
  pivot_x: number;
7529
7609
  pivot_y: number;
7610
+ rotated: boolean;
7530
7611
  vertices: number[] | LuaSet<number>;
7531
7612
  uvs: number[] | LuaSet<number>;
7532
7613
  indices: number[] | LuaSet<number>;
@@ -7671,7 +7752,7 @@ These constants might not be available on the device:
7671
7752
  `graphics.TEXTURE_FORMAT_RGBA_PVRTC_4BPPV1`
7672
7753
  `graphics.TEXTURE_FORMAT_RGB_ETC1`
7673
7754
  `graphics.TEXTURE_FORMAT_RGBA_ETC2`
7674
- `graphics.TEXTURE_FORMAT_RGBA_ASTC_4x4`
7755
+ `graphics.TEXTURE_FORMAT_RGBA_ASTC_4X4`
7675
7756
  `graphics.TEXTURE_FORMAT_RGB_BC1`
7676
7757
  `graphics.TEXTURE_FORMAT_RGBA_BC3`
7677
7758
  `graphics.TEXTURE_FORMAT_R_BC4`
@@ -7841,7 +7922,7 @@ These constants might not be available on the device:
7841
7922
  `graphics.TEXTURE_FORMAT_RGBA_PVRTC_4BPPV1`
7842
7923
  `graphics.TEXTURE_FORMAT_RGB_ETC1`
7843
7924
  `graphics.TEXTURE_FORMAT_RGBA_ETC2`
7844
- `graphics.TEXTURE_FORMAT_RGBA_ASTC_4x4`
7925
+ `graphics.TEXTURE_FORMAT_RGBA_ASTC_4X4`
7845
7926
  `graphics.TEXTURE_FORMAT_RGB_BC1`
7846
7927
  `graphics.TEXTURE_FORMAT_RGBA_BC3`
7847
7928
  `graphics.TEXTURE_FORMAT_R_BC4`
@@ -7883,6 +7964,7 @@ Creating an empty texture with no buffer data is not supported as a core feature
7883
7964
  `COMPRESSION_TYPE_BASIS_UASTC`
7884
7965
 
7885
7966
  * @param buffer optional buffer of precreated pixel data
7967
+ * @param callback callback function when texture is created (self, request_id, resource)
7886
7968
  * @example Create a texture resource asyncronously with a buffer and a callback
7887
7969
  ```lua
7888
7970
  function callback(self, request_id, resource)
@@ -7955,7 +8037,7 @@ function init(self)
7955
8037
  end
7956
8038
  ```
7957
8039
  */
7958
- export function create_texture_async(path: string | hash, table: { type: number; width: number; height: number; depth: number; format: number; flags: number; max_mipmaps?: number; compression_type?: number }, buffer?: buffer): LuaMultiReturn<[hash, number]>;
8040
+ export function create_texture_async(path: string | hash, table: { type: number; width: number; height: number; depth: number; format: number; flags: number; max_mipmaps?: number; compression_type?: number }, buffer: buffer, callback?: (this: any, request_id: number, resource: hash) => void): LuaMultiReturn<[hash, number]>;
7959
8041
  /**
7960
8042
  * Constructor-like function with two purposes:
7961
8043
 
@@ -8516,7 +8598,7 @@ These constants might not be available on the device:
8516
8598
  - `graphics.TEXTURE_FORMAT_RGBA_PVRTC_4BPPV1`
8517
8599
  - `graphics.TEXTURE_FORMAT_RGB_ETC1`
8518
8600
  - `graphics.TEXTURE_FORMAT_RGBA_ETC2`
8519
- - `graphics.TEXTURE_FORMAT_RGBA_ASTC_4x4`
8601
+ - `graphics.TEXTURE_FORMAT_RGBA_ASTC_4X4`
8520
8602
  - `graphics.TEXTURE_FORMAT_RGB_BC1`
8521
8603
  - `graphics.TEXTURE_FORMAT_RGBA_BC3`
8522
8604
  - `graphics.TEXTURE_FORMAT_R_BC4`
@@ -9610,6 +9692,10 @@ number sound gain between 0 and 1, default is 1. The final gain of the sound wil
9610
9692
  number sound pan between -1 and 1, default is 0. The final pan of the sound will be an addition of this pan and the sound pan.
9611
9693
  `speed`
9612
9694
  number sound speed where 1.0 is normal speed, 0.5 is half speed and 2.0 is double speed. The final speed of the sound will be a multiplication of this speed and the sound speed.
9695
+ `start_time`
9696
+ number start playback offset (seconds). Optional, mutually exclusive with `start_frame`.
9697
+ `start_frame`
9698
+ number start playback offset (frames/samples). Optional, mutually exclusive with `start_time`. If both are provided, `start_frame` is used.
9613
9699
 
9614
9700
  * @param complete_function function to call when the sound has finished playing or stopped manually via sound.stop.
9615
9701
 
@@ -9647,7 +9733,7 @@ function init(self)
9647
9733
  end
9648
9734
  ```
9649
9735
  */
9650
- export function play(url: string | hash | url, play_properties?: { delay?: number; gain?: number; pan?: number; speed?: number }, complete_function?: (this: any, message_id: hash, message: { play_id: number }, sender: url,) => void): number;
9736
+ export function play(url: string | hash | url, play_properties?: { delay?: number; gain?: number; pan?: number; speed?: number; start_time?: number; start_frame?: number }, complete_function?: (this: any, message_id: hash, message: { play_id: number }, sender: url,) => void): number;
9651
9737
  /**
9652
9738
  * Set gain on all active playing voices of a sound.
9653
9739
  * @param url the sound to set the gain of
@@ -10040,8 +10126,8 @@ print(my_file_path) --> /home/foobar/.local/share/my_game/my_file
10040
10126
  -- Android package name: com.foobar.packagename
10041
10127
  print(my_file_path) --> /data/data/0/com.foobar.packagename/files/my_file
10042
10128
 
10043
- -- iOS: /var/mobile/Containers/Data/Application/123456AB-78CD-90DE-12345678ABCD/my_game/my_file
10044
- print(my_file_path) --> /var/containers/Bundle/Applications/123456AB-78CD-90DE-12345678ABCD/my_game.app
10129
+ -- iOS: my_game.app
10130
+ print(my_file_path) --> /var/mobile/Containers/Data/Application/123456AB-78CD-90DE-12345678ABCD/my_game/my_file
10045
10131
 
10046
10132
  -- HTML5 path inside the IndexedDB: /data/.my_game/my_file or /.my_game/my_file
10047
10133
  print(my_file_path) --> /data/.my_game/my_file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ts-defold/types",
3
- "version": "1.2.73",
3
+ "version": "1.2.74",
4
4
  "description": "TypeScript definitions for Defold",
5
5
  "repository": "github:ts-defold/types",
6
6
  "keywords": [