Skip to content

Commit 87f7418

Browse files
authored
Merge pull request #1665 from SalavatR/master
Defold engine meta
2 parents 1fd5474 + 893121d commit 87f7418

30 files changed

+4101
-0
lines changed

meta/3rd/Defold/config.lua

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name = 'Defold'
2+
files = {'game.project', '*%.script', '*%.gui_script'}
3+
configs = {
4+
{
5+
key = 'Lua.runtime.version',
6+
action = 'set',
7+
value = 'Lua 5.1',
8+
},
9+
{
10+
key = 'Lua.workspace.library',
11+
action = 'set',
12+
value = {".internal"},
13+
},
14+
{
15+
key = 'Lua.workspace.ignoreDir',
16+
action = 'set',
17+
value = {".internal"},
18+
},
19+
{
20+
key = 'Lua.diagnostics.globals',
21+
action = 'set',
22+
value = {
23+
"on_input",
24+
"on_message",
25+
"init",
26+
"update",
27+
"final"
28+
},
29+
},
30+
{
31+
key = 'files.associations',
32+
action = 'set',
33+
value = {
34+
["*.script"] = "lua",
35+
["*.gui_script"] = "lua",
36+
["*.render_script"] = "lua",
37+
["*.editor_script"] = "lua"
38+
}
39+
},
40+
}

meta/3rd/Defold/library/base.lua

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
------@meta
2+
---
3+
---
4+
---@class vector3
5+
---@field x number
6+
---@field y number
7+
---@field z number
8+
---@operator sub(vector3): vector3
9+
---@operator add(vector3): vector3
10+
11+
---@class vector4
12+
---@field x number
13+
---@field y number
14+
---@field z number
15+
---@field w number
16+
---@operator sub(vector4): vector4
17+
---@operator add(vector4): vector4
18+
19+
---@class quaternion
20+
---@field x number
21+
---@field y number
22+
---@field z number
23+
---@field w number
24+
25+
---@alias quat quaternion
26+
27+
---@class url string|hash
28+
---@field socket string|hash
29+
---@field path string|hash
30+
---@field fragment string|hash
31+
32+
---@alias hash userdata
33+
---@alias constant userdata
34+
---@alias bool boolean
35+
---@alias float number
36+
---@alias object userdata
37+
---@alias matrix4 userdata
38+
---@alias node userdata
39+
40+
--mb use number instead of vector4
41+
---@alias vector vector4
42+
43+
--luasocket
44+
---@alias master userdata
45+
---@alias unconnected userdata
46+
---@alias client userdata
47+
48+
--render
49+
---@alias constant_buffer userdata
50+
---@alias render_target userdata
51+
---@alias predicate userdata
52+
53+
--- Calls error if the value of its argument `v` is false (i.e., **nil** or
54+
--- **false**); otherwise, returns all its arguments. In case of error,
55+
--- `message` is the error object; when absent, it defaults to "assertion
56+
--- failed!"
57+
---@generic ANY
58+
---@overload fun(v:any):any
59+
---@param v ANY
60+
---@param message string
61+
---@return ANY
62+
function assert(v,message) return v end
63+
64+
---@param self object
65+
function init(self) end
66+
67+
---@param self object
68+
---@param dt number
69+
function update(self, dt) end
70+
71+
---@param self object
72+
---@param message_id hash
73+
---@param message table
74+
---@param sender url
75+
function on_message(self, message_id, message, sender) end
76+
77+
---@param self object
78+
---@param action_id hash
79+
---@param action table
80+
function on_input(self, action_id, action) end
81+
82+
---@param self object
83+
function final(self) end;

