Skip to content

Commit 42c22fb

Browse files
committed
Defold engine meta
1 parent 213f517 commit 42c22fb

33 files changed

+4522
-0
lines changed

meta/3rd/Defold/config.lua

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
name = 'Defold'
2+
files = {'game.project'}
3+
configs = {
4+
{
5+
key = 'Lua.runtime.version',
6+
action = 'set',
7+
value = 'Lua 5.1',
8+
},
9+
}

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/bitop.lua

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
---Bitwise operations API documentation
2+
---Lua BitOp <http://bitop.luajit.org/api.html> is a C extension module for Lua 5.1/5.2 which adds bitwise operations on numbers.
3+
---Lua BitOp is Copyright © 2008-2012 Mike Pall.
4+
---Lua BitOp is free software, released under the MIT license (same license as the Lua core).
5+
---Lua BitOp is compatible with the built-in bitwise operations in LuaJIT 2.0 and is used
6+
---on platforms where Defold runs without LuaJIT.
7+
---For clarity the examples assume the definition of a helper function printx().
8+
---This prints its argument as an unsigned 32 bit hexadecimal number on all platforms:
9+
---function printx(x)
10+
--- print("0x"..bit.tohex(x))
11+
---end
12+
13+
---@class bit
14+
bit = {}
15+
---Returns the bitwise arithmetic right-shift of its first argument by the number of bits given by the second argument.
16+
---Arithmetic right-shift treats the most-significant bit as a sign bit and replicates it.
17+
---Only the lower 5 bits of the shift count are used (reduces to the range [0..31]).
18+
---@param x number # number
19+
---@param n number # number of bits
20+
---@return number # bitwise arithmetic right-shifted number
21+
function bit.arshift(x, n) end
22+
23+
---Returns the bitwise and of all of its arguments. Note that more than two arguments are allowed.
24+
---@param x1 number # number
25+
--- ... number? # number(s)
26+
---@return number # bitwise and of the provided arguments
27+
function bit.band(x1, ...) end
28+
29+
---Returns the bitwise not of its argument.
30+
---@param x number # number
31+
---@return number # bitwise not of number x
32+
function bit.bnot(x) end
33+
34+
---Returns the bitwise or of all of its arguments. Note that more than two arguments are allowed.
35+
---@param x1 number # number
36+
--- ... number? # number(s)
37+
---@return number # bitwise or of the provided arguments
38+
function bit.bor(x1, ...) end
39+
40+
---Swaps the bytes of its argument and returns it. This can be used to convert little-endian 32 bit numbers to big-endian 32 bit numbers or vice versa.
41+
---@param x number # number
42+
---@return number # bitwise swapped number
43+
function bit.bswap(x) end
44+
45+
---Returns the bitwise xor of all of its arguments. Note that more than two arguments are allowed.
46+
---@param x1 number # number
47+
--- ... number? # number(s)
48+
---@return number # bitwise xor of the provided arguments
49+
function bit.bxor(x1, ...) end
50+
51+
---Returns the bitwise logical left-shift of its first argument by the number of bits given by the second argument.
52+
---Logical shifts treat the first argument as an unsigned number and shift in 0-bits.
53+
---Only the lower 5 bits of the shift count are used (reduces to the range [0..31]).
54+
---@param x number # number
55+
---@param n number # number of bits
56+
---@return number # bitwise logical left-shifted number
57+
function bit.lshift(x, n) end
58+
59+
---Returns the bitwise left rotation of its first argument by the number of bits given by the second argument. Bits shifted out on one side are shifted back in on the other side.
60+
---Only the lower 5 bits of the rotate count are used (reduces to the range [0..31]).
61+
---@param x number # number
62+
---@param n number # number of bits
63+
---@return number # bitwise left-rotated number
64+
function bit.rol(x, n) end
65+
66+
---Returns the bitwise right rotation of its first argument by the number of bits given by the second argument. Bits shifted out on one side are shifted back in on the other side.
67+
---Only the lower 5 bits of the rotate count are used (reduces to the range [0..31]).
68+
---@param x number # number
69+
---@param n number # number of bits
70+
---@return number # bitwise right-rotated number
71+
function bit.ror(x, n) end
72+
73+
---Returns the bitwise logical right-shift of its first argument by the number of bits given by the second argument.
74+
---Logical shifts treat the first argument as an unsigned number and shift in 0-bits.
75+
---Only the lower 5 bits of the shift count are used (reduces to the range [0..31]).
76+
---@param x number # number
77+
---@param n number # number of bits
78+
---@return number # bitwise logical right-shifted number
79+
function bit.rshift(x, n) end
80+
81+
---Normalizes a number to the numeric range for bit operations and returns it. This function is usually not needed since all bit operations already normalize all of their input arguments.
82+
---@param x number # number to normalize
83+
---@return number # normalized number
84+
function bit.tobit(x) end
85+
86+
---Converts its first argument to a hex string. The number of hex digits is given by the absolute value of the optional second argument. Positive numbers between 1 and 8 generate lowercase hex digits. Negative numbers generate uppercase hex digits. Only the least-significant 4*|n| bits are used. The default is to generate 8 lowercase hex digits.
87+
---@param x number # number to convert
88+
---@param n number # number of hex digits to return
89+
---@return string # hexadecimal string
90+
function bit.tohex(x, n) end
91+
92+
93+
94+
95+
return bit

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)