Skip to content

Commit b069a8f

Browse files
committed
update to 1.4.8
1 parent e763ac1 commit b069a8f

32 files changed

Lines changed: 3727 additions & 1031 deletions

DefoldDocs/api/collection_factory.lua

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,12 @@ function collectionfactory.get_status(url) end
4343
---@param complete_function function(self, url, result)) function to call when resources are loaded.
4444
function collectionfactory.load(url, complete_function) end
4545

46+
---Changes the prototype for the collection factory.
47+
---Setting the prototype to "nil" will revert back to the original prototype.
48+
---@param url string|hash|url the collection factory component
49+
---@param prototype string|nil the path to the new prototype, or nil
50+
function collectionfactory.set_prototype(url, prototype) end
51+
4652
---This decreases the reference count for each resource loaded with collectionfactory.load. If reference is zero, the resource is destroyed.
4753
---Calling this function when the factory is not marked as dynamic loading does nothing.
4854
---@param url string|hash|url the collection factory component to unload

DefoldDocs/api/factory.lua

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ function factory.get_status(url) end
3636
---@param complete_function function(self, url, result)) function to call when resources are loaded.
3737
function factory.load(url, complete_function) end
3838

39+
---Changes the prototype for the factory.
40+
---@param url string|hash|url the factory component
41+
---@param prototype string|nil the path to the new prototype, or nil
42+
function factory.set_prototype(url, prototype) end
43+
3944
---This decreases the reference count for each resource loaded with factory.load. If reference is zero, the resource is destroyed.
4045
---Calling this function when the factory is not marked as dynamic loading does nothing.
4146
---@param url string|hash|url the factory component to unload

DefoldDocs/api/game_object.lua

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,11 @@ function go.cancel_animations(url, property) end
140140
---@param recursive boolean optional boolean, set to true to recursively delete child hiearchy in child to parent order
141141
function go.delete(id, recursive) end
142142

143+
---check if the specified game object exists
144+
---@param url string|hash|url url of the game object to check
145+
---@return bool true if the game object exists
146+
function go.exists(url) end
147+
143148
---gets a named property of the specified game object or component
144149
---@param url string|hash|url url of the game object or component having the property
145150
---@param property string|hash id of the property to retrieve
@@ -218,7 +223,7 @@ function go.get_world_transform(id) end
218223
---The properties defined this way are automatically exposed in the editor in game objects and collections which use the script.
219224
---Note that you can only use this function outside any callback-functions like init and update.
220225
---@param name string the id of the property
221-
---@param value number|hash|url|vector3|vector4|quaternion|resource default value of the property. In the case of a url, only the empty constructor msg.url() is allowed. In the case of a resource one of the resource constructors (eg resource.atlas(), resource.font() etc) is expected.
226+
---@param value number|hash|url|vector3|vector4|quaternion|resource|boolean default value of the property. In the case of a url, only the empty constructor msg.url() is allowed. In the case of a resource one of the resource constructors (eg resource.atlas(), resource.font() etc) is expected.
222227
function go.property(name, value) end
223228

224229
---sets a named property of the specified game object or component, or a material constant

DefoldDocs/api/gui.lua

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ gui.SIZE_MODE_MANUAL = nil
208208
---together. See the examples below for more information.
209209
---@param node node node to animate
210210
---@param property string|constant property to animate
211-
---@param to vector3|vector4 target property value
211+
---@param to number|vector3|vector4|quaternion target property value
212212
---@param easing constant|vector easing to use during animation. Either specify one of the gui.EASING_* constants or provide a vector with a custom curve. See the animation guide <> for more information.
213213
---@param duration number duration of the animation in seconds.
214214
---@param delay number delay before the animation starts in seconds.
@@ -471,6 +471,11 @@ function gui.get_texture(node) end
471471
---@return number tracking scaling number (default=0)
472472
function gui.get_tracking(node) end
473473

474+
---Get a node and all its children as a Lua table.
475+
---@param node node root node to get node tree from
476+
---@return table a table mapping node ids to the corresponding nodes
477+
function gui.get_tree(node) end
478+
474479
---Returns true if a node is visible and false if it's not.
475480
---Invisible nodes are not rendered.
476481
---@param node node node to query

