@defold-typescript/types 0.4.3 → 0.5.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/generated/b2d.d.ts +11 -0
- package/generated/buffer.d.ts +142 -0
- package/generated/collectionfactory.d.ts +118 -0
- package/generated/collectionproxy.d.ts +52 -0
- package/generated/crash.d.ts +109 -0
- package/generated/factory.d.ts +94 -0
- package/generated/go.d.ts +880 -0
- package/generated/graphics.d.ts +108 -0
- package/generated/gui.d.ts +1892 -0
- package/generated/http.d.ts +50 -0
- package/generated/iac.d.ts +7 -0
- package/generated/iap.d.ts +41 -0
- package/generated/image.d.ts +95 -0
- package/generated/json.d.ts +59 -0
- package/generated/label.d.ts +64 -0
- package/generated/liveupdate.d.ts +96 -0
- package/generated/model.d.ts +156 -0
- package/generated/msg.d.ts +56 -0
- package/generated/particlefx.d.ts +122 -0
- package/generated/physics.d.ts +451 -0
- package/generated/profiler.d.ts +188 -0
- package/generated/push.d.ts +48 -0
- package/generated/render.d.ts +944 -0
- package/generated/resource.d.ts +1227 -0
- package/generated/socket.d.ts +125 -0
- package/generated/sound.d.ts +246 -0
- package/generated/sprite.d.ts +111 -0
- package/generated/sys.d.ts +513 -0
- package/generated/tilemap.d.ts +151 -0
- package/generated/timer.d.ts +93 -0
- package/generated/vmath.d.ts +914 -0
- package/generated/webview.d.ts +50 -0
- package/generated/window.d.ts +141 -0
- package/generated/zlib.d.ts +28 -0
- package/package.json +1 -1
- package/src/api-doc.ts +10 -1
- package/src/doc-comment.ts +119 -0
- package/src/emit-dts.ts +63 -2
- package/src/index.ts +1 -0
- package/src/lifecycle.ts +28 -7
package/generated/tilemap.d.ts
CHANGED
|
@@ -3,19 +3,170 @@ import type { Hash, Url } from "../src/core-types";
|
|
|
3
3
|
|
|
4
4
|
declare global {
|
|
5
5
|
namespace tilemap {
|
|
6
|
+
/**
|
|
7
|
+
* flip tile horizontally
|
|
8
|
+
*/
|
|
6
9
|
const H_FLIP: number & { readonly __brand: "tilemap.H_FLIP" };
|
|
10
|
+
/**
|
|
11
|
+
* rotate tile 180 degrees clockwise
|
|
12
|
+
*/
|
|
7
13
|
const ROTATE_180: number & { readonly __brand: "tilemap.ROTATE_180" };
|
|
14
|
+
/**
|
|
15
|
+
* rotate tile 270 degrees clockwise
|
|
16
|
+
*/
|
|
8
17
|
const ROTATE_270: number & { readonly __brand: "tilemap.ROTATE_270" };
|
|
18
|
+
/**
|
|
19
|
+
* rotate tile 90 degrees clockwise
|
|
20
|
+
*/
|
|
9
21
|
const ROTATE_90: number & { readonly __brand: "tilemap.ROTATE_90" };
|
|
22
|
+
/**
|
|
23
|
+
* flip tile vertically
|
|
24
|
+
*/
|
|
10
25
|
const V_FLIP: number & { readonly __brand: "tilemap.V_FLIP" };
|
|
26
|
+
/**
|
|
27
|
+
* Get the bounds for a tile map. This function returns multiple values:
|
|
28
|
+
* The lower left corner index x and y coordinates (1-indexed),
|
|
29
|
+
* the tile map width and the tile map height.
|
|
30
|
+
* The resulting values take all tile map layers into account, meaning that
|
|
31
|
+
* the bounds are calculated as if all layers were collapsed into one.
|
|
32
|
+
*
|
|
33
|
+
* @param url - the tile map
|
|
34
|
+
* @example
|
|
35
|
+
* ```lua
|
|
36
|
+
* -- get the level bounds.
|
|
37
|
+
* local x, y, w, h = tilemap.get_bounds("/level#tilemap")
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
11
40
|
function get_bounds(url: string | Hash | Url): LuaMultiReturn<[number, number, number, number]>;
|
|
41
|
+
/**
|
|
42
|
+
* Get the tile set at the specified position in the tilemap.
|
|
43
|
+
* The position is identified by the tile index starting at origin
|
|
44
|
+
* with index 1, 1. (see tilemap.set_tile())
|
|
45
|
+
* Which tile map and layer to query is identified by the URL and the
|
|
46
|
+
* layer name parameters.
|
|
47
|
+
*
|
|
48
|
+
* @param url - the tile map
|
|
49
|
+
* @param layer - name of the layer for the tile
|
|
50
|
+
* @param x - x-coordinate of the tile
|
|
51
|
+
* @param y - y-coordinate of the tile
|
|
52
|
+
* @returns index of the tile
|
|
53
|
+
* @example
|
|
54
|
+
* ```lua
|
|
55
|
+
* -- get the tile under the player.
|
|
56
|
+
* local tileno = tilemap.get_tile("/level#tilemap", "foreground", self.player_x, self.player_y)
|
|
57
|
+
* ```
|
|
58
|
+
*/
|
|
12
59
|
function get_tile(url: string | Hash | Url, layer: string | Hash, x: number, y: number): number;
|
|
60
|
+
/**
|
|
61
|
+
* Get the tile information at the specified position in the tilemap.
|
|
62
|
+
* The position is identified by the tile index starting at origin
|
|
63
|
+
* with index 1, 1. (see tilemap.set_tile())
|
|
64
|
+
* Which tile map and layer to query is identified by the URL and the
|
|
65
|
+
* layer name parameters.
|
|
66
|
+
*
|
|
67
|
+
* @param url - the tile map
|
|
68
|
+
* @param layer - name of the layer for the tile
|
|
69
|
+
* @param x - x-coordinate of the tile
|
|
70
|
+
* @param y - y-coordinate of the tile
|
|
71
|
+
* @returns index of the tile
|
|
72
|
+
* @example
|
|
73
|
+
* ```lua
|
|
74
|
+
* -- get the tile under the player.
|
|
75
|
+
* local tile_info = tilemap.get_tile_info("/level#tilemap", "foreground", self.player_x, self.player_y)
|
|
76
|
+
* pprint(tile_info)
|
|
77
|
+
* -- {
|
|
78
|
+
* -- index = 0,
|
|
79
|
+
* -- h_flip = false,
|
|
80
|
+
* -- v_flip = true,
|
|
81
|
+
* -- rotate_90 = false
|
|
82
|
+
* -- }
|
|
83
|
+
* ```
|
|
84
|
+
*/
|
|
13
85
|
function get_tile_info(url: string | Hash | Url, layer: string | Hash, x: number, y: number): Record<string | number, unknown>;
|
|
86
|
+
/**
|
|
87
|
+
* Retrieves all the tiles for the specified layer in the tilemap.
|
|
88
|
+
* It returns a table of rows where the keys are the
|
|
89
|
+
* tile positions (see tilemap.get_bounds()).
|
|
90
|
+
* You can iterate it using `tiles[row_index][column_index]`.
|
|
91
|
+
*
|
|
92
|
+
* @param url - the tilemap
|
|
93
|
+
* @param layer - the name of the layer for the tiles
|
|
94
|
+
* @returns a table of rows representing the layer
|
|
95
|
+
* @example
|
|
96
|
+
* ```lua
|
|
97
|
+
* local left, bottom, columns_count, rows_count = tilemap.get_bounds("#tilemap")
|
|
98
|
+
* local tiles = tilemap.get_tiles("#tilemap", "layer")
|
|
99
|
+
* local tile, count = 0, 0
|
|
100
|
+
* for row_index = bottom, bottom + rows_count - 1 do
|
|
101
|
+
* for column_index = left, left + columns_count - 1 do
|
|
102
|
+
* tile = tiles[row_index][column_index]
|
|
103
|
+
* count = count + 1
|
|
104
|
+
* end
|
|
105
|
+
* end
|
|
106
|
+
* ```
|
|
107
|
+
*/
|
|
14
108
|
function get_tiles(url: string | Hash | Url, layer: string | Hash): Record<string | number, unknown>;
|
|
109
|
+
/**
|
|
110
|
+
* Replace a tile in a tile map with a new tile.
|
|
111
|
+
* The coordinates of the tiles are indexed so that the "first" tile just
|
|
112
|
+
* above and to the right of origin has coordinates 1,1.
|
|
113
|
+
* Tiles to the left of and below origin are indexed 0, -1, -2 and so forth.
|
|
114
|
+
* +-------+-------+------+------+
|
|
115
|
+
* | 0,3 | 1,3 | 2,3 | 3,3 |
|
|
116
|
+
* +-------+-------+------+------+
|
|
117
|
+
* | 0,2 | 1,2 | 2,2 | 3,2 |
|
|
118
|
+
* +-------+-------+------+------+
|
|
119
|
+
* | 0,1 | 1,1 | 2,1 | 3,1 |
|
|
120
|
+
* +-------O-------+------+------+
|
|
121
|
+
* | 0,0 | 1,0 | 2,0 | 3,0 |
|
|
122
|
+
* +-------+-------+------+------+
|
|
123
|
+
* The coordinates must be within the bounds of the tile map as it were created.
|
|
124
|
+
* That is, it is not possible to extend the size of a tile map by setting tiles outside the edges.
|
|
125
|
+
* To clear a tile, set the tile to number 0. Which tile map and layer to manipulate is identified by the URL and the layer name parameters.
|
|
126
|
+
* Transform bitmask is arithmetic sum of one or both FLIP constants (`tilemap.H_FLIP`, `tilemap.V_FLIP`) and/or one of ROTATION constants
|
|
127
|
+
* (`tilemap.ROTATE_90`, `tilemap.ROTATE_180`, `tilemap.ROTATE_270`).
|
|
128
|
+
* Flip always applies before rotation (clockwise).
|
|
129
|
+
*
|
|
130
|
+
* @param url - the tile map
|
|
131
|
+
* @param layer - name of the layer for the tile
|
|
132
|
+
* @param x - x-coordinate of the tile
|
|
133
|
+
* @param y - y-coordinate of the tile
|
|
134
|
+
* @param tile - index of new tile to set. 0 resets the cell
|
|
135
|
+
* @param transform_bitmask - optional flip and/or rotation should be applied to the tile
|
|
136
|
+
* @example
|
|
137
|
+
* ```lua
|
|
138
|
+
* -- Clear the tile under the player.
|
|
139
|
+
* tilemap.set_tile("/level#tilemap", "foreground", self.player_x, self.player_y, 0)
|
|
140
|
+
*
|
|
141
|
+
* -- Set tile with different combination of flip and rotation
|
|
142
|
+
* tilemap.set_tile("#tilemap", "layer1", x, y, 0, tilemap.H_FLIP + tilemap.V_FLIP + tilemap.ROTATE_90)
|
|
143
|
+
* tilemap.set_tile("#tilemap", "layer1", x, y, 0, tilemap.H_FLIP + tilemap.ROTATE_270)
|
|
144
|
+
* tilemap.set_tile("#tilemap", "layer1", x, y, 0, tilemap.V_FLIP + tilemap.H_FLIP)
|
|
145
|
+
* tilemap.set_tile("#tilemap", "layer1", x, y, 0, tilemap.ROTATE_180)
|
|
146
|
+
* ```
|
|
147
|
+
*/
|
|
15
148
|
function set_tile(url: string | Hash | Url, layer: string | Hash, x: number, y: number, tile: number, transform_bitmask?: number): void;
|
|
149
|
+
/**
|
|
150
|
+
* Sets the visibility of the tilemap layer
|
|
151
|
+
*
|
|
152
|
+
* @param url - the tile map
|
|
153
|
+
* @param layer - name of the layer for the tile
|
|
154
|
+
* @param visible - should the layer be visible
|
|
155
|
+
* @example
|
|
156
|
+
* ```lua
|
|
157
|
+
* -- Disable rendering of the layer
|
|
158
|
+
* tilemap.set_visible("/level#tilemap", "foreground", false)
|
|
159
|
+
* ```
|
|
160
|
+
*/
|
|
16
161
|
function set_visible(url: string | Hash | Url, layer: string | Hash, visible: boolean): void;
|
|
17
162
|
interface properties {
|
|
163
|
+
/**
|
|
164
|
+
* The material used when rendering the tile map. The type of the property is hash.
|
|
165
|
+
*/
|
|
18
166
|
material: Hash;
|
|
167
|
+
/**
|
|
168
|
+
* The tile source used when rendering the tile map. The type of the property is hash.
|
|
169
|
+
*/
|
|
19
170
|
tile_source: Hash;
|
|
20
171
|
}
|
|
21
172
|
}
|
package/generated/timer.d.ts
CHANGED
|
@@ -1,10 +1,103 @@
|
|
|
1
1
|
/** @noSelfInFile */
|
|
2
2
|
declare global {
|
|
3
3
|
namespace timer {
|
|
4
|
+
/**
|
|
5
|
+
* Indicates an invalid timer handle
|
|
6
|
+
*/
|
|
4
7
|
const INVALID_TIMER_HANDLE: number & { readonly __brand: "timer.INVALID_TIMER_HANDLE" };
|
|
8
|
+
/**
|
|
9
|
+
* You may cancel a timer from inside a timer callback.
|
|
10
|
+
* Cancelling a timer that is already executed or cancelled is safe.
|
|
11
|
+
*
|
|
12
|
+
* @param handle - the timer handle returned by timer.delay()
|
|
13
|
+
* @returns if the timer was active, false if the timer is already cancelled / complete
|
|
14
|
+
* @example
|
|
15
|
+
* ```lua
|
|
16
|
+
* self.handle = timer.delay(1, true, function() print("print every second") end)
|
|
17
|
+
* ...
|
|
18
|
+
* local result = timer.cancel(self.handle)
|
|
19
|
+
* if not result then
|
|
20
|
+
* print("the timer is already cancelled")
|
|
21
|
+
* end
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
5
24
|
function cancel(handle: number): boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Adds a timer and returns a unique handle.
|
|
27
|
+
* You may create more timers from inside a timer callback.
|
|
28
|
+
* Using a delay of 0 will result in a timer that triggers at the next frame just before
|
|
29
|
+
* script update functions.
|
|
30
|
+
* If you want a timer that triggers on each frame, set delay to 0.0f and repeat to true.
|
|
31
|
+
* Timers created within a script will automatically die when the script is deleted.
|
|
32
|
+
*
|
|
33
|
+
* @param delay - time interval in seconds
|
|
34
|
+
* @param repeating - true = repeat timer until cancel, false = one-shot timer
|
|
35
|
+
* @param callback - timer callback function
|
|
36
|
+
`self`
|
|
37
|
+
object The current object
|
|
38
|
+
`handle`
|
|
39
|
+
number The handle of the timer
|
|
40
|
+
`time_elapsed`
|
|
41
|
+
number The elapsed time - on first trigger it is time since timer.delay call, otherwise time since last trigger
|
|
42
|
+
* @returns identifier for the create timer, returns timer.INVALID_TIMER_HANDLE if the timer can not be created
|
|
43
|
+
* @example
|
|
44
|
+
* ```lua
|
|
45
|
+
* A simple one-shot timer
|
|
46
|
+
* timer.delay(1, false, function() print("print in one second") end)
|
|
47
|
+
*
|
|
48
|
+
* Repetitive timer which canceled after 10 calls
|
|
49
|
+
* local function call_every_second(self, handle, time_elapsed)
|
|
50
|
+
* self.counter = self.counter + 1
|
|
51
|
+
* print("Call #", self.counter)
|
|
52
|
+
* if self.counter == 10 then
|
|
53
|
+
* timer.cancel(handle) -- cancel timer after 10 calls
|
|
54
|
+
* end
|
|
55
|
+
* end
|
|
56
|
+
*
|
|
57
|
+
* self.counter = 0
|
|
58
|
+
* timer.delay(1, true, call_every_second)
|
|
59
|
+
* ```
|
|
60
|
+
*/
|
|
6
61
|
function delay(delay: number, repeating: boolean, callback: (self: unknown, handle: unknown, time_elapsed: unknown) => void): number;
|
|
62
|
+
/**
|
|
63
|
+
* Get information about timer.
|
|
64
|
+
*
|
|
65
|
+
* @param handle - the timer handle returned by timer.delay()
|
|
66
|
+
* @returns table or `nil` if timer is cancelled/completed. table with data in the following fields:
|
|
67
|
+
`time_remaining`
|
|
68
|
+
number Time remaining until the next time a timer.delay() fires.
|
|
69
|
+
`delay`
|
|
70
|
+
number Time interval.
|
|
71
|
+
`repeating`
|
|
72
|
+
boolean true = repeat timer until cancel, false = one-shot timer.
|
|
73
|
+
* @example
|
|
74
|
+
* ```lua
|
|
75
|
+
* self.handle = timer.delay(1, true, function() print("print every second") end)
|
|
76
|
+
* ...
|
|
77
|
+
* local result = timer.get_info(self.handle)
|
|
78
|
+
* if not result then
|
|
79
|
+
* print("the timer is already cancelled or complete")
|
|
80
|
+
* else
|
|
81
|
+
* pprint(result) -- delay, time_remaining, repeating
|
|
82
|
+
* end
|
|
83
|
+
* ```
|
|
84
|
+
*/
|
|
7
85
|
function get_info(handle: number): { time_remaining: number; delay: number; repeating: boolean } | unknown;
|
|
86
|
+
/**
|
|
87
|
+
* Manual triggering a callback for a timer.
|
|
88
|
+
*
|
|
89
|
+
* @param handle - the timer handle returned by timer.delay()
|
|
90
|
+
* @returns if the timer was active, false if the timer is already cancelled / complete
|
|
91
|
+
* @example
|
|
92
|
+
* ```lua
|
|
93
|
+
* self.handle = timer.delay(1, true, function() print("print every second or manually by timer.trigger") end)
|
|
94
|
+
* ...
|
|
95
|
+
* local result = timer.trigger(self.handle)
|
|
96
|
+
* if not result then
|
|
97
|
+
* print("the timer is already cancelled or complete")
|
|
98
|
+
* end
|
|
99
|
+
* ```
|
|
100
|
+
*/
|
|
8
101
|
function trigger(handle: number): boolean;
|
|
9
102
|
}
|
|
10
103
|
}
|