@ts-defold/types 1.2.77 → 1.2.79
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/index.d.ts +148 -72
- 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.12.
|
|
6
|
+
// DEFOLD. stable version 1.12.2 (e43be333aa7a4fc319ab62adc8d405c8e98bf92f)
|
|
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
|
*/
|
|
@@ -83,33 +83,6 @@ declare type buffer = object;
|
|
|
83
83
|
declare type bufferstream = LuaUserdata & number[] & object;
|
|
84
84
|
|
|
85
85
|
|
|
86
|
-
declare namespace missingName {
|
|
87
|
-
/**
|
|
88
|
-
* Enables engine throttling.
|
|
89
|
-
* @param enable true if throttling should be enabled
|
|
90
|
-
* @param cooldown the time period to do update + render for (seconds)
|
|
91
|
-
* @example Disable throttling
|
|
92
|
-
```lua
|
|
93
|
-
sys.set_engine_throttle(false)
|
|
94
|
-
```
|
|
95
|
-
|
|
96
|
-
Enable throttling
|
|
97
|
-
```lua
|
|
98
|
-
sys.set_engine_throttle(true, 1.5)
|
|
99
|
-
```
|
|
100
|
-
*/
|
|
101
|
-
export function set_engine_throttle(enable: boolean, cooldown: number): void;
|
|
102
|
-
/**
|
|
103
|
-
* Disables rendering
|
|
104
|
-
* @param enable true if throttling should be enabled
|
|
105
|
-
* @example Disable rendering
|
|
106
|
-
```lua
|
|
107
|
-
sys.set_render_enable(false)
|
|
108
|
-
```
|
|
109
|
-
*/
|
|
110
|
-
export function set_render_enable(enable: boolean): void;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
86
|
declare namespace b2d {
|
|
114
87
|
/**
|
|
115
88
|
* Get the Box2D body from a collision object
|
|
@@ -1630,6 +1603,7 @@ export function fixed_update(this: LuaUserdata, dt: number): void;
|
|
|
1630
1603
|
* @param options optional options table
|
|
1631
1604
|
- index number index into array property (1 based)
|
|
1632
1605
|
- key hash name of internal property
|
|
1606
|
+
- keys table array of internal component resources identified by key (e.g. a particle fx emitter, see examples below)
|
|
1633
1607
|
* @example Get a property "speed" from a script "player", the property must be declared in the player-script:
|
|
1634
1608
|
```lua
|
|
1635
1609
|
go.property("speed", 50)
|
|
@@ -1656,18 +1630,21 @@ Getting all values in a material property array as a table
|
|
|
1656
1630
|
-- get all vector4's in the constant array
|
|
1657
1631
|
go.get(url, "example")
|
|
1658
1632
|
-- result: { vector4, vector4, ... }
|
|
1659
|
-
|
|
1660
1633
|
-- get all elements of the vector4's from an array
|
|
1661
1634
|
go.get(url, "example.x")
|
|
1662
1635
|
-- result: { number1, number2, ... }
|
|
1663
1636
|
```Get a named property
|
|
1664
|
-
|
|
1665
1637
|
```lua
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1638
|
+
lua
|
|
1639
|
+
-- get the resource of a certain gui font
|
|
1640
|
+
local font_hash = go.get("#gui", "fonts", {key = "system_font_BIG"})```Get a property from a sub-component, using the "keys" options table
|
|
1641
|
+
```lua
|
|
1642
|
+
lua
|
|
1643
|
+
-- Addressing the first level of a component:
|
|
1644
|
+
go.get("#particlefx", "material", { keys = { "cone_emitter" } })```Get a property into a deeper sub-hierarchy (if the component supports it).
|
|
1645
|
+
```lua
|
|
1646
|
+
-- Note: There is currently no component that supports this, but a custom component could.
|
|
1647
|
+
go.get("#my_component", "some_property", { keys = { "root", "child_node" } })
|
|
1671
1648
|
*/
|
|
1672
1649
|
export function get(url: string | hash | url, property: string | hash, options?: object): unknown;
|
|
1673
1650
|
/**
|
|
@@ -1866,6 +1843,13 @@ end
|
|
|
1866
1843
|
```
|
|
1867
1844
|
*/
|
|
1868
1845
|
export function init(this: LuaUserdata): void;
|
|
1846
|
+
/**
|
|
1847
|
+
* This is a callback-function, which is called by the engine at the end of the frame to update the state of a script
|
|
1848
|
+
component. Use it to make final adjustments to the game object instance.
|
|
1849
|
+
* @param this reference to the script state to be used for storing data
|
|
1850
|
+
* @param dt the time-step of the frame update
|
|
1851
|
+
*/
|
|
1852
|
+
export function late_update(this: LuaUserdata, dt: number): void;
|
|
1869
1853
|
/**
|
|
1870
1854
|
* This is a callback-function, which is called by the engine when user input is sent to the game object instance of the script.
|
|
1871
1855
|
It can be used to take action on the input, e.g. move the instance according to the input.
|
|
@@ -2193,6 +2177,7 @@ export function property(name: string, value: number | hash | url | vmath.vector
|
|
|
2193
2177
|
* @param options optional options table
|
|
2194
2178
|
- index integer index into array property (1 based)
|
|
2195
2179
|
- key hash name of internal property
|
|
2180
|
+
- keys table array of internal component resources identified by key (e.g. a particle fx emitter, see examples below)
|
|
2196
2181
|
* @example Set a property "speed" of a script "player", the property must be declared in the player-script:
|
|
2197
2182
|
```lua
|
|
2198
2183
|
go.property("speed", 50)
|
|
@@ -2216,18 +2201,25 @@ go.set(url, "example.x", 7, {index=1})
|
|
|
2216
2201
|
|
|
2217
2202
|
Set a material property array by a table of vector4
|
|
2218
2203
|
```lua
|
|
2204
|
+
lua
|
|
2219
2205
|
-- set the first two vector4's in the array
|
|
2220
2206
|
-- if the array has more than two elements in the array they will not be set
|
|
2221
|
-
go.set(url, "example", { vmath.vector4(1,1,1,1), vmath.vector4(2,2,2,2) })
|
|
2222
|
-
```Set a named property
|
|
2223
|
-
|
|
2207
|
+
go.set(url, "example", { vmath.vector4(1,1,1,1), vmath.vector4(2,2,2,2) })```Set a named property
|
|
2224
2208
|
```lua
|
|
2225
2209
|
go.property("big_font", resource.font())
|
|
2226
|
-
|
|
2227
2210
|
function init(self)
|
|
2228
2211
|
go.set("#gui", "fonts", self.big_font, {key = "system_font_BIG"})
|
|
2229
2212
|
end
|
|
2230
|
-
```
|
|
2213
|
+
```Set a property on a sub-component, using the "keys" options table
|
|
2214
|
+
```lua
|
|
2215
|
+
lua
|
|
2216
|
+
go.property("my_material", resource.material)
|
|
2217
|
+
function init(self)
|
|
2218
|
+
go.set("#particlefx", "material", self.my_material, { keys = { "cone_emitter" } })
|
|
2219
|
+
end```Set a property in a deeper sub-hierarchy (if the component supports it).
|
|
2220
|
+
```lua
|
|
2221
|
+
-- Note: There is currently no component that supports this, but a custom component could.
|
|
2222
|
+
go.set("#my_component", "some_property", some_value, { keys = { "root", "child_node" } })
|
|
2231
2223
|
*/
|
|
2232
2224
|
export function set(url: string | hash | url, property: string | hash, value: number | boolean | hash | url | vmath.vector3 | vmath.vector4 | vmath.quaternion | any, options?: object): void;
|
|
2233
2225
|
/**
|
|
@@ -2411,8 +2403,10 @@ export type input_message = {
|
|
|
2411
2403
|
gamepad?: number;
|
|
2412
2404
|
touch?: touch_input[];
|
|
2413
2405
|
};
|
|
2406
|
+
export type late_update = (this: any, dt: number) => void;
|
|
2414
2407
|
export type on_input = (this: any, action_id: hash, action: go.input_message) => void;
|
|
2415
2408
|
export type on_message = (this: any, message_id: hash, message: object, sender: url) => void;
|
|
2409
|
+
export type on_reload = (this: any) => void;
|
|
2416
2410
|
export type touch_input = {
|
|
2417
2411
|
id: number;
|
|
2418
2412
|
pressed: boolean;
|
|
@@ -3026,6 +3020,22 @@ export const RESULT_OUT_OF_RESOURCES: number;
|
|
|
3026
3020
|
* The texture id already exists when trying to use gui.new_texture().
|
|
3027
3021
|
*/
|
|
3028
3022
|
export const RESULT_TEXTURE_ALREADY_EXISTS: number;
|
|
3023
|
+
/**
|
|
3024
|
+
* Safe area mode that applies insets on all edges.
|
|
3025
|
+
*/
|
|
3026
|
+
export const SAFE_AREA_BOTH: number;
|
|
3027
|
+
/**
|
|
3028
|
+
* Safe area mode that applies insets only on the long edges.
|
|
3029
|
+
*/
|
|
3030
|
+
export const SAFE_AREA_LONG: number;
|
|
3031
|
+
/**
|
|
3032
|
+
* Safe area mode that ignores safe area insets.
|
|
3033
|
+
*/
|
|
3034
|
+
export const SAFE_AREA_NONE: number;
|
|
3035
|
+
/**
|
|
3036
|
+
* Safe area mode that applies insets only on the short edges.
|
|
3037
|
+
*/
|
|
3038
|
+
export const SAFE_AREA_SHORT: number;
|
|
3029
3039
|
/**
|
|
3030
3040
|
* The size of the node is determined by the currently assigned texture.
|
|
3031
3041
|
*/
|
|
@@ -3058,7 +3068,7 @@ export const TYPE_TEXT: number;
|
|
|
3058
3068
|
* This starts an animation of a node property according to the specified parameters.
|
|
3059
3069
|
If the node property is already being animated, that animation will be canceled and
|
|
3060
3070
|
replaced by the new one. Note however that several different node properties
|
|
3061
|
-
can be animated simultaneously. Use `gui.
|
|
3071
|
+
can be animated simultaneously. Use `gui.cancel_animations` to stop the animation
|
|
3062
3072
|
before it has completed.
|
|
3063
3073
|
Composite properties of type vector3, vector4 or quaternion
|
|
3064
3074
|
also expose their sub-components (x, y, z and w).
|
|
@@ -4569,6 +4579,17 @@ The rotation is expressed as a quaternion
|
|
|
4569
4579
|
* @param rotation new rotation
|
|
4570
4580
|
*/
|
|
4571
4581
|
export function set_rotation(node: node, rotation: vmath.quaternion | vmath.vector4): void;
|
|
4582
|
+
/**
|
|
4583
|
+
* Sets how the safe area is applied to this gui scene.
|
|
4584
|
+
* @param mode safe area mode
|
|
4585
|
+
|
|
4586
|
+
`gui.SAFE_AREA_NONE`
|
|
4587
|
+
`gui.SAFE_AREA_LONG`
|
|
4588
|
+
`gui.SAFE_AREA_SHORT`
|
|
4589
|
+
`gui.SAFE_AREA_BOTH`
|
|
4590
|
+
|
|
4591
|
+
*/
|
|
4592
|
+
export function set_safe_area_mode(mode: number): void;
|
|
4572
4593
|
/**
|
|
4573
4594
|
* Sets the scaling of the supplied node.
|
|
4574
4595
|
* @param node node to set the scale for
|
|
@@ -4803,6 +4824,7 @@ export type final = (this: any) => void;
|
|
|
4803
4824
|
export type init = (this: any) => void;
|
|
4804
4825
|
export type on_input = (this: any, action_id: hash, action: go.input_message) => void;
|
|
4805
4826
|
export type on_message = (this: any, message_id: hash, message: object, sender: url) => void;
|
|
4827
|
+
export type on_reload = (this: any) => void;
|
|
4806
4828
|
export type update = (this: any, dt: number) => void;
|
|
4807
4829
|
}
|
|
4808
4830
|
|
|
@@ -4900,7 +4922,7 @@ function init(self)
|
|
|
4900
4922
|
end
|
|
4901
4923
|
```
|
|
4902
4924
|
*/
|
|
4903
|
-
export function request(url: string, method: string, callback: ((this: any, id: any, response: any) => void), headers?: { [key: string]: string | number }, post_data?: string, options?: { timeout?: number; path?: string; ignore_cache?: boolean; chunked_transfer?: boolean; report_progress?: boolean }): void;
|
|
4925
|
+
export function request(url: string, method: string, callback: ((this: any, id: any, response: any) => void), headers?: { [key: string]: string | number }, post_data?: string, options?: { timeout?: number; path?: string; ignore_cache?: boolean; chunked_transfer?: boolean; report_progress?: boolean; proxy?: string }): void;
|
|
4904
4926
|
}
|
|
4905
4927
|
|
|
4906
4928
|
declare namespace image {
|
|
@@ -6012,7 +6034,7 @@ end
|
|
|
6012
6034
|
*/
|
|
6013
6035
|
export function raycast_async(from: vmath.vector3, to: vmath.vector3, groups: hash[] | LuaSet<hash>, request_id?: number): void;
|
|
6014
6036
|
/**
|
|
6015
|
-
*
|
|
6037
|
+
* Only one physics world event listener can be set at a time.
|
|
6016
6038
|
* @param callback A callback that receives an information about all the physics interactions in this physics world.
|
|
6017
6039
|
|
|
6018
6040
|
`self`
|
|
@@ -6785,7 +6807,7 @@ function update(self, dt)
|
|
|
6785
6807
|
end
|
|
6786
6808
|
```
|
|
6787
6809
|
*/
|
|
6788
|
-
export function enable_texture(binding: number | string | hash, handle_or_name: number | string | hash, buffer_type?:
|
|
6810
|
+
export function enable_texture(binding: number | string | hash, handle_or_name: number | string | hash, buffer_type?: typeof graphics.BUFFER_TYPE_COLOR0_BIT | typeof graphics.BUFFER_TYPE_COLOR1_BIT | typeof graphics.BUFFER_TYPE_COLOR2_BIT | typeof graphics.BUFFER_TYPE_COLOR3_BIT | typeof graphics.BUFFER_TYPE_DEPTH_BIT | typeof graphics.BUFFER_TYPE_STENCIL_BIT): void;
|
|
6789
6811
|
/**
|
|
6790
6812
|
* Returns the logical window height that is set in the "game.project" settings.
|
|
6791
6813
|
Note that the actual window pixel size can change, either by device constraints
|
|
@@ -10513,6 +10535,21 @@ sys.set_connectivity_host("www.google.com")
|
|
|
10513
10535
|
```
|
|
10514
10536
|
*/
|
|
10515
10537
|
export function set_connectivity_host(host: string): void;
|
|
10538
|
+
/**
|
|
10539
|
+
* Enables engine throttling.
|
|
10540
|
+
* @param enable true if throttling should be enabled
|
|
10541
|
+
* @param cooldown the time period to do update + render for (seconds)
|
|
10542
|
+
* @example Disable throttling
|
|
10543
|
+
```lua
|
|
10544
|
+
sys.set_engine_throttle(false)
|
|
10545
|
+
```
|
|
10546
|
+
|
|
10547
|
+
Enable throttling
|
|
10548
|
+
```lua
|
|
10549
|
+
sys.set_engine_throttle(true, 1.5)
|
|
10550
|
+
```
|
|
10551
|
+
*/
|
|
10552
|
+
export function set_engine_throttle(enable: boolean, cooldown: number): void;
|
|
10516
10553
|
/**
|
|
10517
10554
|
* Set the Lua error handler function.
|
|
10518
10555
|
The error handler is a function which is called whenever a lua runtime error occurs.
|
|
@@ -10546,6 +10583,15 @@ end
|
|
|
10546
10583
|
```
|
|
10547
10584
|
*/
|
|
10548
10585
|
export function set_error_handler(error_handler: (source: string, message: string, traceback: string,) => void): void;
|
|
10586
|
+
/**
|
|
10587
|
+
* Disables rendering
|
|
10588
|
+
* @param enable true if throttling should be enabled
|
|
10589
|
+
* @example Disable rendering
|
|
10590
|
+
```lua
|
|
10591
|
+
sys.set_render_enable(false)
|
|
10592
|
+
```
|
|
10593
|
+
*/
|
|
10594
|
+
export function set_render_enable(enable: boolean): void;
|
|
10549
10595
|
/**
|
|
10550
10596
|
* Set game update-frequency (frame cap). This option is equivalent to `display.update_frequency` in
|
|
10551
10597
|
the "game.project" settings but set in run-time. If `Vsync` checked in "game.project", the rate will
|
|
@@ -11904,6 +11950,36 @@ export function get_display_scale(): number;
|
|
|
11904
11950
|
* @returns The lock state
|
|
11905
11951
|
*/
|
|
11906
11952
|
export function get_mouse_lock(): boolean;
|
|
11953
|
+
/**
|
|
11954
|
+
* This returns the safe area rectangle (x, y, width, height) and the inset
|
|
11955
|
+
values relative to the window edges. On platforms without a safe area,
|
|
11956
|
+
this returns the full window size and zero insets.
|
|
11957
|
+
* @returns safe area data
|
|
11958
|
+
|
|
11959
|
+
`safe_area`
|
|
11960
|
+
table table containing these keys:
|
|
11961
|
+
|
|
11962
|
+
|
|
11963
|
+
number `x`
|
|
11964
|
+
number `y`
|
|
11965
|
+
number `width`
|
|
11966
|
+
number `height`
|
|
11967
|
+
number `inset_left`
|
|
11968
|
+
number `inset_top`
|
|
11969
|
+
number `inset_right`
|
|
11970
|
+
number `inset_bottom`
|
|
11971
|
+
|
|
11972
|
+
*/
|
|
11973
|
+
export function get_safe_area(): {
|
|
11974
|
+
x: number,
|
|
11975
|
+
y: number,
|
|
11976
|
+
width: number,
|
|
11977
|
+
height: number,
|
|
11978
|
+
inset_left: number,
|
|
11979
|
+
inset_top: number,
|
|
11980
|
+
inset_right: number,
|
|
11981
|
+
inset_bottom: number,
|
|
11982
|
+
};
|
|
11907
11983
|
/**
|
|
11908
11984
|
* This returns the current window size (width and height).
|
|
11909
11985
|
* @returns The window width & The window height
|
|
@@ -11921,7 +11997,7 @@ This function has no effect on platforms that does not support dimming.
|
|
|
11921
11997
|
*/
|
|
11922
11998
|
export function set_dim_mode(mode: number): void;
|
|
11923
11999
|
/**
|
|
11924
|
-
* Sets a window event listener.
|
|
12000
|
+
* Sets a window event listener. Only one window event listener can be set at a time.
|
|
11925
12001
|
* @param callback A callback which receives info about window events. Pass an empty function or `nil` if you no longer wish to receive callbacks.
|
|
11926
12002
|
|
|
11927
12003
|
`self`
|