DefoldDocs/api/liveupdate.lua

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
---LiveUpdate API documentation
2+
---Functions and constants to access resources.
3+
---@class liveupdate
4+
liveupdate = {}
5+
---Return a reference to the Manifest that is currently loaded.
6+
---@return number reference to the Manifest that is currently loaded
7+
function liveupdate.get_current_manifest() end
8+
9+
---Is any liveupdate data mounted and currently in use?
10+
---This can be used to determine if a new manifest or zip file should be downloaded.
11+
---@return bool true if a liveupdate archive (any format) has been loaded
12+
function liveupdate.is_using_liveupdate_data() end
13+
14+
---Stores a zip file and uses it for live update content. The contents of the
15+
---zip file will be verified against the manifest to ensure file integrity.
16+
---It is possible to opt out of the resource verification using an option passed
17+
---to this function.
18+
---The path is stored in the (internal) live update location.
19+
---@param path string the path to the original file on disc
20+
---@param callback function(self, status) the callback function executed after the storage has completed
21+
---@param options table optional table with extra parameters. Supported entries:
22+
function liveupdate.store_archive(path, callback, options) end
23+
24+
---Create a new manifest from a buffer. The created manifest is verified
25+
---by ensuring that the manifest was signed using the bundled public/private
26+
---key-pair during the bundle process and that the manifest supports the current
27+
---running engine version. Once the manifest is verified it is stored on device.
28+
---The next time the engine starts (or is rebooted) it will look for the stored
29+
---manifest before loading resources. Storing a new manifest allows the
30+
---developer to update the game, modify existing resources, or add new
31+
---resources to the game through LiveUpdate.
32+
---@param manifest_buffer string the binary data that represents the manifest
33+
---@param callback function(self, status) the callback function executed once the engine has attempted to store the manifest.
34+
function liveupdate.store_manifest(manifest_buffer, callback) end
35+
36+
---add a resource to the data archive and runtime index. The resource will be verified
37+
---internally before being added to the data archive.
38+
---@param manifest_reference number The manifest to check against.
39+
---@param data string The resource data that should be stored.
40+
---@param hexdigest string The expected hash for the resource, retrieved through collectionproxy.missing_resources.
41+
---@param callback function(self, hexdigest, status) The callback function that is executed once the engine has been attempted to store the resource.
42+
function liveupdate.store_resource(manifest_reference, data, hexdigest, callback) end
43+
44+
45+
46+
47+
return liveupdate

DefoldDocs/api/render.lua

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,8 @@ function render.enable_state(state) end
136136
---used as texture with the specified unit.
137137
---A material shader can then use the texture to sample from.
138138
---@param unit number texture unit to enable texture for
139-
---@param render_target render_target render target from which to enable the specified texture unit
140-
---@param buffer_type constant buffer type from which to enable the texture
139+
---@param render_target handle render target or texture from which to enable the specified texture unit
140+
---@param buffer_type constant optional buffer type from which to enable the texture. Note that this argument only applies to render targets. Defaults to render.BUFFER_COLOR_BIT
141141
function render.enable_texture(unit, render_target, buffer_type) end
142142

143143
---Returns the logical window height that is set in the "game.project" settings.
@@ -202,6 +202,13 @@ function render.predicate(tags) end
202202
---The render target can be created to support multiple color attachments. Each attachment can have different format settings and texture filters,
203203
---but attachments must be added in sequence, meaning you cannot create a render target at slot 0 and 3.
204204
---Instead it has to be created with all four buffer types ranging from [0..3] (as denoted by render.BUFFER_COLORX_BIT where 'X' is the attachment you want to create).
205+
---It is not guaranteed that the device running the script can support creating render targets with multiple color attachments. To check if the device can support multiple attachments,
206+
---you can check if the render table contains any of the BUFFER_COLOR1_BIT, BUFFER_COLOR2_BIT or BUFFER_COLOR3_BIT constants:
207+
---function init(self)
208+
--- if render.BUFFER_COLOR1_BIT == nil then
209+
--- -- this devices does not support multiple color attachments
210+
--- end
211+
---end
205212
---@param name string render target name
206213
---@param parameters table table of buffer parameters, see the description for available keys and values
207214
---@return render_target new render target

DefoldDocs/api/resource.lua

