@ts-defold/types 1.2.36 → 1.2.38
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 +260 -14
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
/// <reference types="lua-types/5.1" />
|
|
3
3
|
/// <reference types="@typescript-to-lua/language-extensions" />
|
|
4
4
|
|
|
5
|
-
// DEFOLD. stable version 1.6.
|
|
5
|
+
// DEFOLD. stable version 1.6.4 (4689e4033ebfc982176b92545900302d0fcb03b3)
|
|
6
6
|
// =^..^= =^..^= =^..^= =^..^= =^..^= =^..^= =^..^= //
|
|
7
7
|
|
|
8
8
|
|
|
@@ -438,6 +438,16 @@ declare namespace go {
|
|
|
438
438
|
export let euler: any
|
|
439
439
|
|
|
440
440
|
|
|
441
|
+
/**
|
|
442
|
+
* This is a callback-function, which is called by the engine at fixed intervals to update the state of a script
|
|
443
|
+
* component. The function will be called if 'Fixed Update Frequency' is enabled in the Engine section of game.project.
|
|
444
|
+
* It can for instance be used to update game logic with the physics simulation if using a fixed timestep for the
|
|
445
|
+
* physics (enabled by ticking 'Use Fixed Timestep' in the Physics section of game.project).
|
|
446
|
+
* @param self reference to the script state to be used for storing data
|
|
447
|
+
* @param dt the time-step of the frame update
|
|
448
|
+
*/
|
|
449
|
+
export function fixed_update(self: object, dt: number): void
|
|
450
|
+
|
|
441
451
|
/**
|
|
442
452
|
* in-back
|
|
443
453
|
*/
|
|
@@ -1496,7 +1506,9 @@ with a custom curve. See the animation guide for more information.
|
|
|
1496
1506
|
export function cancel_flipbook(node: node): void
|
|
1497
1507
|
|
|
1498
1508
|
/**
|
|
1499
|
-
* Make a clone instance of a node.
|
|
1509
|
+
* Make a clone instance of a node. The cloned node will be identical to the
|
|
1510
|
+
* original node, except the id which is generated as the string "node" plus
|
|
1511
|
+
* a sequential unsigned integer value.
|
|
1500
1512
|
* This function does not clone the supplied node's children nodes.
|
|
1501
1513
|
* Use gui.clone_tree for that purpose.
|
|
1502
1514
|
* @param node node to clone
|
|
@@ -2584,6 +2596,15 @@ declare namespace physics {
|
|
|
2584
2596
|
*/
|
|
2585
2597
|
export type apply_force = "apply_force"
|
|
2586
2598
|
|
|
2599
|
+
/**
|
|
2600
|
+
* See physics.set_listener.
|
|
2601
|
+
* This message is sent to a function specified in physics.set_listener
|
|
2602
|
+
* when two collision objects collide.
|
|
2603
|
+
* This message only reports that a collision has occurred and will be sent once per frame and per colliding pair.
|
|
2604
|
+
* For more detailed information, check for the contact_point_event.
|
|
2605
|
+
*/
|
|
2606
|
+
export type collision_event = "collision_event"
|
|
2607
|
+
|
|
2587
2608
|
/**
|
|
2588
2609
|
* This message is broadcasted to every component of an instance that has a collision object,
|
|
2589
2610
|
* when the collision object collides with another collision object. For a script to take action
|
|
@@ -2595,6 +2616,16 @@ declare namespace physics {
|
|
|
2595
2616
|
*/
|
|
2596
2617
|
export type collision_response = "collision_response"
|
|
2597
2618
|
|
|
2619
|
+
/**
|
|
2620
|
+
* See physics.set_listener.
|
|
2621
|
+
* This message is sent to a function specified in physics.set_listener when
|
|
2622
|
+
* a collision object has contact points with another collision object.
|
|
2623
|
+
* Since multiple contact points can occur for two colliding objects, this event can be sent
|
|
2624
|
+
* multiple times in the same frame for the same two colliding objects. To only be notified once
|
|
2625
|
+
* when the collision occurs, check for the collision_event event instead.
|
|
2626
|
+
*/
|
|
2627
|
+
export type contact_point_event = "contact_point_event"
|
|
2628
|
+
|
|
2598
2629
|
/**
|
|
2599
2630
|
* This message is broadcasted to every component of an instance that has a collision object,
|
|
2600
2631
|
* when the collision object has contact points with respect to another collision object.
|
|
@@ -2648,6 +2679,11 @@ declare namespace physics {
|
|
|
2648
2679
|
*/
|
|
2649
2680
|
export let JOINT_TYPE_WELD: any
|
|
2650
2681
|
|
|
2682
|
+
/**
|
|
2683
|
+
* wheel joint type
|
|
2684
|
+
*/
|
|
2685
|
+
export let JOINT_TYPE_WHEEL: any
|
|
2686
|
+
|
|
2651
2687
|
/**
|
|
2652
2688
|
* Create a physics joint between two collision object components.
|
|
2653
2689
|
* Note: Currently only supported in 2D physics.
|
|
@@ -2740,6 +2776,48 @@ end
|
|
|
2740
2776
|
*/
|
|
2741
2777
|
export function get_maskbit(url: string | hash | url, group: string): boolean
|
|
2742
2778
|
|
|
2779
|
+
/**
|
|
2780
|
+
* Gets collision shape data from a collision object
|
|
2781
|
+
* @param url the collision object.
|
|
2782
|
+
* @param shape the name of the shape to get data for.
|
|
2783
|
+
* @return table A table containing meta data about the physics shape
|
|
2784
|
+
|
|
2785
|
+
`type`
|
|
2786
|
+
The shape type. Supported values:
|
|
2787
|
+
|
|
2788
|
+
|
|
2789
|
+
- `physics.SHAPE_TYPE_SPHERE`
|
|
2790
|
+
- `physics.SHAPE_TYPE_BOX`
|
|
2791
|
+
- `physics.SHAPE_TYPE_CAPSULE` *Only supported for 3D physics*
|
|
2792
|
+
- `physics.SHAPE_TYPE_HULL`
|
|
2793
|
+
|
|
2794
|
+
The returned table contains different fields depending on which type the shape is.
|
|
2795
|
+
If the shape is a sphere:
|
|
2796
|
+
|
|
2797
|
+
`diameter`
|
|
2798
|
+
the diameter of the sphere shape
|
|
2799
|
+
|
|
2800
|
+
If the shape is a box:
|
|
2801
|
+
|
|
2802
|
+
`dimensions`
|
|
2803
|
+
a `vmath.vector3` of the box dimensions
|
|
2804
|
+
|
|
2805
|
+
If the shape is a capsule:
|
|
2806
|
+
|
|
2807
|
+
`diameter`
|
|
2808
|
+
the diameter of the capsule poles
|
|
2809
|
+
`height`
|
|
2810
|
+
the height of the capsule
|
|
2811
|
+
|
|
2812
|
+
`local function get_shape_meta()
|
|
2813
|
+
local sphere = physics.get_shape("#collisionobject", "my_sphere_shape")
|
|
2814
|
+
-- returns a table with sphere.diameter
|
|
2815
|
+
return sphere
|
|
2816
|
+
end
|
|
2817
|
+
`
|
|
2818
|
+
*/
|
|
2819
|
+
export function get_shape(url: string | hash | url, shape: string | hash): any
|
|
2820
|
+
|
|
2743
2821
|
/**
|
|
2744
2822
|
* Ray casts are used to test for intersections against collision objects in the physics world.
|
|
2745
2823
|
* Collision objects of types kinematic, dynamic and static are tested against. Trigger objects
|
|
@@ -2754,7 +2832,7 @@ end
|
|
|
2754
2832
|
`all`
|
|
2755
2833
|
Set to `true` to return all ray cast hits. If `false`, it will only return the closest hit.
|
|
2756
2834
|
|
|
2757
|
-
* @return result It returns a list. If missed it returns `nil`. See
|
|
2835
|
+
* @return result It returns a list. If missed it returns `nil`. See ray_cast_response for details on the returned values.
|
|
2758
2836
|
*/
|
|
2759
2837
|
export function raycast(from: vmath.vector3, to: vmath.vector3, groups: any, options: any): LuaMultiReturn<[any, any]>
|
|
2760
2838
|
|
|
@@ -2766,8 +2844,8 @@ Set to `true` to return all ray cast hits. If `false`, it will only return the c
|
|
|
2766
2844
|
* through `groups`.
|
|
2767
2845
|
* The actual ray cast will be performed during the physics-update.
|
|
2768
2846
|
*
|
|
2769
|
-
* - If an object is hit, the result will be reported via a
|
|
2770
|
-
* - If there is no object hit, the result will be reported via a
|
|
2847
|
+
* - If an object is hit, the result will be reported via a ray_cast_response message.
|
|
2848
|
+
* - If there is no object hit, the result will be reported via a ray_cast_missed message.
|
|
2771
2849
|
*
|
|
2772
2850
|
* @param from the world position of the start of the ray
|
|
2773
2851
|
* @param to the world position of the end of the ray
|
|
@@ -2815,6 +2893,29 @@ Note: The `collide_connected` field cannot be updated/changed after a connection
|
|
|
2815
2893
|
*/
|
|
2816
2894
|
export function set_joint_properties(collisionobject: string | hash | url, joint_id: string | hash, properties: any): void
|
|
2817
2895
|
|
|
2896
|
+
/**
|
|
2897
|
+
* sets a physics world event listener. If a function is set, physics messages will no longer be sent.
|
|
2898
|
+
* @param callback A callback that receives information about all the physics interactions in this physics world.
|
|
2899
|
+
|
|
2900
|
+
`self`
|
|
2901
|
+
The calling script
|
|
2902
|
+
`event`
|
|
2903
|
+
The type of event. Can be one of these messages:
|
|
2904
|
+
|
|
2905
|
+
|
|
2906
|
+
- contact_point_event
|
|
2907
|
+
- collision_event
|
|
2908
|
+
- trigger_event
|
|
2909
|
+
- ray_cast_response
|
|
2910
|
+
- ray_cast_missed
|
|
2911
|
+
|
|
2912
|
+
|
|
2913
|
+
`data`
|
|
2914
|
+
The callback value data is a table that contains event-related data. See the documentation for details on the messages.
|
|
2915
|
+
|
|
2916
|
+
*/
|
|
2917
|
+
export function set_listener(callback: any): void
|
|
2918
|
+
|
|
2818
2919
|
/**
|
|
2819
2920
|
* Sets or clears the masking of a group (maskbit) in a collision object.
|
|
2820
2921
|
* @param url the collision object to change the mask of.
|
|
@@ -2828,6 +2929,35 @@ end
|
|
|
2828
2929
|
*/
|
|
2829
2930
|
export function set_maskbit(url: string | hash | url, group: string, maskbit: boolean): void
|
|
2830
2931
|
|
|
2932
|
+
/**
|
|
2933
|
+
* Sets collision shape data for a collision object. Please note that updating data in 3D
|
|
2934
|
+
* can be quite costly for box and capsules. Because of the physics engine, the cost
|
|
2935
|
+
* comes from having to recreate the shape objects when certain shapes needs to be updated.
|
|
2936
|
+
* @param url the collision object.
|
|
2937
|
+
* @param shape the name of the shape to get data for.
|
|
2938
|
+
* @param table the shape data to update the shape with.
|
|
2939
|
+
See physics.get_shape for a detailed description of each field in the data table.
|
|
2940
|
+
`local function set_shape_data()
|
|
2941
|
+
-- set capsule shape data
|
|
2942
|
+
local data = {}
|
|
2943
|
+
data.diameter = 10
|
|
2944
|
+
data.height = 20
|
|
2945
|
+
physics.set_shape("#collisionobject", "my_capsule_shape", data)
|
|
2946
|
+
|
|
2947
|
+
-- set sphere shape data
|
|
2948
|
+
data = {}
|
|
2949
|
+
data.diameter = 10
|
|
2950
|
+
physics.set_shape("#collisionobject", "my_sphere_shape", data)
|
|
2951
|
+
|
|
2952
|
+
-- set box shape data
|
|
2953
|
+
data = {}
|
|
2954
|
+
data.dimensions = vmath.vector3(10, 10, 5)
|
|
2955
|
+
physics.set_shape("#collisionobject", "my_box_shape", data)
|
|
2956
|
+
end
|
|
2957
|
+
`
|
|
2958
|
+
*/
|
|
2959
|
+
export function set_shape(url: string | hash | url, shape: string | hash, table: any): void
|
|
2960
|
+
|
|
2831
2961
|
/**
|
|
2832
2962
|
* Flips the collision shapes vertically for a collision object
|
|
2833
2963
|
* @param url the collision object that should flip its shapes
|
|
@@ -2835,6 +2965,14 @@ end
|
|
|
2835
2965
|
*/
|
|
2836
2966
|
export function set_vflip(url: string | hash | url, flip: boolean): void
|
|
2837
2967
|
|
|
2968
|
+
/**
|
|
2969
|
+
* The function recalculates the density of each shape based on the total area of all shapes and the specified mass, then updates the mass of the body accordingly.
|
|
2970
|
+
* Note: Currently only supported in 2D physics.
|
|
2971
|
+
* @param collisionobject the collision object whose mass needs to be updated.
|
|
2972
|
+
* @param mass the new mass value to set for the collision object.
|
|
2973
|
+
*/
|
|
2974
|
+
export function update_mass(collisionobject: string | hash | url, mass: number): void
|
|
2975
|
+
|
|
2838
2976
|
/**
|
|
2839
2977
|
* Collision objects tend to fall asleep when inactive for a small period of time for
|
|
2840
2978
|
* efficiency reasons. This function wakes them up.
|
|
@@ -2849,17 +2987,28 @@ end
|
|
|
2849
2987
|
export function wakeup(url: string | hash | url): void
|
|
2850
2988
|
|
|
2851
2989
|
/**
|
|
2852
|
-
* This message is sent back to the sender of a
|
|
2853
|
-
*
|
|
2990
|
+
* This message is sent back to the sender of a ray_cast_request, or to the physics world listener
|
|
2991
|
+
* if it is set (see physics.set_listener), if the ray didn't hit any collision object.
|
|
2992
|
+
* See physics.raycast_async for examples of how to use it.
|
|
2854
2993
|
*/
|
|
2855
2994
|
export type ray_cast_missed = "ray_cast_missed"
|
|
2856
2995
|
|
|
2857
2996
|
/**
|
|
2858
|
-
* This message is sent back to the sender of a
|
|
2859
|
-
*
|
|
2997
|
+
* This message is sent back to the sender of a ray_cast_request, or to the physics world listener
|
|
2998
|
+
* if it is set (see physics.set_listener), if the ray hits a collision object.
|
|
2999
|
+
* See physics.raycast_async for examples of how to use it.
|
|
2860
3000
|
*/
|
|
2861
3001
|
export type ray_cast_response = "ray_cast_response"
|
|
2862
3002
|
|
|
3003
|
+
/**
|
|
3004
|
+
* See physics.set_listener.
|
|
3005
|
+
* This message is sent to a function specified in physics.set_listener
|
|
3006
|
+
* when a collision object interacts with another collision object and one of them is a trigger.
|
|
3007
|
+
* This message only reports that an interaction actually happened and will be sent once per colliding pair and frame.
|
|
3008
|
+
* For more detailed information, check for the contact_point_event.
|
|
3009
|
+
*/
|
|
3010
|
+
export type trigger_event = "trigger_event"
|
|
3011
|
+
|
|
2863
3012
|
/**
|
|
2864
3013
|
* This message is broadcasted to every component of an instance that has a collision object,
|
|
2865
3014
|
* when the collision object interacts with another collision object and one of them is a trigger.
|
|
@@ -4786,6 +4935,21 @@ declare namespace sys {
|
|
|
4786
4935
|
*/
|
|
4787
4936
|
export let NETWORK_DISCONNECTED: any
|
|
4788
4937
|
|
|
4938
|
+
/**
|
|
4939
|
+
* an asyncronous request is unable to read the resource
|
|
4940
|
+
*/
|
|
4941
|
+
export let REQUEST_STATUS_ERROR_IO_ERROR: any
|
|
4942
|
+
|
|
4943
|
+
/**
|
|
4944
|
+
* an asyncronous request is unable to locate the resource
|
|
4945
|
+
*/
|
|
4946
|
+
export let REQUEST_STATUS_ERROR_NOT_FOUND: any
|
|
4947
|
+
|
|
4948
|
+
/**
|
|
4949
|
+
* an asyncronous request has finished successfully
|
|
4950
|
+
*/
|
|
4951
|
+
export let REQUEST_STATUS_FINISHED: any
|
|
4952
|
+
|
|
4789
4953
|
/**
|
|
4790
4954
|
* deserializes buffer into a lua table
|
|
4791
4955
|
* @param buffer buffer to deserialize from
|
|
@@ -4952,6 +5116,55 @@ The HTTP user agent, i.e. "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) Apple
|
|
|
4952
5116
|
*/
|
|
4953
5117
|
export function load(filename: string): any
|
|
4954
5118
|
|
|
5119
|
+
/**
|
|
5120
|
+
* The sys.load_buffer function will first try to load the resource
|
|
5121
|
+
* from any of the mounted resource locations and return the data if
|
|
5122
|
+
* any matching entries found. If not, the path will be tried
|
|
5123
|
+
* as is from the primary disk on the device.
|
|
5124
|
+
* In order for the engine to include custom resources in the build process, you need
|
|
5125
|
+
* to specify them in the "custom_resources" key in your "game.project" settings file.
|
|
5126
|
+
* You can specify single resource files or directories. If a directory is included
|
|
5127
|
+
* in the resource list, all files and directories in that directory is recursively
|
|
5128
|
+
* included:
|
|
5129
|
+
* For example "main/data/,assets/level_data.json".
|
|
5130
|
+
* @param path the path to load the buffer from
|
|
5131
|
+
* @return buffer the buffer with data
|
|
5132
|
+
*/
|
|
5133
|
+
export function load_buffer(path: string): buffer
|
|
5134
|
+
|
|
5135
|
+
/**
|
|
5136
|
+
* The sys.load_buffer function will first try to load the resource
|
|
5137
|
+
* from any of the mounted resource locations and return the data if
|
|
5138
|
+
* any matching entries found. If not, the path will be tried
|
|
5139
|
+
* as is from the primary disk on the device.
|
|
5140
|
+
* In order for the engine to include custom resources in the build process, you need
|
|
5141
|
+
* to specify them in the "custom_resources" key in your "game.project" settings file.
|
|
5142
|
+
* You can specify single resource files or directories. If a directory is included
|
|
5143
|
+
* in the resource list, all files and directories in that directory is recursively
|
|
5144
|
+
* included:
|
|
5145
|
+
* For example "main/data/,assets/level_data.json".
|
|
5146
|
+
* Note that issuing multiple requests of the same resource will yield
|
|
5147
|
+
* individual buffers per request. There is no implic caching of the buffers
|
|
5148
|
+
* based on request path.
|
|
5149
|
+
* @param path the path to load the buffer from
|
|
5150
|
+
* @param status_callback A status callback that will be invoked when a request has been handled, or an error occured. The result is a table containing:
|
|
5151
|
+
|
|
5152
|
+
`status`
|
|
5153
|
+
The status of the request, supported values are:
|
|
5154
|
+
|
|
5155
|
+
|
|
5156
|
+
- `resource.REQUEST_STATUS_FINISHED`
|
|
5157
|
+
- `resource.REQUEST_STATUS_ERROR_IO_ERROR`
|
|
5158
|
+
- `resource.REQUEST_STATUS_ERROR_NOT_FOUND`
|
|
5159
|
+
|
|
5160
|
+
|
|
5161
|
+
`buffer`
|
|
5162
|
+
If the request was successfull, this will contain the request payload in a buffer object, and nil otherwise. Make sure to check the status before doing anything with the buffer value!
|
|
5163
|
+
|
|
5164
|
+
* @return handle a handle to the request
|
|
5165
|
+
*/
|
|
5166
|
+
export function load_buffer_async(path: string, status_callback: any): any
|
|
5167
|
+
|
|
4955
5168
|
/**
|
|
4956
5169
|
* Loads a custom resource. Specify the full filename of the resource that you want
|
|
4957
5170
|
* to load. When loaded, the file data is returned as a string.
|
|
@@ -5449,6 +5662,26 @@ declare namespace image {
|
|
|
5449
5662
|
*/
|
|
5450
5663
|
export function load(buffer: string, premult?: boolean): LuaMultiReturn<[any, any]>
|
|
5451
5664
|
|
|
5665
|
+
/**
|
|
5666
|
+
* Load image (PNG or JPEG) from a string buffer.
|
|
5667
|
+
* @param buffer image data buffer
|
|
5668
|
+
* @param premult optional flag if alpha should be premultiplied. Defaults to `false`
|
|
5669
|
+
* @return image object or `nil` if loading fails. The object is a table with the following fields:
|
|
5670
|
+
|
|
5671
|
+
`width`: image width
|
|
5672
|
+
`height`: image height
|
|
5673
|
+
`type`: image type
|
|
5674
|
+
- `image.TYPE_RGB`
|
|
5675
|
+
- `image.TYPE_RGBA`
|
|
5676
|
+
- `image.TYPE_LUMINANCE`
|
|
5677
|
+
- `image.TYPE_LUMINANCE_ALPHA`
|
|
5678
|
+
|
|
5679
|
+
|
|
5680
|
+
`buffer`: the script buffer that holds the decompressed image data. See buffer.create how to use the buffer.
|
|
5681
|
+
|
|
5682
|
+
*/
|
|
5683
|
+
export function load_buffer(buffer: string, premult?: boolean): LuaMultiReturn<[any, any]>
|
|
5684
|
+
|
|
5452
5685
|
}
|
|
5453
5686
|
// =^..^= =^..^= =^..^= =^..^= =^..^= =^..^= =^..^= //
|
|
5454
5687
|
|
|
@@ -5459,17 +5692,25 @@ declare namespace json {
|
|
|
5459
5692
|
* Decode a string of JSON data into a Lua table.
|
|
5460
5693
|
* A Lua error is raised for syntax errors.
|
|
5461
5694
|
* @param json json data
|
|
5695
|
+
* @param options table with decode options
|
|
5696
|
+
|
|
5697
|
+
`decode_null_as_userdata`: wether to decode a JSON null value as json.null or nil (default is nil)
|
|
5698
|
+
|
|
5462
5699
|
* @return data decoded json
|
|
5463
5700
|
*/
|
|
5464
|
-
export function decode(json: string): any
|
|
5701
|
+
export function decode(json: string, options: any): any
|
|
5465
5702
|
|
|
5466
5703
|
/**
|
|
5467
5704
|
* Encode a lua table to a JSON string.
|
|
5468
5705
|
* A Lua error is raised for syntax errors.
|
|
5469
5706
|
* @param tbl lua table to encode
|
|
5707
|
+
* @param options table with encode options
|
|
5708
|
+
|
|
5709
|
+
`encode_empty_table_as_object`: wether to encode an empty table as an JSON object or array (default is object)
|
|
5710
|
+
|
|
5470
5711
|
* @return json encoded json
|
|
5471
5712
|
*/
|
|
5472
|
-
export function encode(tbl: any): string
|
|
5713
|
+
export function encode(tbl: any, options: any): string
|
|
5473
5714
|
|
|
5474
5715
|
/**
|
|
5475
5716
|
* null
|
|
@@ -6934,10 +7175,15 @@ The invoker of the callback: the sound component.
|
|
|
6934
7175
|
export function set_pan(url: string | hash | url, pan?: number): void
|
|
6935
7176
|
|
|
6936
7177
|
/**
|
|
6937
|
-
* Stop playing all active voices
|
|
6938
|
-
* @param url the sound that should stop
|
|
7178
|
+
* Stop playing all active voices or just one voice if `play_id` provided
|
|
7179
|
+
* @param url the sound component that should stop
|
|
7180
|
+
* @param stop_properties
|
|
7181
|
+
optional table with properties:
|
|
7182
|
+
`play_id`
|
|
7183
|
+
the sequential play identifier that should be stopped (was given by the sound.play() function)
|
|
7184
|
+
|
|
6939
7185
|
*/
|
|
6940
|
-
export function stop(url: string | hash | url): void
|
|
7186
|
+
export function stop(url: string | hash | url, stop_properties?: any): void
|
|
6941
7187
|
|
|
6942
7188
|
/**
|
|
6943
7189
|
* This message is sent back to the sender of a `play_sound` message, if the sound
|