meta/3rd/Defold/library/buffer.lua

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
---Buffer API documentation
2+
---Functions for manipulating buffers and streams
3+
---@class buffer
4+
buffer = {}
5+
---float32
6+
buffer.VALUE_TYPE_FLOAT32 = nil
7+
---int16
8+
buffer.VALUE_TYPE_INT16 = nil
9+
---int32
10+
buffer.VALUE_TYPE_INT32 = nil
11+
---int64
12+
buffer.VALUE_TYPE_INT64 = nil
13+
---int8
14+
buffer.VALUE_TYPE_INT8 = nil
15+
---uint16
16+
buffer.VALUE_TYPE_UINT16 = nil
17+
---uint32
18+
buffer.VALUE_TYPE_UINT32 = nil
19+
---uint64
20+
buffer.VALUE_TYPE_UINT64 = nil
21+
---uint8
22+
buffer.VALUE_TYPE_UINT8 = nil
23+
---Copy all data streams from one buffer to another, element wise.
24+
--- Each of the source streams must have a matching stream in the
25+
---destination buffer. The streams must match in both type and size.
26+
---The source and destination buffer can be the same.
27+
---@param dst buffer # the destination buffer
28+
---@param dstoffset number # the offset to start copying data to
29+
---@param src buffer # the source data buffer
30+
---@param srcoffset number # the offset to start copying data from
31+
---@param count number # the number of elements to copy
32+
function buffer.copy_buffer(dst, dstoffset, src, srcoffset, count) end
33+
34+
---Copy a specified amount of data from one stream to another.
35+
--- The value type and size must match between source and destination streams.
36+
---The source and destination streams can be the same.
37+
---@param dst bufferstream # the destination stream
38+
---@param dstoffset number # the offset to start copying data to (measured in value type)
39+
---@param src bufferstream # the source data stream
40+
---@param srcoffset number # the offset to start copying data from (measured in value type)
41+
---@param count number # the number of values to copy (measured in value type)
42+
function buffer.copy_stream(dst, dstoffset, src, srcoffset, count) end
43+
44+
---Create a new data buffer containing a specified set of streams. A data buffer
45+
---can contain one or more streams with typed data. This is useful for managing
46+
---compound data, for instance a vertex buffer could contain separate streams for
47+
---vertex position, color, normal etc.
48+
---@param element_count number # The number of elements the buffer should hold
49+
---@param declaration table # A table where each entry (table) describes a stream
50+
---@return buffer # the new buffer
51+
function buffer.create(element_count, declaration) end
52+
53+
---Get a copy of all the bytes from a specified stream as a Lua string.
54+
---@param buffer buffer # the source buffer
55+
---@param stream_name hash # the name of the stream
56+
---@return string # the buffer data as a Lua string
57+
function buffer.get_bytes(buffer, stream_name) end
58+
59+
---Get a specified stream from a buffer.
60+
---@param buffer buffer # the buffer to get the stream from
61+
---@param stream_name hash|string # the stream name
62+
---@return bufferstream # the data stream
63+
function buffer.get_stream(buffer, stream_name) end
64+
65+
66+
67+
68+
return buffer
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
---Built-ins API documentation
2+
---Built-in scripting functions.
3+
4+
---All ids in the engine are represented as hashes, so a string needs to be hashed
5+
---before it can be compared with an id.
6+
---@param s string # string to hash
7+
---@return hash # a hashed string
8+
function hash(s) end
9+
10+
---Returns a hexadecimal representation of a hash value.
11+
---The returned string is always padded with leading zeros.
12+
---@param h hash # hash value to get hex string for
13+
---@return string # hex representation of the hash
14+
function hash_to_hex(h) end
15+
16+
---Pretty printing of Lua values. This function prints Lua values
17+
---in a manner similar to +print()+, but will also recurse into tables
18+
---and pretty print them. There is a limit to how deep the function
19+
---will recurse.
20+
---@param v any # value to print
21+
function pprint(v) end
22+
23+
24+
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
---Collection factory API documentation
2+
---Functions for controlling collection factory components which are
3+
---used to dynamically spawn collections into the runtime.
4+
---@class collectionfactory
5+
collectionfactory = {}
6+
---loaded
7+
collectionfactory.STATUS_LOADED = nil
8+
---loading
9+
collectionfactory.STATUS_LOADING = nil
10+
---unloaded
11+
collectionfactory.STATUS_UNLOADED = nil
12+
---The URL identifies the collectionfactory component that should do the spawning.
13+
---Spawning is instant, but spawned game objects get their first update calls the following frame. The supplied parameters for position, rotation and scale
14+
---will be applied to the whole collection when spawned.
15+
---Script properties in the created game objects can be overridden through
16+
---a properties-parameter table. The table should contain game object ids
17+
---(hash) as keys and property tables as values to be used when initiating each
18+
---spawned game object.
19+
---See go.property for more information on script properties.
20+
---The function returns a table that contains a key for each game object
21+
---id (hash), as addressed if the collection file was top level, and the
22+
---corresponding spawned instance id (hash) as value with a unique path
23+
---prefix added to each instance.
24+
--- Calling collectionfactory.create <> create on a collection factory that is marked as dynamic without having loaded resources
25+
---using collectionfactory.load <> will synchronously load and create resources which may affect application performance.
26+
---@param url string|hash|url # the collection factory component to be used
27+
---@param position vector3? # position to assign to the newly spawned collection
28+
---@param rotation quaternion? # rotation to assign to the newly spawned collection
29+
---@param properties table? # table of script properties to propagate to any new game object instances
30+
---@param scale number? # uniform scaling to apply to the newly spawned collection (must be greater than 0).
31+
---@return table # a table mapping the id:s from the collection to the new instance id:s
32+
function collectionfactory.create(url, position, rotation, properties, scale) end
33+
34+
---This returns status of the collection factory.
35+
---Calling this function when the factory is not marked as dynamic loading always returns COMP_COLLECTION_FACTORY_STATUS_LOADED.
36+
---@param url string|hash|url? # the collection factory component to get status from
37+
---@return constant # status of the collection factory component
38+
function collectionfactory.get_status(url) end
39+
40+
---Resources loaded are referenced by the collection factory component until the existing (parent) collection is destroyed or collectionfactory.unload is called.
41+
---Calling this function when the factory is not marked as dynamic loading does nothing.
42+
---@param url string|hash|url? # the collection factory component to load
43+
---@param complete_function (fun(self: object, url: url, result: boolean))? # function to call when resources are loaded.
44+
function collectionfactory.load(url, complete_function) end
45+
46+
---This decreases the reference count for each resource loaded with collectionfactory.load. If reference is zero, the resource is destroyed.
47+
---Calling this function when the factory is not marked as dynamic loading does nothing.
48+
---@param url string|hash|url? # the collection factory component to unload
49+
function collectionfactory.unload(url) end
50+
51+
52+
53+
54+
return collectionfactory
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---Collection proxy API documentation
2+
---Messages for controlling and interacting with collection proxies
3+
---which are used to dynamically load collections into the runtime.
4+
---@class collectionproxy
5+
collectionproxy = {}
6+
7+
8+
9+
return collectionproxy

0 commit comments

Comments
 (0)