Lines changed: 37 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -6,28 +6,28 @@ resource = {}
66
resource.COMPRESSION_TYPE_BASIS_UASTC = nil
77
---COMPRESSION_TYPE_DEFAULT compression type
88
resource.COMPRESSION_TYPE_DEFAULT = nil
9-
---LIVEUPDATE_BUNDLED_RESOURCE_MISMATCH
10-
resource.LIVEUPDATE_BUNDLED_RESOURCE_MISMATCH = nil
11-
---LIVEUPDATE_ENGINE_VERSION_MISMATCH
12-
resource.LIVEUPDATE_ENGINE_VERSION_MISMATCH = nil
13-
---LIVEUPDATE_FORMAT_ERROR
14-
resource.LIVEUPDATE_FORMAT_ERROR = nil
15-
---LIVEUPDATE_INVALID_RESOURCE
16-
resource.LIVEUPDATE_INVALID_RESOURCE = nil
17-
---LIVEUPDATE_OK
18-
resource.LIVEUPDATE_OK = nil
19-
---LIVEUPDATE_SCHEME_MISMATCH
20-
resource.LIVEUPDATE_SCHEME_MISMATCH = nil
21-
---LIVEUPDATE_SIGNATURE_MISMATCH
22-
resource.LIVEUPDATE_SIGNATURE_MISMATCH = nil
23-
---LIVEUPDATE_VERSION_MISMATCH
24-
resource.LIVEUPDATE_VERSION_MISMATCH = nil
259
---luminance type texture format
2610
resource.TEXTURE_FORMAT_LUMINANCE = nil
11+
---R16F type texture format
12+
resource.TEXTURE_FORMAT_R16F = nil
13+
---R32F type texture format
14+
resource.TEXTURE_FORMAT_R32F = nil
15+
---RG16F type texture format
16+
resource.TEXTURE_FORMAT_RG16F = nil
17+
---RG32F type texture format
18+
resource.TEXTURE_FORMAT_RG32F = nil
2719
---RGB type texture format
2820
resource.TEXTURE_FORMAT_RGB = nil
21+
---RGB16F type texture format
22+
resource.TEXTURE_FORMAT_RGB16F = nil
23+
---RGB32F type texture format
24+
resource.TEXTURE_FORMAT_RGB32F = nil
2925
---RGBA type texture format
3026
resource.TEXTURE_FORMAT_RGBA = nil
27+
---RGBA16F type texture format
28+
resource.TEXTURE_FORMAT_RGBA16F = nil
29+
---RGBA32F type texture format
30+
resource.TEXTURE_FORMAT_RGBA32F = nil
3131
---RGBA_ASTC_4x4 type texture format
3232
resource.TEXTURE_FORMAT_RGBA_ASTC_4x4 = nil
3333
---RGBA_BC3 type texture format
@@ -54,6 +54,8 @@ resource.TEXTURE_FORMAT_RG_BC5 = nil
5454
resource.TEXTURE_FORMAT_R_BC4 = nil
5555
---2D texture type
5656
resource.TEXTURE_TYPE_2D = nil
57+
---2D Array texture type
58+
resource.TEXTURE_TYPE_2D_ARRAY = nil
5759
---Cube map texture type
5860
resource.TEXTURE_TYPE_CUBE_MAP = nil
5961
---Constructor-like function with two purposes:
@@ -95,15 +97,29 @@ function resource.buffer(path) end
9597
---@return hash Returns the atlas resource path
9698
function resource.create_atlas(path, table) end
9799

100+
---This function creates a new buffer resource that can be used in the same way as any buffer created during build time.
101+
---The function requires a valid buffer created from either buffer.create <> or another pre-existing buffer resource.
102+
---By default, the new resource will take ownership of the buffer lua reference, meaning the buffer will not automatically be removed
103+
---when the lua reference to the buffer is garbage collected. This behaviour can be overruled by specifying 'transfer_ownership = false'
104+
---in the argument table. If the new buffer resource is created from a buffer object that is created by another resource,
105+
---the buffer object will be copied and the new resource will effectively own a copy of the buffer instead.
106+
---Note that the path to the new resource must have the '.bufferc' extension, "/path/my_buffer" is not a valid path but "/path/my_buffer.bufferc" is.
107+
---The path must also be unique, attempting to create a buffer with the same name as an existing resource will raise an error.
108+
---@param path string The path to the resource.
109+
---@param table table A table containing info about how to create the buffer. Supported entries:
110+
---@return hash Returns the buffer resource path
111+
function resource.create_buffer(path, table) end
112+
98113
---Creates a new texture resource that can be used in the same way as any texture created during build time.
99114
---The path used for creating the texture must be unique, trying to create a resource at a path that is already
100115
---registered will trigger an error. If the intention is to instead modify an existing texture, use the resource.set_texture <>
101116
---function. Also note that the path to the new texture resource must have a '.texturec' extension,
102117
---meaning "/path/my_texture" is not a valid path but "/path/my_texture.texturec" is.
103118
---@param path string The path to the resource.
104119
---@param table table A table containing info about how to create the texture. Supported entries:
120+
---@param buffer buffer optional buffer of precreated pixel data
105121
---@return hash The path to the resource.
106-
function resource.create_texture(path, table) end
122+
function resource.create_texture(path, table, buffer) end
107123

108124
---Constructor-like function with two purposes:
109125
---
@@ -127,21 +143,17 @@ function resource.get_atlas(path) end
127143
---@return buffer The resource buffer
128144
function resource.get_buffer(path) end
129145

130-
---Return a reference to the Manifest that is currently loaded.
131-
---@return number reference to the Manifest that is currently loaded
132-
function resource.get_current_manifest() end
133-
134146
---Gets the text metrics from a font
135147
---@param url hash the font to get the (unscaled) metrics from
136148
---@param text string text to measure
137149
---@param options table A table containing parameters for the text. Supported entries:
138150
---@return table a table with the following fields:
139151
function resource.get_text_metrics(url, text, options) end
140152

141-
---Is any liveupdate data mounted and currently in use?
142-
---This can be used to determine if a new manifest or zip file should be downloaded.
143-
---@return bool true if a liveupdate archive (any format) has been loaded
144-
function resource.is_using_liveupdate_data() end
153+
---Gets texture info from a texture resource path or a texture handle
154+
---@param path hash|string|handle The path to the resource or a texture handle
155+
---@return table A table containing info about the texture:
156+
function resource.get_texture_info(path) end
145157

146158
---Loads the resource data for a specific resource.
147159
---@param path string The path to the resource
@@ -201,36 +213,6 @@ function resource.set_sound(path, buffer) end
201213
---@param buffer buffer The buffer of precreated pixel data To update a cube map texture you need to pass in six times the amount of data via the buffer, since a cube map has six sides!
202214
function resource.set_texture(path, table, buffer) end
203215

204-
---Stores a zip file and uses it for live update content. The contents of the
205-
---zip file will be verified against the manifest to ensure file integrity.
206-
---It is possible to opt out of the resource verification using an option passed
207-
---to this function.
208-
---The path is stored in the (internal) live update location.
209-
---@param path string the path to the original file on disc
210-
---@param callback function(self, status) the callback function executed after the storage has completed
211-
---@param options table optional table with extra parameters. Supported entries:
212-
function resource.store_archive(path, callback, options) end
213-
214-
---Create a new manifest from a buffer. The created manifest is verified
215-
---by ensuring that the manifest was signed using the bundled public/private
216-
---key-pair during the bundle process and that the manifest supports the current
217-
---running engine version. Once the manifest is verified it is stored on device.
218-
---The next time the engine starts (or is rebooted) it will look for the stored
219-
---manifest before loading resources. Storing a new manifest allows the
220-
---developer to update the game, modify existing resources, or add new
221-
---resources to the game through LiveUpdate.
222-
---@param manifest_buffer string the binary data that represents the manifest
223-
---@param callback function(self, status) the callback function executed once the engine has attempted to store the manifest.
224-
function resource.store_manifest(manifest_buffer, callback) end
225-
226-
---add a resource to the data archive and runtime index. The resource will be verified
227-
---internally before being added to the data archive.
228-
---@param manifest_reference number The manifest to check against.
229-
---@param data string The resource data that should be stored.
230-
---@param hexdigest string The expected hash for the resource, retrieved through collectionproxy.missing_resources.
231-
---@param callback function(self, hexdigest, status) The callback function that is executed once the engine has been attempted to store the resource.
232-
function resource.store_resource(manifest_reference, data, hexdigest, callback) end
233-
234216
---Constructor-like function with two purposes:
235217
---
236218
---

DefoldDocs/api/system.lua

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,12 @@ function sys.get_connectivity() end
5959
---@return table table with engine information in the following fields:
6060
function sys.get_engine_info() end
6161

62+
---Create a path to the host device for unit testing
63+
---Useful for saving logs etc during development
64+
---@param filename string file to read from
65+
---@return string the path prefixed with the proper host mount
66+
function sys.get_host_path(filename) end
67+
6268
---Returns an array of tables with information on network interfaces.
6369
---@return table an array of tables. Each table entry contain the following fields:
6470
function sys.get_ifaddrs() end

DefoldDocs/api/timer.lua

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,14 @@ function timer.cancel(handle) end
2222
---@param delay number time interval in seconds
2323
---@param _repeat boolean true = repeat timer until cancel, false = one-shot timer
2424
---@param callback function(self, handle, time_elapsed) timer callback function
25-
---@return hash handle identifier for the create timer, returns timer.INVALID_TIMER_HANDLE if the timer can not be created
25+
---@return hash identifier for the create timer, returns timer.INVALID_TIMER_HANDLE if the timer can not be created
2626
function timer.delay(delay, _repeat, callback) end
2727

28+
---Get information about timer.
29+
---@param handle hash the timer handle returned by timer.delay()
30+
---@return table or nil if timer is cancelled/completed. table with data in the following fields:
31+
function timer.get_info(handle) end
32+
2833
---Manual triggering a callback for a timer.
2934
---@param handle hash the timer handle returned by timer.delay()
3035
---@return boolean if the timer was active, false if the timer is already cancelled / complete

0 commit comments

Comments
 (0)