diff options
Diffstat (limited to 'meta')
51 files changed, 4660 insertions, 116 deletions
diff --git a/meta/3rd/Defold/config.lua b/meta/3rd/Defold/config.lua new file mode 100644 index 00000000..f4dad34e --- /dev/null +++ b/meta/3rd/Defold/config.lua @@ -0,0 +1,40 @@ +name = 'Defold' +files = {'game.project', '*%.script', '*%.gui_script'} +configs = { + { + key = 'Lua.runtime.version', + action = 'set', + value = 'Lua 5.1', + }, + { + key = 'Lua.workspace.library', + action = 'set', + value = {".internal"}, + }, + { + key = 'Lua.workspace.ignoreDir', + action = 'set', + value = {".internal"}, + }, + { + key = 'Lua.diagnostics.globals', + action = 'set', + value = { + "on_input", + "on_message", + "init", + "update", + "final" + }, + }, + { + key = 'files.associations', + action = 'set', + value = { + ["*.script"] = "lua", + ["*.gui_script"] = "lua", + ["*.render_script"] = "lua", + ["*.editor_script"] = "lua" + } + }, +} diff --git a/meta/3rd/Defold/library/base.lua b/meta/3rd/Defold/library/base.lua new file mode 100644 index 00000000..5aac30df --- /dev/null +++ b/meta/3rd/Defold/library/base.lua @@ -0,0 +1,83 @@ +------@meta +--- +--- +---@class vector3 +---@field x number +---@field y number +---@field z number +---@operator sub(vector3): vector3 +---@operator add(vector3): vector3 + +---@class vector4 +---@field x number +---@field y number +---@field z number +---@field w number +---@operator sub(vector4): vector4 +---@operator add(vector4): vector4 + +---@class quaternion +---@field x number +---@field y number +---@field z number +---@field w number + +---@alias quat quaternion + +---@class url string|hash +---@field socket string|hash +---@field path string|hash +---@field fragment string|hash + +---@alias hash userdata +---@alias constant userdata +---@alias bool boolean +---@alias float number +---@alias object userdata +---@alias matrix4 userdata +---@alias node userdata + +--mb use number instead of vector4 +---@alias vector vector4 + +--luasocket +---@alias master userdata +---@alias unconnected userdata +---@alias client userdata + +--render +---@alias constant_buffer userdata +---@alias render_target userdata +---@alias predicate userdata + +--- Calls error if the value of its argument `v` is false (i.e., **nil** or +--- **false**); otherwise, returns all its arguments. In case of error, +--- `message` is the error object; when absent, it defaults to "assertion +--- failed!" +---@generic ANY +---@overload fun(v:any):any +---@param v ANY +---@param message string +---@return ANY +function assert(v,message) return v end + +---@param self object +function init(self) end + +---@param self object +---@param dt number +function update(self, dt) end + +---@param self object +---@param message_id hash +---@param message table +---@param sender url +function on_message(self, message_id, message, sender) end + +---@param self object +---@param action_id hash +---@param action table +function on_input(self, action_id, action) end + +---@param self object +function final(self) end; diff --git a/meta/3rd/Defold/library/buffer.lua b/meta/3rd/Defold/library/buffer.lua new file mode 100644 index 00000000..d5841e3c --- /dev/null +++ b/meta/3rd/Defold/library/buffer.lua @@ -0,0 +1,68 @@ +---Buffer API documentation +---Functions for manipulating buffers and streams +---@class buffer +buffer = {} +---float32 +buffer.VALUE_TYPE_FLOAT32 = nil +---int16 +buffer.VALUE_TYPE_INT16 = nil +---int32 +buffer.VALUE_TYPE_INT32 = nil +---int64 +buffer.VALUE_TYPE_INT64 = nil +---int8 +buffer.VALUE_TYPE_INT8 = nil +---uint16 +buffer.VALUE_TYPE_UINT16 = nil +---uint32 +buffer.VALUE_TYPE_UINT32 = nil +---uint64 +buffer.VALUE_TYPE_UINT64 = nil +---uint8 +buffer.VALUE_TYPE_UINT8 = nil +---Copy all data streams from one buffer to another, element wise. +--- Each of the source streams must have a matching stream in the +---destination buffer. The streams must match in both type and size. +---The source and destination buffer can be the same. +---@param dst buffer # the destination buffer +---@param dstoffset number # the offset to start copying data to +---@param src buffer # the source data buffer +---@param srcoffset number # the offset to start copying data from +---@param count number # the number of elements to copy +function buffer.copy_buffer(dst, dstoffset, src, srcoffset, count) end + +---Copy a specified amount of data from one stream to another. +--- The value type and size must match between source and destination streams. +---The source and destination streams can be the same. +---@param dst bufferstream # the destination stream +---@param dstoffset number # the offset to start copying data to (measured in value type) +---@param src bufferstream # the source data stream +---@param srcoffset number # the offset to start copying data from (measured in value type) +---@param count number # the number of values to copy (measured in value type) +function buffer.copy_stream(dst, dstoffset, src, srcoffset, count) end + +---Create a new data buffer containing a specified set of streams. A data buffer +---can contain one or more streams with typed data. This is useful for managing +---compound data, for instance a vertex buffer could contain separate streams for +---vertex position, color, normal etc. +---@param element_count number # The number of elements the buffer should hold +---@param declaration table # A table where each entry (table) describes a stream +---@return buffer # the new buffer +function buffer.create(element_count, declaration) end + +---Get a copy of all the bytes from a specified stream as a Lua string. +---@param buffer buffer # the source buffer +---@param stream_name hash # the name of the stream +---@return string # the buffer data as a Lua string +function buffer.get_bytes(buffer, stream_name) end + +---Get a specified stream from a buffer. +---@param buffer buffer # the buffer to get the stream from +---@param stream_name hash|string # the stream name +---@return bufferstream # the data stream +function buffer.get_stream(buffer, stream_name) end + + + + +return buffer
\ No newline at end of file diff --git a/meta/3rd/Defold/library/built-ins.lua b/meta/3rd/Defold/library/built-ins.lua new file mode 100644 index 00000000..9365baf0 --- /dev/null +++ b/meta/3rd/Defold/library/built-ins.lua @@ -0,0 +1,24 @@ +---Built-ins API documentation +---Built-in scripting functions. + +---All ids in the engine are represented as hashes, so a string needs to be hashed +---before it can be compared with an id. +---@param s string # string to hash +---@return hash # a hashed string +function hash(s) end + +---Returns a hexadecimal representation of a hash value. +---The returned string is always padded with leading zeros. +---@param h hash # hash value to get hex string for +---@return string # hex representation of the hash +function hash_to_hex(h) end + +---Pretty printing of Lua values. This function prints Lua values +---in a manner similar to +print()+, but will also recurse into tables +---and pretty print them. There is a limit to how deep the function +---will recurse. +---@param v any # value to print +function pprint(v) end + + + diff --git a/meta/3rd/Defold/library/collection_factory.lua b/meta/3rd/Defold/library/collection_factory.lua new file mode 100644 index 00000000..e96137a8 --- /dev/null +++ b/meta/3rd/Defold/library/collection_factory.lua @@ -0,0 +1,54 @@ +---Collection factory API documentation +---Functions for controlling collection factory components which are +---used to dynamically spawn collections into the runtime. +---@class collectionfactory +collectionfactory = {} +---loaded +collectionfactory.STATUS_LOADED = nil +---loading +collectionfactory.STATUS_LOADING = nil +---unloaded +collectionfactory.STATUS_UNLOADED = nil +---The URL identifies the collectionfactory component that should do the spawning. +---Spawning is instant, but spawned game objects get their first update calls the following frame. The supplied parameters for position, rotation and scale +---will be applied to the whole collection when spawned. +---Script properties in the created game objects can be overridden through +---a properties-parameter table. The table should contain game object ids +---(hash) as keys and property tables as values to be used when initiating each +---spawned game object. +---See go.property for more information on script properties. +---The function returns a table that contains a key for each game object +---id (hash), as addressed if the collection file was top level, and the +---corresponding spawned instance id (hash) as value with a unique path +---prefix added to each instance. +--- Calling collectionfactory.create <> create on a collection factory that is marked as dynamic without having loaded resources +---using collectionfactory.load <> will synchronously load and create resources which may affect application performance. +---@param url string|hash|url # the collection factory component to be used +---@param position vector3? # position to assign to the newly spawned collection +---@param rotation quaternion? # rotation to assign to the newly spawned collection +---@param properties table? # table of script properties to propagate to any new game object instances +---@param scale number? # uniform scaling to apply to the newly spawned collection (must be greater than 0). +---@return table # a table mapping the id:s from the collection to the new instance id:s +function collectionfactory.create(url, position, rotation, properties, scale) end + +---This returns status of the collection factory. +---Calling this function when the factory is not marked as dynamic loading always returns COMP_COLLECTION_FACTORY_STATUS_LOADED. +---@param url string|hash|url? # the collection factory component to get status from +---@return constant # status of the collection factory component +function collectionfactory.get_status(url) end + +---Resources loaded are referenced by the collection factory component until the existing (parent) collection is destroyed or collectionfactory.unload is called. +---Calling this function when the factory is not marked as dynamic loading does nothing. +---@param url string|hash|url? # the collection factory component to load +---@param complete_function (fun(self: object, url: url, result: boolean))? # function to call when resources are loaded. +function collectionfactory.load(url, complete_function) end + +---This decreases the reference count for each resource loaded with collectionfactory.load. If reference is zero, the resource is destroyed. +---Calling this function when the factory is not marked as dynamic loading does nothing. +---@param url string|hash|url? # the collection factory component to unload +function collectionfactory.unload(url) end + + + + +return collectionfactory
\ No newline at end of file diff --git a/meta/3rd/Defold/library/collection_proxy.lua b/meta/3rd/Defold/library/collection_proxy.lua new file mode 100644 index 00000000..d49ed6d1 --- /dev/null +++ b/meta/3rd/Defold/library/collection_proxy.lua @@ -0,0 +1,9 @@ +---Collection proxy API documentation +---Messages for controlling and interacting with collection proxies +---which are used to dynamically load collections into the runtime. +---@class collectionproxy +collectionproxy = {} + + + +return collectionproxy
\ No newline at end of file diff --git a/meta/3rd/Defold/library/collision_object.lua b/meta/3rd/Defold/library/collision_object.lua new file mode 100644 index 00000000..41a6ac6a --- /dev/null +++ b/meta/3rd/Defold/library/collision_object.lua @@ -0,0 +1,149 @@ +---Collision object physics API documentation +---Collision object physics API documentation +---@class physics +physics = {} +---fixed joint type +physics.JOINT_TYPE_FIXED = nil +---hinge joint type +physics.JOINT_TYPE_HINGE = nil +---slider joint type +physics.JOINT_TYPE_SLIDER = nil +---spring joint type +physics.JOINT_TYPE_SPRING = nil +---weld joint type +physics.JOINT_TYPE_WELD = nil +---Create a physics joint between two collision object components. +---Note: Currently only supported in 2D physics. +---@param joint_type number # the joint type +---@param collisionobject_a string|hash|url # first collision object +---@param joint_id string|hash # id of the joint +---@param position_a vector3 # local position where to attach the joint on the first collision object +---@param collisionobject_b string|hash|url # second collision object +---@param position_b vector3 # local position where to attach the joint on the second collision object +---@param properties table? # optional joint specific properties table See each joint type for possible properties field. The one field that is accepted for all joint types is: - boolean collide_connected: Set this flag to true if the attached bodies should collide. +function physics.create_joint(joint_type, collisionobject_a, joint_id, position_a, collisionobject_b, position_b, properties) end + +---Destroy an already physics joint. The joint has to be created before a +---destroy can be issued. +---Note: Currently only supported in 2D physics. +---@param collisionobject string|hash|url # collision object where the joint exist +---@param joint_id string|hash # id of the joint +function physics.destroy_joint(collisionobject, joint_id) end + +---Get the gravity in runtime. The gravity returned is not global, it will return +---the gravity for the collection that the function is called from. +---Note: For 2D physics the z component will always be zero. +---@return vector3 # gravity vector of collection +function physics.get_gravity() end + +---Returns the group name of a collision object as a hash. +---@param url string|hash|url # the collision object to return the group of. +---@return hash # hash value of the group. local function check_is_enemy() local group = physics.get_group("#collisionobject") return group == hash("enemy") end +function physics.get_group(url) end + +---Get a table for properties for a connected joint. The joint has to be created before +---properties can be retrieved. +---Note: Currently only supported in 2D physics. +---@param collisionobject string|hash|url # collision object where the joint exist +---@param joint_id string|hash # id of the joint +---@return table # properties table. See the joint types for what fields are available, the only field available for all types is: +function physics.get_joint_properties(collisionobject, joint_id) end + +---Get the reaction force for a joint. The joint has to be created before +---the reaction force can be calculated. +---Note: Currently only supported in 2D physics. +---@param collisionobject string|hash|url # collision object where the joint exist +---@param joint_id string|hash # id of the joint +---@return vector3 # reaction force for the joint +function physics.get_joint_reaction_force(collisionobject, joint_id) end + +---Get the reaction torque for a joint. The joint has to be created before +---the reaction torque can be calculated. +---Note: Currently only supported in 2D physics. +---@param collisionobject string|hash|url # collision object where the joint exist +---@param joint_id string|hash # id of the joint +---@return float # the reaction torque on bodyB in N*m. +function physics.get_joint_reaction_torque(collisionobject, joint_id) end + +---Returns true if the specified group is set in the mask of a collision +---object, false otherwise. +---@param url string|hash|url # the collision object to check the mask of. +---@param group string # the name of the group to check for. +---@return boolean # boolean value of the maskbit. 'true' if present, 'false' otherwise. local function is_invincible() -- check if the collisionobject would collide with the "bullet" group local invincible = physics.get_maskbit("#collisionobject", "bullet") return invincible end +function physics.get_maskbit(url, group) end + +---Ray casts are used to test for intersections against collision objects in the physics world. +---Collision objects of types kinematic, dynamic and static are tested against. Trigger objects +---do not intersect with ray casts. +---Which collision objects to hit is filtered by their collision groups and can be configured +---through groups. +---@param from vector3 # the world position of the start of the ray +---@param to vector3 # the world position of the end of the ray +---@param groups table # a lua table containing the hashed groups for which to test collisions against +---@param options table # a lua table containing options for the raycast. +---@return table # It returns a list. If missed it returns nil. See ray_cast_response for details on the returned values. +function physics.raycast(from, to, groups, options) end + +---Ray casts are used to test for intersections against collision objects in the physics world. +---Collision objects of types kinematic, dynamic and static are tested against. Trigger objects +---do not intersect with ray casts. +---Which collision objects to hit is filtered by their collision groups and can be configured +---through groups. +---The actual ray cast will be performed during the physics-update. +--- +--- +--- * If an object is hit, the result will be reported via a ray_cast_response message. +--- +--- * If there is no object hit, the result will be reported via a ray_cast_missed message. +---@param from vector3 # the world position of the start of the ray +---@param to vector3 # the world position of the end of the ray +---@param groups table # a lua table containing the hashed groups for which to test collisions against +---@param request_id number] a number between [0,-255? # . It will be sent back in the response for identification, 0 by default +function physics.raycast_async(from, to, groups, request_id) end + +---Set the gravity in runtime. The gravity change is not global, it will only affect +---the collection that the function is called from. +---Note: For 2D physics the z component of the gravity vector will be ignored. +---@param gravity vector3 # the new gravity vector +function physics.set_gravity(gravity) end + +---Updates the group property of a collision object to the specified +---string value. The group name should exist i.e. have been used in +---a collision object in the editor. +---@param url string|hash|url # the collision object affected. +---@param group string # the new group name to be assigned. local function change_collision_group() physics.set_group("#collisionobject", "enemy") end +function physics.set_group(url, group) end + +---Flips the collision shapes horizontally for a collision object +---@param url string|hash|url # the collision object that should flip its shapes +---@param flip boolean # true if the collision object should flip its shapes, false if not +function physics.set_hflip(url, flip) end + +---Updates the properties for an already connected joint. The joint has to be created before +---properties can be changed. +---Note: Currently only supported in 2D physics. +---@param collisionobject string|hash|url # collision object where the joint exist +---@param joint_id string|hash # id of the joint +---@param properties table # joint specific properties table Note: The collide_connected field cannot be updated/changed after a connection has been made. +function physics.set_joint_properties(collisionobject, joint_id, properties) end + +---Sets or clears the masking of a group (maskbit) in a collision object. +---@param url string|hash|url # the collision object to change the mask of. +---@param group string # the name of the group (maskbit) to modify in the mask. +---@param maskbit boolean # boolean value of the new maskbit. 'true' to enable, 'false' to disable. local function make_invincible() -- no longer collide with the "bullet" group physics.set_maskbit("#collisionobject", "bullet", false) end +function physics.set_maskbit(url, group, maskbit) end + +---Flips the collision shapes vertically for a collision object +---@param url string|hash|url # the collision object that should flip its shapes +---@param flip boolean # true if the collision object should flip its shapes, false if not +function physics.set_vflip(url, flip) end + +---Collision objects tend to fall asleep when inactive for a small period of time for +---efficiency reasons. This function wakes them up. +---@param url string|hash|url # the collision object to wake. function on_input(self, action_id, action) if action_id == hash("test") and action.pressed then physics.wakeup("#collisionobject") end end +function physics.wakeup(url) end + + + + +return physics
\ No newline at end of file diff --git a/meta/3rd/Defold/library/factory.lua b/meta/3rd/Defold/library/factory.lua new file mode 100644 index 00000000..77332789 --- /dev/null +++ b/meta/3rd/Defold/library/factory.lua @@ -0,0 +1,47 @@ +---Factory API documentation +---Functions for controlling factory components which are used to +---dynamically spawn game objects into the runtime. +---@class factory +factory = {} +---loaded +factory.STATUS_LOADED = nil +---loading +factory.STATUS_LOADING = nil +---unloaded +factory.STATUS_UNLOADED = nil +---The URL identifies which factory should create the game object. +---If the game object is created inside of the frame (e.g. from an update callback), the game object will be created instantly, but none of its component will be updated in the same frame. +---Properties defined in scripts in the created game object can be overridden through the properties-parameter below. +---See go.property for more information on script properties. +--- Calling factory.create <> on a factory that is marked as dynamic without having loaded resources +---using factory.load <> will synchronously load and create resources which may affect application performance. +---@param url string|hash|url # the factory that should create a game object. +---@param position vector3? # the position of the new game object, the position of the game object calling factory.create() is used by default, or if the value is nil. +---@param rotation quaternion? # the rotation of the new game object, the rotation of the game object calling factory.create() is used by default, or if the value is nil. +---@param properties table? # the properties defined in a script attached to the new game object. +---@param scale number|vector3? # the scale of the new game object (must be greater than 0), the scale of the game object containing the factory is used by default, or if the value is nil +---@return hash # the global id of the spawned game object +function factory.create(url, position, rotation, properties, scale) end + +---This returns status of the factory. +---Calling this function when the factory is not marked as dynamic loading always returns +---factory.STATUS_LOADED. +---@param url string|hash|url? # the factory component to get status from +---@return constant # status of the factory component +function factory.get_status(url) end + +---Resources are referenced by the factory component until the existing (parent) collection is destroyed or factory.unload is called. +---Calling this function when the factory is not marked as dynamic loading does nothing. +---@param url string|hash|url? # the factory component to load +---@param complete_function (fun(self: object, url: url, result: boolean))? # function to call when resources are loaded. +function factory.load(url, complete_function) end + +---This decreases the reference count for each resource loaded with factory.load. If reference is zero, the resource is destroyed. +---Calling this function when the factory is not marked as dynamic loading does nothing. +---@param url string|hash|url? # the factory component to unload +function factory.unload(url) end + + + + +return factory
\ No newline at end of file diff --git a/meta/3rd/Defold/library/game_object.lua b/meta/3rd/Defold/library/game_object.lua new file mode 100644 index 00000000..08054a07 --- /dev/null +++ b/meta/3rd/Defold/library/game_object.lua @@ -0,0 +1,340 @@ +---Game object API documentation +---Functions, core hooks, messages and constants for manipulation of +---game objects. The "go" namespace is accessible from game object script +---files. +---@class go +go = {} +---This is a callback-function, which is called by the engine when a script component is finalized (destroyed). It can +---be used to e.g. take some last action, report the finalization to other game object instances, delete spawned objects +---or release user input focus (see release_input_focus <>). +---@param self object # reference to the script state to be used for storing data +function final(self) end + +---in-back +go.EASING_INBACK = nil +---in-bounce +go.EASING_INBOUNCE = nil +---in-circlic +go.EASING_INCIRC = nil +---in-cubic +go.EASING_INCUBIC = nil +---in-elastic +go.EASING_INELASTIC = nil +---in-exponential +go.EASING_INEXPO = nil +---in-out-back +go.EASING_INOUTBACK = nil +---in-out-bounce +go.EASING_INOUTBOUNCE = nil +---in-out-circlic +go.EASING_INOUTCIRC = nil +---in-out-cubic +go.EASING_INOUTCUBIC = nil +---in-out-elastic +go.EASING_INOUTELASTIC = nil +---in-out-exponential +go.EASING_INOUTEXPO = nil +---in-out-quadratic +go.EASING_INOUTQUAD = nil +---in-out-quartic +go.EASING_INOUTQUART = nil +---in-out-quintic +go.EASING_INOUTQUINT = nil +---in-out-sine +go.EASING_INOUTSINE = nil +---in-quadratic +go.EASING_INQUAD = nil +---in-quartic +go.EASING_INQUART = nil +---in-quintic +go.EASING_INQUINT = nil +---in-sine +go.EASING_INSINE = nil +---linear interpolation +go.EASING_LINEAR = nil +---out-back +go.EASING_OUTBACK = nil +---out-bounce +go.EASING_OUTBOUNCE = nil +---out-circlic +go.EASING_OUTCIRC = nil +---out-cubic +go.EASING_OUTCUBIC = nil +---out-elastic +go.EASING_OUTELASTIC = nil +---out-exponential +go.EASING_OUTEXPO = nil +---out-in-back +go.EASING_OUTINBACK = nil +---out-in-bounce +go.EASING_OUTINBOUNCE = nil +---out-in-circlic +go.EASING_OUTINCIRC = nil +---out-in-cubic +go.EASING_OUTINCUBIC = nil +---out-in-elastic +go.EASING_OUTINELASTIC = nil +---out-in-exponential +go.EASING_OUTINEXPO = nil +---out-in-quadratic +go.EASING_OUTINQUAD = nil +---out-in-quartic +go.EASING_OUTINQUART = nil +---out-in-quintic +go.EASING_OUTINQUINT = nil +---out-in-sine +go.EASING_OUTINSINE = nil +---out-quadratic +go.EASING_OUTQUAD = nil +---out-quartic +go.EASING_OUTQUART = nil +---out-quintic +go.EASING_OUTQUINT = nil +---out-sine +go.EASING_OUTSINE = nil +---loop backward +go.PLAYBACK_LOOP_BACKWARD = nil +---loop forward +go.PLAYBACK_LOOP_FORWARD = nil +---ping pong loop +go.PLAYBACK_LOOP_PINGPONG = nil +---no playback +go.PLAYBACK_NONE = nil +---once backward +go.PLAYBACK_ONCE_BACKWARD = nil +---once forward +go.PLAYBACK_ONCE_FORWARD = nil +---once ping pong +go.PLAYBACK_ONCE_PINGPONG = nil +---This is only supported for numerical properties. If the node property is already being +---animated, that animation will be canceled and replaced by the new one. +---If a complete_function (lua function) is specified, that function will be called when the animation has completed. +---By starting a new animation in that function, several animations can be sequenced together. See the examples for more information. +--- If you call go.animate() from a game object's final() function, +---any passed complete_function will be ignored and never called upon animation completion. +---See the properties guide <> for which properties can be animated and the animation guide <> for how +---them. +---@param url string|hash|url # url of the game object or component having the property +---@param property string|hash # id of the property to animate +---@param playback constant # playback mode of the animation +---@param to number|vector3|vector4|quaternion # target property value +---@param easing constant|vector # easing to use during animation. Either specify a constant, see the animation guide <> for a complete list, or a vmath.vector with a curve +---@param duration number # duration of the animation in seconds +---@param delay number? # delay before the animation starts in seconds +---@param complete_function (fun(self: object, url: url, property: hash))? # optional function to call when the animation has completed +function go.animate(url, property, playback, to, easing, duration, delay, complete_function) end + +---By calling this function, all or specified stored property animations of the game object or component will be canceled. +---See the properties guide <> for which properties can be animated and the animation guide <> for how to animate them. +---@param url string|hash|url # url of the game object or component +---@param property string|hash? # optional id of the property to cancel +function go.cancel_animations(url, property) end + +---Delete one or more game objects identified by id. Deletion is asynchronous meaning that +---the game object(s) are scheduled for deletion which will happen at the end of the current +---frame. Note that game objects scheduled for deletion will be counted against +---max_instances in "game.project" until they are actually removed. +--- Deleting a game object containing a particle FX component emitting particles will not immediately stop the particle FX from emitting particles. You need to manually stop the particle FX using particlefx.stop(). +--- Deleting a game object containing a sound component that is playing will not immediately stop the sound from playing. You need to manually stop the sound using sound.stop(). +---@param id string|hash|url|table? # optional id or table of id's of the instance(s) to delete, the instance of the calling script is deleted by default +---@param recursive boolean? # optional boolean, set to true to recursively delete child hiearchy in child to parent order +function go.delete(id, recursive) end + +---gets a named property of the specified game object or component +---@param url string|hash|url # url of the game object or component having the property +---@param property string|hash # id of the property to retrieve +---@param options table # (optional) options table - index integer index into array property (1 based) - key hash name of internal property +---@return any # the value of the specified property +function go.get(url, property, options) end + +---Returns or constructs an instance identifier. The instance id is a hash +---of the absolute path to the instance. +--- +--- +--- * If path is specified, it can either be absolute or relative to the instance of the calling script. +--- +--- * If path is not specified, the id of the game object instance the script is attached to will be returned. +---@param path string? # path of the instance for which to return the id +---@return hash # instance id +function go.get_id(path) end + +---Get the parent for a game object instance. +---@param id string|hash|url? # optional id of the game object instance to get parent for, defaults to the instance containing the calling script +---@return hash # parent instance or nil +function go.get_parent(id) end + +---The position is relative the parent (if any). Use go.get_world_position <> to retrieve the global world position. +---@param id string|hash|url? # optional id of the game object instance to get the position for, by default the instance of the calling script +---@return vector3 # instance position +function go.get_position(id) end + +---The rotation is relative to the parent (if any). Use go.get_world_rotation <> to retrieve the global world rotation. +---@param id string|hash|url? # optional id of the game object instance to get the rotation for, by default the instance of the calling script +---@return quaternion # instance rotation +function go.get_rotation(id) end + +---The scale is relative the parent (if any). Use go.get_world_scale <> to retrieve the global world 3D scale factor. +---@param id string|hash|url? # optional id of the game object instance to get the scale for, by default the instance of the calling script +---@return vector3 # instance scale factor +function go.get_scale(id) end + +---The uniform scale is relative the parent (if any). If the underlying scale vector is non-uniform the min element of the vector is returned as the uniform scale factor. +---@param id string|hash|url? # optional id of the game object instance to get the uniform scale for, by default the instance of the calling script +---@return number # uniform instance scale factor +function go.get_scale_uniform(id) end + +---The function will return the world position calculated at the end of the previous frame. +---Use go.get_position <> to retrieve the position relative to the parent. +---@param id string|hash|url? # optional id of the game object instance to get the world position for, by default the instance of the calling script +---@return vector3 # instance world position +function go.get_world_position(id) end + +---The function will return the world rotation calculated at the end of the previous frame. +---Use go.get_rotation <> to retrieve the rotation relative to the parent. +---@param id string|hash|url? # optional id of the game object instance to get the world rotation for, by default the instance of the calling script +---@return quaternion # instance world rotation +function go.get_world_rotation(id) end + +---The function will return the world 3D scale factor calculated at the end of the previous frame. +---Use go.get_scale <> to retrieve the 3D scale factor relative to the parent. +---This vector is derived by decomposing the transformation matrix and should be used with care. +---For most cases it should be fine to use go.get_world_scale_uniform <> instead. +---@param id string|hash|url? # optional id of the game object instance to get the world scale for, by default the instance of the calling script +---@return vector3 # instance world 3D scale factor +function go.get_world_scale(id) end + +---The function will return the world scale factor calculated at the end of the previous frame. +---Use go.get_scale_uniform <> to retrieve the scale factor relative to the parent. +---@param id string|hash|url? # optional id of the game object instance to get the world scale for, by default the instance of the calling script +---@return number # instance world scale factor +function go.get_world_scale_uniform(id) end + +---The function will return the world transform matrix calculated at the end of the previous frame. +---@param id string|hash|url? # optional id of the game object instance to get the world transform for, by default the instance of the calling script +---@return matrix4 # instance world transform +function go.get_world_transform(id) end + +---This function defines a property which can then be used in the script through the self-reference. +---The properties defined this way are automatically exposed in the editor in game objects and collections which use the script. +---Note that you can only use this function outside any callback-functions like init and update. +---@param name string # the id of the property +---@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. +function go.property(name, value) end + +---sets a named property of the specified game object or component, or a material constant +---@param url string|hash|url # url of the game object or component having the property +---@param property string|hash # id of the property to set +---@param value any # the value to set +---@param options table # (optional) options table - index integer index into array property (1 based) - key hash name of internal property +function go.set(url, property, value, options) end + +---Sets the parent for a game object instance. This means that the instance will exist in the geometrical space of its parent, +---like a basic transformation hierarchy or scene graph. If no parent is specified, the instance will be detached from any parent and exist in world +---space. +---This function will generate a set_parent message. It is not until the message has been processed that the change actually takes effect. This +---typically happens later in the same frame or the beginning of the next frame. Refer to the manual to learn how messages are processed by the +---engine. +---@param id string|hash|url? # optional id of the game object instance to set parent for, defaults to the instance containing the calling script +---@param parent_id string|hash|url? # optional id of the new parent game object, defaults to detaching game object from its parent +---@param keep_world_transform boolean? # optional boolean, set to true to maintain the world transform when changing spaces. Defaults to false. +function go.set_parent(id, parent_id, keep_world_transform) end + +---The position is relative to the parent (if any). The global world position cannot be manually set. +---@param position vector3 # position to set +---@param id string|hash|url? # optional id of the game object instance to set the position for, by default the instance of the calling script +function go.set_position(position, id) end + +---The rotation is relative to the parent (if any). The global world rotation cannot be manually set. +---@param rotation quaternion # rotation to set +---@param id string|hash|url? # optional id of the game object instance to get the rotation for, by default the instance of the calling script +function go.set_rotation(rotation, id) end + +---The scale factor is relative to the parent (if any). The global world scale factor cannot be manually set. +--- Physics are currently not affected when setting scale from this function. +---@param scale number|vector3 # vector or uniform scale factor, must be greater than 0 +---@param id string|hash|url? # optional id of the game object instance to get the scale for, by default the instance of the calling script +function go.set_scale(scale, id) end + +---This is a callback-function, which is called by the engine when a script component is initialized. It can be used +---to set the initial state of the script. +---@param self object # reference to the script state to be used for storing data +function init(self) end + +---This is a callback-function, which is called by the engine when user input is sent to the game object instance of the script. +---It can be used to take action on the input, e.g. move the instance according to the input. +---For an instance to obtain user input, it must first acquire input focus +---through the message acquire_input_focus. +---Any instance that has obtained input will be put on top of an +---input stack. Input is sent to all listeners on the stack until the +---end of stack is reached, or a listener returns true +---to signal that it wants input to be consumed. +---See the documentation of acquire_input_focus <> for more +---information. +---The action parameter is a table containing data about the input mapped to the +---action_id. +---For mapped actions it specifies the value of the input and if it was just pressed or released. +---Actions are mapped to input in an input_binding-file. +---Mouse movement is specifically handled and uses nil as its action_id. +---The action only contains positional parameters in this case, such as x and y of the pointer. +---Here is a brief description of the available table fields: +--- +---Field Description +---value The amount of input given by the user. This is usually 1 for buttons and 0-1 for analogue inputs. This is not present for mouse movement. +---pressed If the input was pressed this frame. This is not present for mouse movement. +---released If the input was released this frame. This is not present for mouse movement. +---repeated If the input was repeated this frame. This is similar to how a key on a keyboard is repeated when you hold it down. This is not present for mouse movement. +---x The x value of a pointer device, if present. +---y The y value of a pointer device, if present. +---screen_x The screen space x value of a pointer device, if present. +---screen_y The screen space y value of a pointer device, if present. +---dx The change in x value of a pointer device, if present. +---dy The change in y value of a pointer device, if present. +---screen_dx The change in screen space x value of a pointer device, if present. +---screen_dy The change in screen space y value of a pointer device, if present. +---gamepad The index of the gamepad device that provided the input. +---touch List of touch input, one element per finger, if present. See table below about touch input +---Touch input table: +--- +---Field Description +---id A number identifying the touch input during its duration. +---pressed True if the finger was pressed this frame. +---released True if the finger was released this frame. +---tap_count Number of taps, one for single, two for double-tap, etc +---x The x touch location. +---y The y touch location. +---dx The change in x value. +---dy The change in y value. +---acc_x Accelerometer x value (if present). +---acc_y Accelerometer y value (if present). +---acc_z Accelerometer z value (if present). +---@param self object # reference to the script state to be used for storing data +---@param action_id hash # id of the received input action, as mapped in the input_binding-file +---@param action table # a table containing the input data, see above for a description +---@return boolean? # optional boolean to signal if the input should be consumed (not passed on to others) or not, default is false +function on_input(self, action_id, action) end + +---This is a callback-function, which is called by the engine whenever a message has been sent to the script component. +---It can be used to take action on the message, e.g. send a response back to the sender of the message. +---The message parameter is a table containing the message data. If the message is sent from the engine, the +---documentation of the message specifies which data is supplied. +---@param self object # reference to the script state to be used for storing data +---@param message_id hash # id of the received message +---@param message table # a table containing the message data +---@param sender url # address of the sender +function on_message(self, message_id, message, sender) end + +---This is a callback-function, which is called by the engine when the script component is reloaded, e.g. from the editor. +---It can be used for live development, e.g. to tweak constants or set up the state properly for the instance. +---@param self object # reference to the script state to be used for storing data +function on_reload(self) end + +---This is a callback-function, which is called by the engine every frame to update the state of a script component. +---It can be used to perform any kind of game related tasks, e.g. moving the game object instance. +---@param self object # reference to the script state to be used for storing data +---@param dt number # the time-step of the frame update +function update(self, dt) end + + + + +return go
\ No newline at end of file diff --git a/meta/3rd/Defold/library/gui.lua b/meta/3rd/Defold/library/gui.lua new file mode 100644 index 00000000..f4b82cd0 --- /dev/null +++ b/meta/3rd/Defold/library/gui.lua @@ -0,0 +1,929 @@ +---GUI API documentation +---GUI API documentation +---@class gui +gui = {} +---This is a callback-function, which is called by the engine when a gui component is finalized (destroyed). It can +---be used to e.g. take some last action, report the finalization to other game object instances +---or release user input focus (see release_input_focus). There is no use in starting any animations or similar +---from this function since the gui component is about to be destroyed. +---@param self object # reference to the script state to be used for storing data +function final(self) end + +---fit adjust mode +gui.ADJUST_FIT = nil +---stretch adjust mode +gui.ADJUST_STRETCH = nil +---zoom adjust mode +gui.ADJUST_ZOOM = nil +---bottom y-anchor +gui.ANCHOR_BOTTOM = nil +---left x-anchor +gui.ANCHOR_LEFT = nil +---no anchor +gui.ANCHOR_NONE = nil +---right x-anchor +gui.ANCHOR_RIGHT = nil +---top y-anchor +gui.ANCHOR_TOP = nil +---additive blending +gui.BLEND_ADD = nil +---additive alpha blending +gui.BLEND_ADD_ALPHA = nil +---alpha blending +gui.BLEND_ALPHA = nil +---multiply blending +gui.BLEND_MULT = nil +---clipping mode none +gui.CLIPPING_MODE_NONE = nil +---clipping mode stencil +gui.CLIPPING_MODE_STENCIL = nil +---in-back +gui.EASING_INBACK = nil +---in-bounce +gui.EASING_INBOUNCE = nil +---in-circlic +gui.EASING_INCIRC = nil +---in-cubic +gui.EASING_INCUBIC = nil +---in-elastic +gui.EASING_INELASTIC = nil +---in-exponential +gui.EASING_INEXPO = nil +---in-out-back +gui.EASING_INOUTBACK = nil +---in-out-bounce +gui.EASING_INOUTBOUNCE = nil +---in-out-circlic +gui.EASING_INOUTCIRC = nil +---in-out-cubic +gui.EASING_INOUTCUBIC = nil +---in-out-elastic +gui.EASING_INOUTELASTIC = nil +---in-out-exponential +gui.EASING_INOUTEXPO = nil +---in-out-quadratic +gui.EASING_INOUTQUAD = nil +---in-out-quartic +gui.EASING_INOUTQUART = nil +---in-out-quintic +gui.EASING_INOUTQUINT = nil +---in-out-sine +gui.EASING_INOUTSINE = nil +---in-quadratic +gui.EASING_INQUAD = nil +---in-quartic +gui.EASING_INQUART = nil +---in-quintic +gui.EASING_INQUINT = nil +---in-sine +gui.EASING_INSINE = nil +---linear interpolation +gui.EASING_LINEAR = nil +---out-back +gui.EASING_OUTBACK = nil +---out-bounce +gui.EASING_OUTBOUNCE = nil +---out-circlic +gui.EASING_OUTCIRC = nil +---out-cubic +gui.EASING_OUTCUBIC = nil +---out-elastic +gui.EASING_OUTELASTIC = nil +---out-exponential +gui.EASING_OUTEXPO = nil +---out-in-back +gui.EASING_OUTINBACK = nil +---out-in-bounce +gui.EASING_OUTINBOUNCE = nil +---out-in-circlic +gui.EASING_OUTINCIRC = nil +---out-in-cubic +gui.EASING_OUTINCUBIC = nil +---out-in-elastic +gui.EASING_OUTINELASTIC = nil +---out-in-exponential +gui.EASING_OUTINEXPO = nil +---out-in-quadratic +gui.EASING_OUTINQUAD = nil +---out-in-quartic +gui.EASING_OUTINQUART = nil +---out-in-quintic +gui.EASING_OUTINQUINT = nil +---out-in-sine +gui.EASING_OUTINSINE = nil +---out-quadratic +gui.EASING_OUTQUAD = nil +---out-quartic +gui.EASING_OUTQUART = nil +---out-quintic +gui.EASING_OUTQUINT = nil +---out-sine +gui.EASING_OUTSINE = nil +---default keyboard +gui.KEYBOARD_TYPE_DEFAULT = nil +---email keyboard +gui.KEYBOARD_TYPE_EMAIL = nil +---number input keyboard +gui.KEYBOARD_TYPE_NUMBER_PAD = nil +---password keyboard +gui.KEYBOARD_TYPE_PASSWORD = nil +---elliptical pie node bounds +gui.PIEBOUNDS_ELLIPSE = nil +---rectangular pie node bounds +gui.PIEBOUNDS_RECTANGLE = nil +---center pivot +gui.PIVOT_CENTER = nil +---east pivot +gui.PIVOT_E = nil +---north pivot +gui.PIVOT_N = nil +---north-east pivot +gui.PIVOT_NE = nil +---north-west pivot +gui.PIVOT_NW = nil +---south pivot +gui.PIVOT_S = nil +---south-east pivot +gui.PIVOT_SE = nil +---south-west pivot +gui.PIVOT_SW = nil +---west pivot +gui.PIVOT_W = nil +---loop backward +gui.PLAYBACK_LOOP_BACKWARD = nil +---loop forward +gui.PLAYBACK_LOOP_FORWARD = nil +---ping pong loop +gui.PLAYBACK_LOOP_PINGPONG = nil +---once backward +gui.PLAYBACK_ONCE_BACKWARD = nil +---once forward +gui.PLAYBACK_ONCE_FORWARD = nil +---once forward and then backward +gui.PLAYBACK_ONCE_PINGPONG = nil +---color property +gui.PROP_COLOR = nil +---fill_angle property +gui.PROP_FILL_ANGLE = nil +---inner_radius property +gui.PROP_INNER_RADIUS = nil +---outline color property +gui.PROP_OUTLINE = nil +---position property +gui.PROP_POSITION = nil +---rotation property +gui.PROP_ROTATION = nil +---scale property +gui.PROP_SCALE = nil +---shadow color property +gui.PROP_SHADOW = nil +---size property +gui.PROP_SIZE = nil +---slice9 property +gui.PROP_SLICE9 = nil +---data error +gui.RESULT_DATA_ERROR = nil +---out of resource +gui.RESULT_OUT_OF_RESOURCES = nil +---texture already exists +gui.RESULT_TEXTURE_ALREADY_EXISTS = nil +---automatic size mode +gui.SIZE_MODE_AUTO = nil +---manual size mode +gui.SIZE_MODE_MANUAL = nil +---This starts an animation of a node property according to the specified parameters. +---If the node property is already being animated, that animation will be canceled and +---replaced by the new one. Note however that several different node properties +---can be animated simultaneously. Use gui.cancel_animation to stop the animation +---before it has completed. +---Composite properties of type vector3, vector4 or quaternion +---also expose their sub-components (x, y, z and w). +---You can address the components individually by suffixing the name with a dot '.' +---and the name of the component. +---For instance, "position.x" (the position x coordinate) or "color.w" +---(the color alpha value). +---If a complete_function (Lua function) is specified, that function will be called +---when the animation has completed. +---By starting a new animation in that function, several animations can be sequenced +---together. See the examples below for more information. +---@param node node # node to animate +---@param property string|constant # property to animate +---@param to vector3|vector4 # target property value +---@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. +---@param duration number # duration of the animation in seconds. +---@param delay number? # delay before the animation starts in seconds. +---@param complete_function (fun(self: any, node: any))? # function to call when the animation has completed +---@param playback constant? # playback mode +function gui.animate(node, property, to, easing, duration, delay, complete_function, playback) end + +---If an animation of the specified node is currently running (started by gui.animate), it will immediately be canceled. +---@param node node # node that should have its animation canceled +---@param property string|constant # property for which the animation should be canceled +function gui.cancel_animation(node, property) end + +---Cancels any running flipbook animation on the specified node. +---@param node node # node cancel flipbook animation for +function gui.cancel_flipbook(node) end + +---Make a clone instance of a node. +---This function does not clone the supplied node's children nodes. +---Use gui.clone_tree for that purpose. +---@param node node # node to clone +---@return node # the cloned node +function gui.clone(node) end + +---Make a clone instance of a node and all its children. +---Use gui.clone to clone a node excluding its children. +---@param node node # root node to clone +---@return table # a table mapping node ids to the corresponding cloned nodes +function gui.clone_tree(node) end + +---Deletes the specified node. Any child nodes of the specified node will be +---recursively deleted. +---@param node node # node to delete +function gui.delete_node(node) end + +---Delete a dynamically created texture. +---@param texture string|hash # texture id +function gui.delete_texture(texture) end + +---Returns the adjust mode of a node. +---The adjust mode defines how the node will adjust itself to screen +---resolutions that differs from the one in the project settings. +---@param node node # node from which to get the adjust mode (node) +---@return constant # the current adjust mode +function gui.get_adjust_mode(node) end + +---gets the node alpha +---@param node node # node from which to get alpha +function gui.get_alpha(node) end + +---Returns the blend mode of a node. +---Blend mode defines how the node will be blended with the background. +---@param node node # node from which to get the blend mode +---@return constant # blend mode +function gui.get_blend_mode(node) end + +---If node is set as an inverted clipping node, it will clip anything inside as opposed to outside. +---@param node node # node from which to get the clipping inverted state +---@return boolean # true or false +function gui.get_clipping_inverted(node) end + +---Clipping mode defines how the node will clip it's children nodes +---@param node node # node from which to get the clipping mode +---@return constant # clipping mode +function gui.get_clipping_mode(node) end + +---If node is set as visible clipping node, it will be shown as well as clipping. Otherwise, it will only clip but not show visually. +---@param node node # node from which to get the clipping visibility state +---@return boolean # true or false +function gui.get_clipping_visible(node) end + +---Returns the color of the supplied node. The components +---of the returned vector4 contains the color channel values: +--- +---Component Color value +---x Red value +---y Green value +---z Blue value +---w Alpha value +---@param node node # node to get the color from +---@return vector4 # node color +function gui.get_color(node) end + +---Returns the sector angle of a pie node. +---@param node node # node from which to get the fill angle +---@return number # sector angle +function gui.get_fill_angle(node) end + +---Get node flipbook animation. +---@param node node # node to get flipbook animation from +---@return hash # animation id +function gui.get_flipbook(node) end + +---This is only useful nodes with flipbook animations. Gets the normalized cursor of the flipbook animation on a node. +---@param node node # node to get the cursor for (node) +---@return # value number cursor value +function gui.get_flipbook_cursor(node) end + +---This is only useful nodes with flipbook animations. Gets the playback rate of the flipbook animation on a node. +---@param node node # node to set the cursor for +---@return number # playback rate +function gui.get_flipbook_playback_rate(node) end + +---This is only useful for text nodes. The font must be mapped to the gui scene in the gui editor. +---@param node node # node from which to get the font +---@return hash # font id +function gui.get_font(node) end + +---This is only useful for text nodes. The font must be mapped to the gui scene in the gui editor. +---@param font_name hash|string # font of which to get the path hash +---@return hash # path hash to resource +function gui.get_font_resource(font_name) end + +---Returns the scene height. +---@return number # scene height +function gui.get_height() end + +---Retrieves the id of the specified node. +---@param node node # the node to retrieve the id from +---@return hash # the id of the node +function gui.get_id(node) end + +---Retrieve the index of the specified node among its siblings. +---The index defines the order in which a node appear in a GUI scene. +---Higher index means the node is drawn on top of lower indexed nodes. +---@param node node # the node to retrieve the id from +---@return number # the index of the node +function gui.get_index(node) end + +---gets the node inherit alpha state +---@param node node # node from which to get the inherit alpha state +function gui.get_inherit_alpha(node) end + +---Returns the inner radius of a pie node. +---The radius is defined along the x-axis. +---@param node node # node from where to get the inner radius +---@return number # inner radius +function gui.get_inner_radius(node) end + +---The layer must be mapped to the gui scene in the gui editor. +---@param node node # node from which to get the layer +---@return hash # layer id +function gui.get_layer(node) end + +---gets the scene current layout +---@return hash # layout id +function gui.get_layout() end + +---Returns the leading value for a text node. +---@param node node # node from where to get the leading +---@return number # leading scaling value (default=1) +function gui.get_leading(node) end + +---Returns whether a text node is in line-break mode or not. +---This is only useful for text nodes. +---@param node node # node from which to get the line-break for +---@return boolean # true or false +function gui.get_line_break(node) end + +---Retrieves the node with the specified id. +---@param id string|hash # id of the node to retrieve +---@return node # a new node instance +function gui.get_node(id) end + +---Returns the outer bounds mode for a pie node. +---@param node node # node from where to get the outer bounds mode +---@return constant # the outer bounds mode of the pie node: +function gui.get_outer_bounds(node) end + +---Returns the outline color of the supplied node. +---See gui.get_color <> for info how vectors encode color values. +---@param node node # node to get the outline color from +---@return vector4 # outline color +function gui.get_outline(node) end + +---Returns the parent node of the specified node. +---If the supplied node does not have a parent, nil is returned. +---@param node node # the node from which to retrieve its parent +---@return node # parent instance or nil +function gui.get_parent(node) end + +---Get the paricle fx for a gui node +---@param node node # node to get particle fx for +---@return hash # particle fx id +function gui.get_particlefx(node) end + +---Returns the number of generated vertices around the perimeter +---of a pie node. +---@param node node # pie node +---@return number # vertex count +function gui.get_perimeter_vertices(node) end + +---The pivot specifies how the node is drawn and rotated from its position. +---@param node node # node to get pivot from +---@return constant # pivot constant +function gui.get_pivot(node) end + +---Returns the position of the supplied node. +---@param node node # node to get the position from +---@return vector3 # node position +function gui.get_position(node) end + +---Returns the rotation of the supplied node. +---The rotation is expressed in degree Euler angles. +---@param node node # node to get the rotation from +---@return vector3 # node rotation +function gui.get_rotation(node) end + +---Returns the scale of the supplied node. +---@param node node # node to get the scale from +---@return vector3 # node scale +function gui.get_scale(node) end + +---Returns the screen position of the supplied node. This function returns the +---calculated transformed position of the node, taking into account any parent node +---transforms. +---@param node node # node to get the screen position from +---@return vector3 # node screen position +function gui.get_screen_position(node) end + +---Returns the shadow color of the supplied node. +---See gui.get_color <> for info how vectors encode color values. +---@param node node # node to get the shadow color from +---@return vector4 # node shadow color +function gui.get_shadow(node) end + +---Returns the size of the supplied node. +---@param node node # node to get the size from +---@return vector3 # node size +function gui.get_size(node) end + +---Returns the size of a node. +---The size mode defines how the node will adjust itself in size. Automatic +---size mode alters the node size based on the node's content. Automatic size +---mode works for Box nodes and Pie nodes which will both adjust their size +---to match the assigned image. Particle fx and Text nodes will ignore +---any size mode setting. +---@param node node # node from which to get the size mode (node) +---@return constant # the current size mode +function gui.get_size_mode(node) end + +---Returns the slice9 configuration values for the node. +---@param node node # node to manipulate +---@return vector4 # configuration values +function gui.get_slice9(node) end + +---Returns the text value of a text node. This is only useful for text nodes. +---@param node node # node from which to get the text +---@return string # text value +function gui.get_text(node) end + +---Returns the texture of a node. +---This is currently only useful for box or pie nodes. +---The texture must be mapped to the gui scene in the gui editor. +---@param node node # node to get texture from +---@return hash # texture id +function gui.get_texture(node) end + +---Returns the tracking value of a text node. +---@param node node # node from where to get the tracking +---@return number # tracking scaling number (default=0) +function gui.get_tracking(node) end + +---Returns true if a node is visible and false if it's not. +---Invisible nodes are not rendered. +---@param node node # node to query +---@return boolean # whether the node is visible or not +function gui.get_visible(node) end + +---Returns the scene width. +---@return number # scene width +function gui.get_width() end + +---The x-anchor specifies how the node is moved when the game is run in a different resolution. +---@param node node # node to get x-anchor from +---@return constant # anchor constant +function gui.get_xanchor(node) end + +---The y-anchor specifies how the node is moved when the game is run in a different resolution. +---@param node node # node to get y-anchor from +---@return constant # anchor constant +function gui.get_yanchor(node) end + +---Hides the on-display touch keyboard on the device. +function gui.hide_keyboard() end + +---Returns true if a node is enabled and false if it's not. +---Disabled nodes are not rendered and animations acting on them are not evaluated. +---@param node node # node to query +---@param recursive boolean # check hierarchy recursively +---@return boolean # whether the node is enabled or not +function gui.is_enabled(node, recursive) end + +---Alters the ordering of the two supplied nodes by moving the first node +---above the second. +---If the second argument is nil the first node is moved to the top. +---@param node node # to move +---@param node node|nil # reference node above which the first node should be moved +function gui.move_above(node, node) end + +---Alters the ordering of the two supplied nodes by moving the first node +---below the second. +---If the second argument is nil the first node is moved to the bottom. +---@param node node # to move +---@param node node|nil # reference node below which the first node should be moved +function gui.move_below(node, node) end + +---Dynamically create a new box node. +---@param pos vector3|vector4 # node position +---@param size vector3 # node size +---@return node # new box node +function gui.new_box_node(pos, size) end + +---Dynamically create a particle fx node. +---@param pos vector3|vector4 # node position +---@param particlefx hash|string # particle fx resource name +---@return node # new particle fx node +function gui.new_particlefx_node(pos, particlefx) end + +---Dynamically create a new pie node. +---@param pos vector3|vector4 # node position +---@param size vector3 # node size +---@return node # new pie node +function gui.new_pie_node(pos, size) end + +---Dynamically create a new text node. +---@param pos vector3|vector4 # node position +---@param text string # node text +---@return node # new text node +function gui.new_text_node(pos, text) end + +---Dynamically create a new texture. +---@param texture string|hash # texture id +---@param width number # texture width +---@param height number # texture height +---@param type string|constant # texture type +---@param buffer string # texture data +---@param flip boolean # flip texture vertically +---@return boolean # texture creation was successful +---@return number # one of the gui.RESULT_* codes if unsuccessful +function gui.new_texture(texture, width, height, type, buffer, flip) end + +---Tests whether a coordinate is within the bounding box of a +---node. +---@param node node # node to be tested for picking +---@param x number # x-coordinate (see on_input <> ) +---@param y number # y-coordinate (see on_input <> ) +---@return boolean # pick result +function gui.pick_node(node, x, y) end + +---Play flipbook animation on a box or pie node. +---The current node texture must contain the animation. +---Use this function to set one-frame still images on the node. +---@param node node # node to set animation for +---@param animation string|hash # animation id +---@param complete_function (fun(self: object, node: node))? # optional function to call when the animation has completed +---@param play_properties table? # optional table with properties +function gui.play_flipbook(node, animation, complete_function, play_properties) end + +---Plays the paricle fx for a gui node +---@param node node # node to play particle fx for +---@param emitter_state_function (fun(self: object, node: hash, emitter: hash, state: constant))? # optional callback function that will be called when an emitter attached to this particlefx changes state. +function gui.play_particlefx(node, emitter_state_function) end + +---Resets the input context of keyboard. This will clear marked text. +function gui.reset_keyboard() end + +---Resets all nodes in the current GUI scene to their initial state. +---The reset only applies to static node loaded from the scene. +---Nodes that are created dynamically from script are not affected. +function gui.reset_nodes() end + +---Convert the screen position to the local position of supplied node +---@param node node # node used for getting local transformation matrix +---@param screen_position vector3 # screen position +---@return vector3 # local position +function gui.screen_to_local(node, screen_position) end + +---Sets the adjust mode on a node. +---The adjust mode defines how the node will adjust itself to screen +---resolutions that differs from the one in the project settings. +---@param node node # node to set adjust mode for +---@param adjust_mode constant # adjust mode to set +function gui.set_adjust_mode(node, adjust_mode) end + +---sets the node alpha +---@param node node # node for which to set alpha +---@param alpha number # 0..1 alpha color +function gui.set_alpha(node, alpha) end + +---Set the blend mode of a node. +---Blend mode defines how the node will be blended with the background. +---@param node node # node to set blend mode for +---@param blend_mode constant # blend mode to set +function gui.set_blend_mode(node, blend_mode) end + +---If node is set as an inverted clipping node, it will clip anything inside as opposed to outside. +---@param node node # node to set clipping inverted state for +---@param inverted boolean # true or false +function gui.set_clipping_inverted(node, inverted) end + +---Clipping mode defines how the node will clip it's children nodes +---@param node node # node to set clipping mode for +---@param clipping_mode constant # clipping mode to set +function gui.set_clipping_mode(node, clipping_mode) end + +---If node is set as an visible clipping node, it will be shown as well as clipping. Otherwise, it will only clip but not show visually. +---@param node node # node to set clipping visibility for +---@param visible boolean # true or false +function gui.set_clipping_visible(node, visible) end + +---Sets the color of the supplied node. The components +---of the supplied vector3 or vector4 should contain the color channel values: +--- +---Component Color value +---x Red value +---y Green value +---z Blue value +---w vector4 Alpha value +---@param node node # node to set the color for +---@param color vector3|vector4 # new color +function gui.set_color(node, color) end + +---Sets a node to the disabled or enabled state. +---Disabled nodes are not rendered and animations acting on them are not evaluated. +---@param node node # node to be enabled/disabled +---@param enabled boolean # whether the node should be enabled or not +function gui.set_enabled(node, enabled) end + +---Set the sector angle of a pie node. +---@param node node # node to set the fill angle for +---@param angle number # sector angle +function gui.set_fill_angle(node, angle) end + +---This is only useful nodes with flipbook animations. The cursor is normalized. +---@param node node # node to set the cursor for +---@param cursor number # cursor value +function gui.set_flipbook_cursor(node, cursor) end + +---This is only useful nodes with flipbook animations. Sets the playback rate of the flipbook animation on a node. Must be positive. +---@param node node # node to set the cursor for +---@param playback_rate number # playback rate +function gui.set_flipbook_playback_rate(node, playback_rate) end + +---This is only useful for text nodes. +---The font must be mapped to the gui scene in the gui editor. +---@param node node # node for which to set the font +---@param font string|hash # font id +function gui.set_font(node, font) end + +---Set the id of the specicied node to a new value. +---Nodes created with the gui.new_*_node() functions get +---an empty id. This function allows you to give dynamically +---created nodes an id. +--- No checking is done on the uniqueness of supplied ids. +---It is up to you to make sure you use unique ids. +---@param node node # node to set the id for +---@param id string|hash # id to set +function gui.set_id(node, id) end + +---sets the node inherit alpha state +---@param node node # node from which to set the inherit alpha state +---@param inherit_alpha boolean # true or false +function gui.set_inherit_alpha(node, inherit_alpha) end + +---Sets the inner radius of a pie node. +---The radius is defined along the x-axis. +---@param node node # node to set the inner radius for +---@param radius number # inner radius +function gui.set_inner_radius(node, radius) end + +---The layer must be mapped to the gui scene in the gui editor. +---@param node node # node for which to set the layer +---@param layer string|hash # layer id +function gui.set_layer(node, layer) end + +---Sets the leading value for a text node. This value is used to +---scale the line spacing of text. +---@param node node # node for which to set the leading +---@param leading number # a scaling value for the line spacing (default=1) +function gui.set_leading(node, leading) end + +---Sets the line-break mode on a text node. +---This is only useful for text nodes. +---@param node node # node to set line-break for +---@param line_break boolean # true or false +function gui.set_line_break(node, line_break) end + +---Sets the outer bounds mode for a pie node. +---@param node node # node for which to set the outer bounds mode +---@param bounds_mode constant # the outer bounds mode of the pie node: +function gui.set_outer_bounds(node, bounds_mode) end + +---Sets the outline color of the supplied node. +---See gui.set_color <> for info how vectors encode color values. +---@param node node # node to set the outline color for +---@param color vector3|vector4 # new outline color +function gui.set_outline(node, color) end + +---Sets the parent node of the specified node. +---@param node node # node for which to set its parent +---@param parent node # parent node to set +---@param keep_scene_transform boolean # optional flag to make the scene position being perserved +function gui.set_parent(node, parent, keep_scene_transform) end + +---Set the paricle fx for a gui node +---@param node node # node to set particle fx for +---@param particlefx hash|string # particle fx id +function gui.set_particlefx(node, particlefx) end + +---Sets the number of generated vertices around the perimeter of a pie node. +---@param node node # pie node +---@param vertices number # vertex count +function gui.set_perimeter_vertices(node, vertices) end + +---The pivot specifies how the node is drawn and rotated from its position. +---@param node node # node to set pivot for +---@param pivot constant # pivot constant +function gui.set_pivot(node, pivot) end + +---Sets the position of the supplied node. +---@param node node # node to set the position for +---@param position vector3|vector4 # new position +function gui.set_position(node, position) end + +---Set the order number for the current GUI scene. +---The number dictates the sorting of the "gui" render predicate, +---in other words in which order the scene will be rendered in relation +---to other currently rendered GUI scenes. +---The number must be in the range 0 to 15. +---@param order number # rendering order (0-15) +function gui.set_render_order(order) end + +---Sets the rotation of the supplied node. +---The rotation is expressed in degree Euler angles. +---@param node node # node to set the rotation for +---@param rotation vector3|vector4 # new rotation +function gui.set_rotation(node, rotation) end + +---Sets the scaling of the supplied node. +---@param node node # node to set the scale for +---@param scale vector3|vector4 # new scale +function gui.set_scale(node, scale) end + +---Set the screen position to the supplied node +---@param node node # node to set the screen position to +---@param screen_position vector3 # screen position +function gui.set_screen_position(node, screen_position) end + +---Sets the shadow color of the supplied node. +---See gui.set_color <> for info how vectors encode color values. +---@param node node # node to set the shadow color for +---@param color vector3|vector4 # new shadow color +function gui.set_shadow(node, color) end + +---Sets the size of the supplied node. +--- You can only set size on nodes with size mode set to SIZE_MODE_MANUAL +---@param node node # node to set the size for +---@param size vector3|vector4 # new size +function gui.set_size(node, size) end + +---Sets the size mode of a node. +---The size mode defines how the node will adjust itself in size. Automatic +---size mode alters the node size based on the node's content. Automatic size +---mode works for Box nodes and Pie nodes which will both adjust their size +---to match the assigned image. Particle fx and Text nodes will ignore +---any size mode setting. +---@param node node # node to set size mode for +---@param size_mode constant # size mode to set +function gui.set_size_mode(node, size_mode) end + +---Set the slice9 configuration values for the node. +---@param node node # node to manipulate +---@param values vector4 # new values +function gui.set_slice9(node, values) end + +---Set the text value of a text node. This is only useful for text nodes. +---@param node node # node to set text for +---@param text string # text to set +function gui.set_text(node, text) end + +---Set the texture on a box or pie node. The texture must be mapped to +---the gui scene in the gui editor. The function points out which texture +---the node should render from. If the texture is an atlas, further +---information is needed to select which image/animation in the atlas +---to render. In such cases, use gui.play_flipbook() in +---addition to this function. +---@param node node # node to set texture for +---@param texture string|hash # texture id +function gui.set_texture(node, texture) end + +---Set the texture buffer data for a dynamically created texture. +---@param texture string|hash # texture id +---@param width number # texture width +---@param height number # texture height +---@param type string|constant # texture type +---@param buffer string # texture data +---@param flip boolean # flip texture vertically +---@return boolean # setting the data was successful +function gui.set_texture_data(texture, width, height, type, buffer, flip) end + +---Sets the tracking value of a text node. This value is used to +---adjust the vertical spacing of characters in the text. +---@param node node # node for which to set the tracking +---@param tracking number # a scaling number for the letter spacing (default=0) +function gui.set_tracking(node, tracking) end + +---Set if a node should be visible or not. Only visible nodes are rendered. +---@param node node # node to be visible or not +---@param visible boolean # whether the node should be visible or not +function gui.set_visible(node, visible) end + +---The x-anchor specifies how the node is moved when the game is run in a different resolution. +---@param node node # node to set x-anchor for +---@param anchor constant # anchor constant +function gui.set_xanchor(node, anchor) end + +---The y-anchor specifies how the node is moved when the game is run in a different resolution. +---@param node node # node to set y-anchor for +---@param anchor constant # anchor constant +function gui.set_yanchor(node, anchor) end + +---Shows the on-display touch keyboard. +---The specified type of keyboard is displayed if it is available on +---the device. +---This function is only available on iOS and Android. . +---@param type constant # keyboard type +---@param autoclose boolean # if the keyboard should automatically close when clicking outside +function gui.show_keyboard(type, autoclose) end + +---Stops the particle fx for a gui node +---@param node node # node to stop particle fx for +---@param options table # options when stopping the particle fx. Supported options: +function gui.stop_particlefx(node, options) end + +---This is a callback-function, which is called by the engine when a gui component is initialized. It can be used +---to set the initial state of the script and gui scene. +---@param self object # reference to the script state to be used for storing data +function init(self) end + +---This is a callback-function, which is called by the engine when user input is sent to the instance of the gui component. +---It can be used to take action on the input, e.g. modify the gui according to the input. +---For an instance to obtain user input, it must first acquire input +---focus through the message acquire_input_focus. +---Any instance that has obtained input will be put on top of an +---input stack. Input is sent to all listeners on the stack until the +---end of stack is reached, or a listener returns true +---to signal that it wants input to be consumed. +---See the documentation of acquire_input_focus <> for more +---information. +---The action parameter is a table containing data about the input mapped to the +---action_id. +---For mapped actions it specifies the value of the input and if it was just pressed or released. +---Actions are mapped to input in an input_binding-file. +---Mouse movement is specifically handled and uses nil as its action_id. +---The action only contains positional parameters in this case, such as x and y of the pointer. +---Here is a brief description of the available table fields: +--- +---Field Description +---value The amount of input given by the user. This is usually 1 for buttons and 0-1 for analogue inputs. This is not present for mouse movement. +---pressed If the input was pressed this frame. This is not present for mouse movement. +---released If the input was released this frame. This is not present for mouse movement. +---repeated If the input was repeated this frame. This is similar to how a key on a keyboard is repeated when you hold it down. This is not present for mouse movement. +---x The x value of a pointer device, if present. +---y The y value of a pointer device, if present. +---screen_x The screen space x value of a pointer device, if present. +---screen_y The screen space y value of a pointer device, if present. +---dx The change in x value of a pointer device, if present. +---dy The change in y value of a pointer device, if present. +---screen_dx The change in screen space x value of a pointer device, if present. +---screen_dy The change in screen space y value of a pointer device, if present. +---gamepad The index of the gamepad device that provided the input. +---touch List of touch input, one element per finger, if present. See table below about touch input +---Touch input table: +--- +---Field Description +---id A number identifying the touch input during its duration. +---pressed True if the finger was pressed this frame. +---released True if the finger was released this frame. +---tap_count Number of taps, one for single, two for double-tap, etc +---x The x touch location. +---y The y touch location. +---dx The change in x value. +---dy The change in y value. +---acc_x Accelerometer x value (if present). +---acc_y Accelerometer y value (if present). +---acc_z Accelerometer z value (if present). +---@param self object # reference to the script state to be used for storing data +---@param action_id hash # id of the received input action, as mapped in the input_binding-file +---@param action table # a table containing the input data, see above for a description +---@return boolean? # optional boolean to signal if the input should be consumed (not passed on to others) or not, default is false +function on_input(self, action_id, action) end + +---This is a callback-function, which is called by the engine whenever a message has been sent to the gui component. +---It can be used to take action on the message, e.g. update the gui or send a response back to the sender of the message. +---The message parameter is a table containing the message data. If the message is sent from the engine, the +---documentation of the message specifies which data is supplied. +---See the update <> function for examples on how to use this callback-function. +---@param self object # reference to the script state to be used for storing data +---@param message_id hash # id of the received message +---@param message table # a table containing the message data +function on_message(self, message_id, message) end + +--- +---This is a callback-function, which is called by the engine when the gui script is reloaded, e.g. from the editor. +---It can be used for live development, e.g. to tweak constants or set up the state properly for the script. +---@param self object # reference to the script state to be used for storing data +function on_reload(self) end + +---This is a callback-function, which is called by the engine every frame to update the state of a gui component. +---It can be used to perform any kind of gui related tasks, e.g. animating nodes. +---@param self object # reference to the script state to be used for storing data +---@param dt number # the time-step of the frame update +function update(self, dt) end + + + + +return gui
\ No newline at end of file diff --git a/meta/3rd/Defold/library/html5.lua b/meta/3rd/Defold/library/html5.lua new file mode 100644 index 00000000..e87568a9 --- /dev/null +++ b/meta/3rd/Defold/library/html5.lua @@ -0,0 +1,23 @@ +---HTML5 API documentation +---HTML5 platform specific functions. +--- The following functions are only available on HTML5 builds, the html5.* Lua namespace will not be available on other platforms. +---@class html5 +html5 = {} +---Executes the supplied string as JavaScript inside the browser. +---A call to this function is blocking, the result is returned as-is, as a string. +---(Internally this will execute the string using the eval() JavaScript function.) +---@param code string # Javascript code to run +---@return string # result as string +function html5.run(code) end + +---Set a JavaScript interaction listener callaback from lua that will be +---invoked when a user interacts with the web page by clicking, touching or typing. +---The callback can then call DOM restricted actions like requesting a pointer lock, +---or start playing sounds the first time the callback is invoked. +---@param callback fun(self: object) # The interaction callback. Pass an empty function or nil if you no longer wish to receive callbacks. +function html5.set_interaction_listener(callback) end + + + + +return html5
\ No newline at end of file diff --git a/meta/3rd/Defold/library/http.lua b/meta/3rd/Defold/library/http.lua new file mode 100644 index 00000000..67e7774f --- /dev/null +++ b/meta/3rd/Defold/library/http.lua @@ -0,0 +1,18 @@ +---HTTP API documentation +---Functions for performing HTTP and HTTPS requests. +---@class http +http = {} +---Perform a HTTP/HTTPS request. +--- If no timeout value is passed, the configuration value "network.http_timeout" is used. If that is not set, the timeout value is 0 (which blocks indefinitely). +---@param url string # target url +---@param method string # HTTP/HTTPS method, e.g. "GET", "PUT", "POST" etc. +---@param callback fun(self: object, id: hash, response: table) # response callback function +---@param headers table? # optional table with custom headers +---@param post_data string? # optional data to send +---@param options table? # optional table with request parameters. Supported entries: +function http.request(url, method, callback, headers, post_data, options) end + + + + +return http
\ No newline at end of file diff --git a/meta/3rd/Defold/library/image.lua b/meta/3rd/Defold/library/image.lua new file mode 100644 index 00000000..1dcab022 --- /dev/null +++ b/meta/3rd/Defold/library/image.lua @@ -0,0 +1,20 @@ +---Image API documentation +---Functions for creating image objects. +---@class image +image = {} +---luminance image type +image.TYPE_LUMINANCE = nil +---RGB image type +image.TYPE_RGB = nil +---RGBA image type +image.TYPE_RGBA = nil +---Load image (PNG or JPEG) from buffer. +---@param buffer string # image data buffer +---@param premult boolean? # optional flag if alpha should be premultiplied. Defaults to false +---@return table # object or nil if loading fails. The object is a table with the following fields: +function image.load(buffer, premult) end + + + + +return image
\ No newline at end of file diff --git a/meta/3rd/Defold/library/json.lua b/meta/3rd/Defold/library/json.lua new file mode 100644 index 00000000..2421d95e --- /dev/null +++ b/meta/3rd/Defold/library/json.lua @@ -0,0 +1,20 @@ +---JSON API documentation +---Manipulation of JSON data strings. +---@class json +json = {} +---Decode a string of JSON data into a Lua table. +---A Lua error is raised for syntax errors. +---@param json string # json data +---@return table # decoded json +function json.decode(json) end + +---Encode a lua table to a JSON string. +---A Lua error is raised for syntax errors. +---@param tbl table # lua table to encode +---@return string # encoded json +function json.encode(tbl) end + + + + +return json
\ No newline at end of file diff --git a/meta/3rd/Defold/library/label.lua b/meta/3rd/Defold/library/label.lua new file mode 100644 index 00000000..7646a0a8 --- /dev/null +++ b/meta/3rd/Defold/library/label.lua @@ -0,0 +1,20 @@ +---Label API documentation +---Label API documentation +---@class label +label = {} +---Gets the text from a label component +---@param url string|hash|url # the label to get the text from +---@return string # the label text +function label.get_text(url) end + +---Sets the text of a label component +--- This method uses the message passing that means the value will be set after dispatch messages step. +---More information is available in the Application Lifecycle manual <>. +---@param url string|hash|url # the label that should have a constant set +---@param text string # the text +function label.set_text(url, text) end + + + + +return label
\ No newline at end of file diff --git a/meta/3rd/Defold/library/luasocket.lua b/meta/3rd/Defold/library/luasocket.lua new file mode 100644 index 00000000..6f4d9103 --- /dev/null +++ b/meta/3rd/Defold/library/luasocket.lua @@ -0,0 +1,484 @@ +---LuaSocket API documentation +---LuaSocket <https://github.com/diegonehab/luasocket> is a Lua extension library that provides +---support for the TCP and UDP transport layers. Defold provides the "socket" namespace in +---runtime, which contain the core C functionality. Additional LuaSocket support modules for +---SMTP, HTTP, FTP etc are not part of the core included, but can be easily added to a project +---and used. +---Note the included helper module "socket.lua" in "builtins/scripts/socket.lua". Require this +---module to add some additional functions and shortcuts to the namespace: +---require "builtins.scripts.socket" +--- +--- +---LuaSocket is Copyright 2004-2007 Diego Nehab. All rights reserved. +---LuaSocket is free software, released under the MIT license (same license as the Lua core). +---@class socket +socket = {} +---Closes the TCP object. The internal socket used by the object is closed and the local address to which the object was bound is made available to other applications. No further operations (except for further calls to the close method) are allowed on a closed socket. +--- It is important to close all used sockets once they are not needed, since, in many systems, each socket uses a file descriptor, which are limited system resources. Garbage-collected objects are automatically closed before destruction, though. +function client:close() end + +---Check the read buffer status. +--- This is an internal method, any use is unlikely to be portable. +---@return boolean # true if there is any data in the read buffer, false otherwise. +function client:dirty() end + +---Returns the underlying socket descriptor or handle associated to the object. +--- This is an internal method, any use is unlikely to be portable. +---@return number # the descriptor or handle. In case the object has been closed, the return will be -1. +function client:getfd() end + +---Gets options for the TCP object. See client:setoption <> for description of the option names and values. +---@param option string # the name of the option to get: +---@return any # the option value, or nil in case of error. +---@return string # the error message, or nil if no error occurred. +function client:getoption(option) end + +---Returns information about the remote side of a connected client object. +--- It makes no sense to call this method on server objects. +---@return string # a string with the IP address of the peer, the port number that peer is using for the connection, and the family ("inet" or "inet6"). In case of error, the method returns nil. +function client:getpeername() end + +---Returns the local address information associated to the object. +---@return string # a string with local IP address, the local port number, and the family ("inet" or "inet6"). In case of error, the method returns nil. +function client:getsockname() end + +---Returns accounting information on the socket, useful for throttling of bandwidth. +---@return string # a string with the number of bytes received, the number of bytes sent, and the age of the socket object in seconds. +function client:getstats() end + +---Reads data from a client object, according to the specified read pattern. Patterns follow the Lua file I/O format, and the difference in performance between patterns is negligible. +---@param pattern string|number? # the read pattern that can be any of the following: +---@param prefix string? # an optional string to be concatenated to the beginning of any received data before return. +---@return string # the received pattern, or nil in case of error. +---@return string # the error message, or nil if no error occurred. The error message can be the string "closed" in case the connection was closed before the transmission was completed or the string "timeout" in case there was a timeout during the operation. +---@return string # a (possibly empty) string containing the partial that was received, or nil if no error occurred. +function client:receive(pattern, prefix) end + +---Sends data through client object. +---The optional arguments i and j work exactly like the standard string.sub <> Lua function to allow the selection of a substring to be sent. +--- Output is not buffered. For small strings, it is always better to concatenate them in Lua (with the .. operator) and send the result in one call instead of calling the method several times. +---@param data string # the string to be sent. +---@param i number? # optional starting index of the string. +---@param j number? # optional end index of string. +---@return number] the index of the last byte within [i, j # that has been sent, or nil in case of error. Notice that, if i is 1 or absent, this is effectively the total number of bytes sent. +---@return string # the error message, or nil if no error occurred. The error message can be "closed" in case the connection was closed before the transmission was completed or the string "timeout" in case there was a timeout during the operation. +---@return number] in case of error, the index of the last byte within [i, j # that has been sent. You might want to try again from the byte following that. nil if no error occurred. +function client:send(data, i, j) end + +---Sets the underling socket descriptor or handle associated to the object. The current one is simply replaced, not closed, and no other change to the object state is made +---@param handle number # the descriptor or handle to set. +function client:setfd(handle) end + +---Sets options for the TCP object. Options are only needed by low-level or time-critical applications. You should only modify an option if you are sure you need it. +---@param option string # the name of the option to set. The value is provided in the value parameter: +---@param value any? # the value to set for the specified option. +---@return number # the value 1, or nil in case of error. +---@return string # the error message, or nil if no error occurred. +function client:setoption(option, value) end + +---Resets accounting information on the socket, useful for throttling of bandwidth. +---@param received number # the new number of bytes received. +---@param sent number # the new number of bytes sent. +---@param age number # the new age in seconds. +---@return number # the value 1 in case of success, or nil in case of error. +function client:setstats(received, sent, age) end + +---Changes the timeout values for the object. By default, all I/O operations are blocking. That is, any call to the methods send, receive, and accept will block indefinitely, until the operation completes. The settimeout method defines a limit on the amount of time the I/O methods can block. When a timeout is set and the specified amount of time has elapsed, the affected methods give up and fail with an error code. +---There are two timeout modes and both can be used together for fine tuning. +--- Although timeout values have millisecond precision in LuaSocket, large blocks can cause I/O functions not to respect timeout values due to the time the library takes to transfer blocks to and from the OS and to and from the Lua interpreter. Also, function that accept host names and perform automatic name resolution might be blocked by the resolver for longer than the specified timeout value. +---@param value number # the amount of time to wait, in seconds. The nil timeout value allows operations to block indefinitely. Negative timeout values have the same effect. +---@param mode string? # optional timeout mode to set: +function client:settimeout(value, mode) end + +---Shuts down part of a full-duplex connection. +---@param mode string # which way of the connection should be shut down: +---@return number # the value 1. +function client:shutdown(mode) end + +---Closes a UDP object. The internal socket used by the object is closed and the local address to which the object was bound is made available to other applications. No further operations (except for further calls to the close method) are allowed on a closed socket. +--- It is important to close all used sockets once they are not needed, since, in many systems, each socket uses a file descriptor, which are limited system resources. Garbage-collected objects are automatically closed before destruction, though. +function connected:close() end + +---Gets an option value from the UDP object. See connected:setoption <> for description of the option names and values. +---@param option string # the name of the option to get: +---@return any # the option value, or nil in case of error. +---@return string # the error message, or nil if no error occurred. +function connected:getoption(option) end + +---Retrieves information about the peer associated with a connected UDP object. +--- It makes no sense to call this method on unconnected objects. +---@return string # a string with the IP address of the peer, the port number that peer is using for the connection, and the family ("inet" or "inet6"). In case of error, the method returns nil. +function connected:getpeername() end + +---Returns the local address information associated to the object. +--- UDP sockets are not bound to any address until the setsockname or the sendto method is called for the first time (in which case it is bound to an ephemeral port and the wild-card address). +---@return string # a string with local IP address, a number with the local port, and the family ("inet" or "inet6"). In case of error, the method returns nil. +function connected:getsockname() end + +---Receives a datagram from the UDP object. If the UDP object is connected, only datagrams coming from the peer are accepted. Otherwise, the returned datagram can come from any host. +---@param size number? # optional maximum size of the datagram to be retrieved. If there are more than size bytes available in the datagram, the excess bytes are discarded. If there are less then size bytes available in the current datagram, the available bytes are returned. If size is omitted, the maximum datagram size is used (which is currently limited by the implementation to 8192 bytes). +---@return string # the received datagram, or nil in case of error. +---@return string # the error message, or nil if no error occurred. +function connected:receive(size) end + +---Sends a datagram to the UDP peer of a connected object. +--- In UDP, the send method never blocks and the only way it can fail is if the underlying transport layer refuses to send a message to the specified address (i.e. no interface accepts the address). +---@param datagram string # a string with the datagram contents. The maximum datagram size for UDP is 64K minus IP layer overhead. However datagrams larger than the link layer packet size will be fragmented, which may deteriorate performance and/or reliability. +---@return number # the value 1 on success, or nil in case of error. +---@return string # the error message, or nil if no error occurred. +function connected:send(datagram) end + +---Sets options for the UDP object. Options are only needed by low-level or time-critical applications. You should only modify an option if you are sure you need it. +---@param option string # the name of the option to set. The value is provided in the value parameter: +---@param value any? # the value to set for the specified option. +---@return number # the value 1, or nil in case of error. +---@return string # the error message, or nil if no error occurred. +function connected:setoption(option, value) end + +---Changes the peer of a UDP object. This method turns an unconnected UDP object into a connected UDP object or vice versa. +---For connected objects, outgoing datagrams will be sent to the specified peer, and datagrams received from other peers will be discarded by the OS. Connected UDP objects must use the send and receive methods instead of sendto and receivefrom. +--- Since the address of the peer does not have to be passed to and from the OS, the use of connected UDP objects is recommended when the same peer is used for several transmissions and can result in up to 30% performance gains. +---@param _ string # if address is "*" and the object is connected, the peer association is removed and the object becomes an unconnected object again. +---@return number # the value 1 on success, or nil in case of error. +---@return string # the error message, or nil if no error occurred. +function connected:setpeername(_) end + +---Changes the timeout values for the object. By default, the receive and receivefrom operations are blocking. That is, any call to the methods will block indefinitely, until data arrives. The settimeout function defines a limit on the amount of time the functions can block. When a timeout is set and the specified amount of time has elapsed, the affected methods give up and fail with an error code. +--- In UDP, the send and sendto methods never block (the datagram is just passed to the OS and the call returns immediately). Therefore, the settimeout method has no effect on them. +---@param value number # the amount of time to wait, in seconds. The nil timeout value allows operations to block indefinitely. Negative timeout values have the same effect. +function connected:settimeout(value) end + +---Binds a master object to address and port on the local host. +---@param address string # an IP address or a host name. If address is "*", the system binds to all local interfaces using the INADDR_ANY constant. +---@param port number # the port to commect to, in the range [0..64K). If port is 0, the system automatically chooses an ephemeral port. +---@return number # the value 1, or nil in case of error. +---@return string # the error message, or nil if no error occurred. +function master:bind(address, port) end + +---Closes the TCP object. The internal socket used by the object is closed and the local address to which the object was bound is made available to other applications. No further operations (except for further calls to the close method) are allowed on a closed socket. +--- It is important to close all used sockets once they are not needed, since, in many systems, each socket uses a file descriptor, which are limited system resources. Garbage-collected objects are automatically closed before destruction, though. +function master:close() end + +---Attempts to connect a master object to a remote host, transforming it into a client object. Client objects support methods send, receive, getsockname, getpeername, settimeout, and close. +---Note that the function socket.connect is available and is a shortcut for the creation of client sockets. +---@param address string # an IP address or a host name. If address is "*", the system binds to all local interfaces using the INADDR_ANY constant. +---@param port number # the port to commect to, in the range [0..64K). If port is 0, the system automatically chooses an ephemeral port. +---@return number # the value 1, or nil in case of error. +---@return string # the error message, or nil if no error occurred. +function master:connect(address, port) end + +---Check the read buffer status. +--- This is an internal method, any use is unlikely to be portable. +---@return boolean # true if there is any data in the read buffer, false otherwise. +function master:dirty() end + +---Returns the underlying socket descriptor or handle associated to the object. +--- This is an internal method, any use is unlikely to be portable. +---@return number # the descriptor or handle. In case the object has been closed, the return will be -1. +function master:getfd() end + +---Returns the local address information associated to the object. +---@return string # a string with local IP address, the local port number, and the family ("inet" or "inet6"). In case of error, the method returns nil. +function master:getsockname() end + +---Returns accounting information on the socket, useful for throttling of bandwidth. +---@return string # a string with the number of bytes received, the number of bytes sent, and the age of the socket object in seconds. +function master:getstats() end + +---Specifies the socket is willing to receive connections, transforming the object into a server object. Server objects support the accept, getsockname, setoption, settimeout, and close methods. +---@param backlog number # the number of client connections that can be queued waiting for service. If the queue is full and another client attempts connection, the connection is refused. +---@return number # the value 1, or nil in case of error. +---@return string # the error message, or nil if no error occurred. +function master:listen(backlog) end + +---Sets the underling socket descriptor or handle associated to the object. The current one is simply replaced, not closed, and no other change to the object state is made +---@param handle number # the descriptor or handle to set. +function master:setfd(handle) end + +---Resets accounting information on the socket, useful for throttling of bandwidth. +---@param received number # the new number of bytes received. +---@param sent number # the new number of bytes sent. +---@param age number # the new age in seconds. +---@return number # the value 1 in case of success, or nil in case of error. +function master:setstats(received, sent, age) end + +---Changes the timeout values for the object. By default, all I/O operations are blocking. That is, any call to the methods send, receive, and accept will block indefinitely, until the operation completes. The settimeout method defines a limit on the amount of time the I/O methods can block. When a timeout is set and the specified amount of time has elapsed, the affected methods give up and fail with an error code. +---There are two timeout modes and both can be used together for fine tuning. +--- Although timeout values have millisecond precision in LuaSocket, large blocks can cause I/O functions not to respect timeout values due to the time the library takes to transfer blocks to and from the OS and to and from the Lua interpreter. Also, function that accept host names and perform automatic name resolution might be blocked by the resolver for longer than the specified timeout value. +---@param value number # the amount of time to wait, in seconds. The nil timeout value allows operations to block indefinitely. Negative timeout values have the same effect. +---@param mode string? # optional timeout mode to set: +function master:settimeout(value, mode) end + +---Waits for a remote connection on the server object and returns a client object representing that connection. +--- Calling socket.select with a server object in the recvt parameter before a call to accept does not guarantee accept will return immediately. Use the settimeout method or accept might block until another client shows up. +---@return client # if a connection is successfully initiated, a client object is returned, or nil in case of error. +---@return string # the error message, or nil if no error occurred. The error is "timeout" if a timeout condition is met. +function server:accept() end + +---Closes the TCP object. The internal socket used by the object is closed and the local address to which the object was bound is made available to other applications. No further operations (except for further calls to the close method) are allowed on a closed socket. +--- It is important to close all used sockets once they are not needed, since, in many systems, each socket uses a file descriptor, which are limited system resources. Garbage-collected objects are automatically closed before destruction, though. +function server:close() end + +---Check the read buffer status. +--- This is an internal method, any use is unlikely to be portable. +---@return boolean # true if there is any data in the read buffer, false otherwise. +function server:dirty() end + +---Returns the underlying socket descriptor or handle associated to the object. +--- This is an internal method, any use is unlikely to be portable. +---@return number # the descriptor or handle. In case the object has been closed, the return will be -1. +function server:getfd() end + +---Gets options for the TCP object. See server:setoption <> for description of the option names and values. +---@param option string # the name of the option to get: +---@return any # the option value, or nil in case of error. +---@return string # the error message, or nil if no error occurred. +function server:getoption(option) end + +---Returns the local address information associated to the object. +---@return string # a string with local IP address, the local port number, and the family ("inet" or "inet6"). In case of error, the method returns nil. +function server:getsockname() end + +---Returns accounting information on the socket, useful for throttling of bandwidth. +---@return string # a string with the number of bytes received, the number of bytes sent, and the age of the socket object in seconds. +function server:getstats() end + +---Sets the underling socket descriptor or handle associated to the object. The current one is simply replaced, not closed, and no other change to the object state is made +---@param handle number # the descriptor or handle to set. +function server:setfd(handle) end + +---Sets options for the TCP object. Options are only needed by low-level or time-critical applications. You should only modify an option if you are sure you need it. +---@param option string # the name of the option to set. The value is provided in the value parameter: +---@param value any? # the value to set for the specified option. +---@return number # the value 1, or nil in case of error. +---@return string # the error message, or nil if no error occurred. +function server:setoption(option, value) end + +---Resets accounting information on the socket, useful for throttling of bandwidth. +---@param received number # the new number of bytes received. +---@param sent number # the new number of bytes sent. +---@param age number # the new age in seconds. +---@return number # the value 1 in case of success, or nil in case of error. +function server:setstats(received, sent, age) end + +---Changes the timeout values for the object. By default, all I/O operations are blocking. That is, any call to the methods send, receive, and accept will block indefinitely, until the operation completes. The settimeout method defines a limit on the amount of time the I/O methods can block. When a timeout is set and the specified amount of time has elapsed, the affected methods give up and fail with an error code. +---There are two timeout modes and both can be used together for fine tuning. +--- Although timeout values have millisecond precision in LuaSocket, large blocks can cause I/O functions not to respect timeout values due to the time the library takes to transfer blocks to and from the OS and to and from the Lua interpreter. Also, function that accept host names and perform automatic name resolution might be blocked by the resolver for longer than the specified timeout value. +---@param value number # the amount of time to wait, in seconds. The nil timeout value allows operations to block indefinitely. Negative timeout values have the same effect. +---@param mode string? # optional timeout mode to set: +function server:settimeout(value, mode) end + +---max numbers of sockets the select function can handle +socket._SETSIZE = nil +---the current LuaSocket version +socket._VERSION = nil +---This function is a shortcut that creates and returns a TCP client object connected to a remote +---address at a given port. Optionally, the user can also specify the local address and port to +---bind (locaddr and locport), or restrict the socket family to "inet" or "inet6". +---Without specifying family to connect, whether a tcp or tcp6 connection is created depends on +---your system configuration. +---@param address string # the address to connect to. +---@param port number # the port to connect to. +---@param locaddr string? # optional local address to bind to. +---@param locport number? # optional local port to bind to. +---@param family string? # optional socket family to use, "inet" or "inet6". +---@return client # a new IPv6 TCP client object, or nil in case of error. +---@return string # the error message, or nil if no error occurred. +function socket.connect(address, port, locaddr, locport, family) end + +---This function converts a host name to IPv4 or IPv6 address. +---The supplied address can be an IPv4 or IPv6 address or host name. +---The function returns a table with all information returned by the resolver: +---{ +--- [1] = { +--- family = family-name-1, +--- addr = address-1 +--- }, +--- ... +--- [n] = { +--- family = family-name-n, +--- addr = address-n +--- } +---} +--- +--- +---Here, family contains the string "inet" for IPv4 addresses, and "inet6" for IPv6 addresses. +---In case of error, the function returns nil followed by an error message. +---@param address string # a hostname or an IPv4 or IPv6 address. +---@return table # a table with all information returned by the resolver, or if an error occurs, nil. +---@return string # the error message, or nil if no error occurred. +function socket.dns.getaddrinfo(address) end + +---Returns the standard host name for the machine as a string. +---@return string # the host name for the machine. +function socket.dns.gethostname() end + +---This function converts an address to host name. +---The supplied address can be an IPv4 or IPv6 address or host name. +---The function returns a table with all information returned by the resolver: +---{ +--- [1] = host-name-1, +--- ... +--- [n] = host-name-n, +---} +---@param address string # a hostname or an IPv4 or IPv6 address. +---@return table # a table with all information returned by the resolver, or if an error occurs, nil. +---@return string # the error message, or nil if no error occurred. +function socket.dns.getnameinfo(address) end + +---This function converts from an IPv4 address to host name. +---The address can be an IPv4 address or a host name. +---@param address string # an IPv4 address or host name. +---@return string # the canonic host name of the given address, or nil in case of an error. +---@return table|string # a table with all information returned by the resolver, or if an error occurs, the error message string. +function socket.dns.tohostname(address) end + +---This function converts a host name to IPv4 address. +---The address can be an IP address or a host name. +---@param address string # a hostname or an IP address. +---@return string # the first IP address found for the hostname, or nil in case of an error. +---@return table|string # a table with all information returned by the resolver, or if an error occurs, the error message string. +function socket.dns.toip(address) end + +---Returns the time in seconds, relative to the system epoch (Unix epoch time since January 1, 1970 (UTC) or Windows file time since January 1, 1601 (UTC)). +---You should use the values returned by this function for relative measurements only. +---@return number # the number of seconds elapsed. +function socket.gettime() end + +---This function creates and returns a clean try function that allows for cleanup before the exception is raised. +---The finalizer function will be called in protected mode (see protect <>). +---@param finalizer fun() # a function that will be called before the try throws the exception. +---@return fun() # the customized try function. +function socket.newtry(finalizer) end + +---Converts a function that throws exceptions into a safe function. This function only catches exceptions thrown by try functions. It does not catch normal Lua errors. +--- Beware that if your function performs some illegal operation that raises an error, the protected function will catch the error and return it as a string. This is because try functions uses errors as the mechanism to throw exceptions. +---@param func fun() # a function that calls a try function (or assert, or error) to throw exceptions. +---@return fun(fun:fun()) # an equivalent function that instead of throwing exceptions, returns nil followed by an error message. +function socket.protect(func) end + +---The function returns a list with the sockets ready for reading, a list with the sockets ready for writing and an error message. The error message is "timeout" if a timeout condition was met and nil otherwise. The returned tables are doubly keyed both by integers and also by the sockets themselves, to simplify the test if a specific socket has changed status. +---Recvt and sendt parameters can be empty tables or nil. Non-socket values (or values with non-numeric indices) in these arrays will be silently ignored. +---The returned tables are doubly keyed both by integers and also by the sockets themselves, to simplify the test if a specific socket has changed status. +--- This function can monitor a limited number of sockets, as defined by the constant socket._SETSIZE. This number may be as high as 1024 or as low as 64 by default, depending on the system. It is usually possible to change this at compile time. Invoking select with a larger number of sockets will raise an error. +--- A known bug in WinSock causes select to fail on non-blocking TCP sockets. The function may return a socket as writable even though the socket is not ready for sending. +--- Calling select with a server socket in the receive parameter before a call to accept does not guarantee accept will return immediately. Use the settimeout method or accept might block forever. +--- If you close a socket and pass it to select, it will be ignored. +---(Using select with non-socket objects: Any object that implements getfd and dirty can be used with select, allowing objects from other libraries to be used within a socket.select driven loop.) +---@param recvt table # array with the sockets to test for characters available for reading. +---@param sendt table # array with sockets that are watched to see if it is OK to immediately write on them. +---@param timeout number? # the maximum amount of time (in seconds) to wait for a change in status. Nil, negative or omitted timeout value allows the function to block indefinitely. +---@return table # a list with the sockets ready for reading. +---@return table # a list with the sockets ready for writing. +---@return string # an error message. "timeout" if a timeout condition was met, otherwise nil. +function socket.select(recvt, sendt, timeout) end + +---This function drops a number of arguments and returns the remaining. +---It is useful to avoid creation of dummy variables: +---D is the number of arguments to drop. Ret1 to retN are the arguments. +---The function returns retD+1 to retN. +---@param d number # the number of arguments to drop. +---@param ret1 any? # argument 1. +---@param ret2 any? # argument 2. +---@param retN any? # argument N. +---@return any? # argument D+1. +---@return any? # argument D+2. +---@return any? # argument N. +function socket.skip(d, ret1, ret2, retN) end + +---Freezes the program execution during a given amount of time. +---@param time number # the number of seconds to sleep for. +function socket.sleep(time) end + +---Creates and returns an IPv4 TCP master object. A master object can be transformed into a server object with the method listen (after a call to bind) or into a client object with the method connect. The only other method supported by a master object is the close method. +---@return master # a new IPv4 TCP master object, or nil in case of error. +---@return string # the error message, or nil if no error occurred. +function socket.tcp() end + +---Creates and returns an IPv6 TCP master object. A master object can be transformed into a server object with the method listen (after a call to bind) or into a client object with the method connect. The only other method supported by a master object is the close method. +---Note: The TCP object returned will have the option "ipv6-v6only" set to true. +---@return master # a new IPv6 TCP master object, or nil in case of error. +---@return string # the error message, or nil if no error occurred. +function socket.tcp6() end + +---Creates and returns an unconnected IPv4 UDP object. Unconnected objects support the sendto, receive, receivefrom, getoption, getsockname, setoption, settimeout, setpeername, setsockname, and close methods. The setpeername method is used to connect the object. +---@return unconnected # a new unconnected IPv4 UDP object, or nil in case of error. +---@return string # the error message, or nil if no error occurred. +function socket.udp() end + +---Creates and returns an unconnected IPv6 UDP object. Unconnected objects support the sendto, receive, receivefrom, getoption, getsockname, setoption, settimeout, setpeername, setsockname, and close methods. The setpeername method is used to connect the object. +---Note: The UDP object returned will have the option "ipv6-v6only" set to true. +---@return unconnected # a new unconnected IPv6 UDP object, or nil in case of error. +---@return string # the error message, or nil if no error occurred. +function socket.udp6() end + +---Closes a UDP object. The internal socket used by the object is closed and the local address to which the object was bound is made available to other applications. No further operations (except for further calls to the close method) are allowed on a closed socket. +--- It is important to close all used sockets once they are not needed, since, in many systems, each socket uses a file descriptor, which are limited system resources. Garbage-collected objects are automatically closed before destruction, though. +function unconnected:close() end + +---Gets an option value from the UDP object. See unconnected:setoption <> for description of the option names and values. +---@param option string # the name of the option to get: +---@return any # the option value, or nil in case of error. +---@return string # the error message, or nil if no error occurred. +function unconnected:getoption(option) end + +---Returns the local address information associated to the object. +--- UDP sockets are not bound to any address until the setsockname or the sendto method is called for the first time (in which case it is bound to an ephemeral port and the wild-card address). +---@return string # a string with local IP address, a number with the local port, and the family ("inet" or "inet6"). In case of error, the method returns nil. +function unconnected:getsockname() end + +---Receives a datagram from the UDP object. If the UDP object is connected, only datagrams coming from the peer are accepted. Otherwise, the returned datagram can come from any host. +---@param size number? # optional maximum size of the datagram to be retrieved. If there are more than size bytes available in the datagram, the excess bytes are discarded. If there are less then size bytes available in the current datagram, the available bytes are returned. If size is omitted, the maximum datagram size is used (which is currently limited by the implementation to 8192 bytes). +---@return string # the received datagram, or nil in case of error. +---@return string # the error message, or nil if no error occurred. +function unconnected:receive(size) end + +---Works exactly as the receive method, except it returns the IP address and port as extra return values (and is therefore slightly less efficient). +---@param size number? # optional maximum size of the datagram to be retrieved. +---@return string # the received datagram, or nil in case of error. +---@return string # the IP address, or the error message in case of error. +---@return number # the port number, or nil in case of error. +function unconnected:receivefrom(size) end + +---Sends a datagram to the specified IP address and port number. +--- In UDP, the send method never blocks and the only way it can fail is if the underlying transport layer refuses to send a message to the specified address (i.e. no interface accepts the address). +---@param datagram string # a string with the datagram contents. The maximum datagram size for UDP is 64K minus IP layer overhead. However datagrams larger than the link layer packet size will be fragmented, which may deteriorate performance and/or reliability. +---@param ip string # the IP address of the recipient. Host names are not allowed for performance reasons. +---@param port number # the port number at the recipient. +---@return number # the value 1 on success, or nil in case of error. +---@return string # the error message, or nil if no error occurred. +function unconnected:sendto(datagram, ip, port) end + +---Sets options for the UDP object. Options are only needed by low-level or time-critical applications. You should only modify an option if you are sure you need it. +---@param option string # the name of the option to set. The value is provided in the value parameter: +---@param value any? # the value to set for the specified option. +---@return number # the value 1, or nil in case of error. +---@return string # the error message, or nil if no error occurred. +function unconnected:setoption(option, value) end + +---Changes the peer of a UDP object. This method turns an unconnected UDP object into a connected UDP object or vice versa. +---For connected objects, outgoing datagrams will be sent to the specified peer, and datagrams received from other peers will be discarded by the OS. Connected UDP objects must use the send and receive methods instead of sendto and receivefrom. +--- Since the address of the peer does not have to be passed to and from the OS, the use of connected UDP objects is recommended when the same peer is used for several transmissions and can result in up to 30% performance gains. +---@param address string # an IP address or a host name. +---@param port number # the port number. +---@return number # the value 1 on success, or nil in case of error. +---@return string # the error message, or nil if no error occurred. +function unconnected:setpeername(address, port) end + +---Binds the UDP object to a local address. +--- This method can only be called before any datagram is sent through the UDP object, and only once. Otherwise, the system automatically binds the object to all local interfaces and chooses an ephemeral port as soon as the first datagram is sent. After the local address is set, either automatically by the system or explicitly by setsockname, it cannot be changed. +---@param address string # an IP address or a host name. If address is "*" the system binds to all local interfaces using the constant INADDR_ANY. +---@param port number # the port number. If port is 0, the system chooses an ephemeral port. +---@return number # the value 1 on success, or nil in case of error. +---@return string # the error message, or nil if no error occurred. +function unconnected:setsockname(address, port) end + +---Changes the timeout values for the object. By default, the receive and receivefrom operations are blocking. That is, any call to the methods will block indefinitely, until data arrives. The settimeout function defines a limit on the amount of time the functions can block. When a timeout is set and the specified amount of time has elapsed, the affected methods give up and fail with an error code. +--- In UDP, the send and sendto methods never block (the datagram is just passed to the OS and the call returns immediately). Therefore, the settimeout method has no effect on them. +---@param value number # the amount of time to wait, in seconds. The nil timeout value allows operations to block indefinitely. Negative timeout values have the same effect. +function unconnected:settimeout(value) end + + + + +return socket
\ No newline at end of file diff --git a/meta/3rd/Defold/library/message.lua b/meta/3rd/Defold/library/message.lua new file mode 100644 index 00000000..726b54a9 --- /dev/null +++ b/meta/3rd/Defold/library/message.lua @@ -0,0 +1,56 @@ +---Messaging API documentation +---Functions for passing messages and constructing URL objects. +---@class msg +msg = {} +---Post a message to a receiving URL. The most common case is to send messages +---to a component. If the component part of the receiver is omitted, the message +---is broadcast to all components in the game object. +---The following receiver shorthands are available: +--- +--- +--- * "." the current game object +--- +--- * "#" the current component +--- +--- There is a 2 kilobyte limit to the message parameter table size. +---@param receiver string|url|hash # The receiver must be a string in URL-format, a URL object or a hashed string. +---@param message_id string|hash # The id must be a string or a hashed string. +---@param message table|nil? # a lua table with message parameters to send. +function msg.post(receiver, message_id, message) end + +---This is equivalent to msg.url(nil) or msg.url("#"), which creates an url to the current +---script component. +---@return url # a new URL +function msg.url() end + +---The format of the string must be [socket:][path][#fragment], which is similar to a HTTP URL. +---When addressing instances: +--- +--- +--- * socket is the name of a valid world (a collection) +--- +--- * path is the id of the instance, which can either be relative the instance of the calling script or global +--- +--- * fragment would be the id of the desired component +--- +---In addition, the following shorthands are available: +--- +--- +--- * "." the current game object +--- +--- * "#" the current component +---@param urlstring string # string to create the url from +---@return url # a new URL +function msg.url(urlstring) end + +---creates a new URL from separate arguments +---@param socket string|hash? # socket of the URL +---@param path string|hash? # path of the URL +---@param fragment string|hash? # fragment of the URL +---@return url # a new URL +function msg.url(socket, path, fragment) end + + + + +return msg
\ No newline at end of file diff --git a/meta/3rd/Defold/library/model.lua b/meta/3rd/Defold/library/model.lua new file mode 100644 index 00000000..0631365e --- /dev/null +++ b/meta/3rd/Defold/library/model.lua @@ -0,0 +1,43 @@ +---Model API documentation +---Model API documentation +---@class model +model = {} +---Cancels all animation on a model component. +---@param url string|hash|url # the model for which to cancel the animation +function model.cancel(url) end + +---Gets the id of the game object that corresponds to a model skeleton bone. +---The returned game object can be used for parenting and transform queries. +---This function has complexity O(n), where n is the number of bones in the model skeleton. +---Game objects corresponding to a model skeleton bone can not be individually deleted. +---@param url string|hash|url # the model to query +---@param bone_id string|hash # id of the corresponding bone +---@return hash # id of the game object +function model.get_go(url, bone_id) end + +---Plays an animation on a model component with specified playback +---mode and parameters. +---An optional completion callback function can be provided that will be called when +---the animation has completed playing. If no function is provided, +---a model_animation_done <> message is sent to the script that started the animation. +--- The callback is not called (or message sent) if the animation is +---cancelled with model.cancel <>. The callback is called (or message sent) only for +---animations that play with the following playback modes: +--- +--- +--- * go.PLAYBACK_ONCE_FORWARD +--- +--- * go.PLAYBACK_ONCE_BACKWARD +--- +--- * go.PLAYBACK_ONCE_PINGPONG +---@param url string|hash|url # the model for which to play the animation +---@param anim_id string|hash # id of the animation to play +---@param playback constant # playback mode of the animation +---@param play_properties table? # optional table with properties Play properties table: +---@param complete_function (fun(self: object, message_id: hash, message: table, sender: hash))? # function to call when the animation has completed. +function model.play_anim(url, anim_id, playback, play_properties, complete_function) end + + + + +return model
\ No newline at end of file diff --git a/meta/3rd/Defold/library/particle_effects.lua b/meta/3rd/Defold/library/particle_effects.lua new file mode 100644 index 00000000..5bc8a5a6 --- /dev/null +++ b/meta/3rd/Defold/library/particle_effects.lua @@ -0,0 +1,52 @@ +---Particle effects API documentation +---Functions for controlling particle effect component playback and +---shader constants. +---@class particlefx +particlefx = {} +---postspawn state +particlefx.EMITTER_STATE_POSTSPAWN = nil +---prespawn state +particlefx.EMITTER_STATE_PRESPAWN = nil +---sleeping state +particlefx.EMITTER_STATE_SLEEPING = nil +---spawning state +particlefx.EMITTER_STATE_SPAWNING = nil +---Starts playing a particle FX component. +---Particle FX started this way need to be manually stopped through particlefx.stop(). +---Which particle FX to play is identified by the URL. +--- A particle FX will continue to emit particles even if the game object the particle FX component belonged to is deleted. You can call particlefx.stop() to stop it from emitting more particles. +---@param url string|hash|url # the particle fx that should start playing. +---@param emitter_state_function (fun(self: object, id: hash, emitter: hash, state: constant))? # optional callback function that will be called when an emitter attached to this particlefx changes state. +function particlefx.play(url, emitter_state_function) end + +---Resets a shader constant for a particle FX component emitter. +---The constant must be defined in the material assigned to the emitter. +---Resetting a constant through this function implies that the value defined in the material will be used. +---Which particle FX to reset a constant for is identified by the URL. +---@param url string|hash|url # the particle FX that should have a constant reset +---@param emitter string|hash # the id of the emitter +---@param constant string|hash # the name of the constant +function particlefx.reset_constant(url, emitter, constant) end + +---Sets a shader constant for a particle FX component emitter. +---The constant must be defined in the material assigned to the emitter. +---Setting a constant through this function will override the value set for that constant in the material. +---The value will be overridden until particlefx.reset_constant is called. +---Which particle FX to set a constant for is identified by the URL. +---@param url string|hash|url # the particle FX that should have a constant set +---@param emitter string|hash # the id of the emitter +---@param constant string|hash # the name of the constant +---@param value vector4 # the value of the constant +function particlefx.set_constant(url, emitter, constant, value) end + +---Stops a particle FX component from playing. +---Stopping a particle FX does not remove already spawned particles. +---Which particle FX to stop is identified by the URL. +---@param url string|hash|url # the particle fx that should stop playing +---@param options table # Options when stopping the particle fx. Supported options: +function particlefx.stop(url, options) end + + + + +return particlefx
\ No newline at end of file diff --git a/meta/3rd/Defold/library/profiler.lua b/meta/3rd/Defold/library/profiler.lua new file mode 100644 index 00000000..ed2a36fa --- /dev/null +++ b/meta/3rd/Defold/library/profiler.lua @@ -0,0 +1,89 @@ +---Profiler API documentation +---Functions for getting profiling data in runtime. +---More detailed profiling <https://www.defold.com/manuals/profiling/> and debugging <http://www.defold.com/manuals/debugging/> information available in the manuals. +---@class profiler +profiler = {} +---pause on current frame +profiler.MODE_PAUSE = nil +---start recording +profiler.MODE_RECORD = nil +---continously show latest frame +profiler.MODE_RUN = nil +---pause at peak frame +profiler.MODE_SHOW_PEAK_FRAME = nil +---show full profiler ui +profiler.VIEW_MODE_FULL = nil +---show mimimal profiler ui +profiler.VIEW_MODE_MINIMIZED = nil +---Creates and shows or hides and destroys the on-sceen profiler ui +---The profiler is a real-time tool that shows the numbers of milliseconds spent +---in each scope per frame as well as counters. The profiler is very useful for +---tracking down performance and resource problems. +---@param enabled boolean # true to enable, false to disable +function profiler.enable_ui(enabled) end + +---Get the percent of CPU usage by the application, as reported by the OS. +--- This function is not available on HTML5. +---For some platforms ( Android, Linux and Windows), this information is only available +---by default in the debug version of the engine. It can be enabled in release version as well +---by checking track_cpu under profiler in the game.project file. +---(This means that the engine will sample the CPU usage in intervalls during execution even in release mode.) +---@return number # of CPU used by the application +function profiler.get_cpu_usage() end + +---Get the amount of memory used (resident/working set) by the application in bytes, as reported by the OS. +--- This function is not available on HTML5. +---The values are gathered from internal OS functions which correspond to the following; +--- +---OS Value +--- iOS MacOSAndrod Linux <https://en.wikipedia.org/wiki/Resident_set_size> Resident memory +--- Windows <https://en.wikipedia.org/wiki/Working_set> Working set +--- HTML5 Not available +---@return number # used by the application +function profiler.get_memory_usage() end + +---Send a text to the profiler +---@param text string # the string to send to the profiler +function profiler.log_text(text) end + +---Get the number of recorded frames in the on-screen profiler ui recording buffer +---@return number # the number of recorded frames, zero if on-screen profiler is disabled +function profiler.recorded_frame_count() end + +---Starts a profile scope. +---@param name string # The name of the scope +function profiler.scope_begin(name) end + +---End the current profile scope. +function profiler.scope_end() end + +---Set the on-screen profile mode - run, pause, record or show peak frame +---@param mode constant # the mode to set the ui profiler in +function profiler.set_ui_mode(mode) end + +---Set the on-screen profile view mode - minimized or expanded +---@param mode constant # the view mode to set the ui profiler in +function profiler.set_ui_view_mode(mode) end + +---Shows or hides the time the engine waits for vsync in the on-screen profiler +---Each frame the engine waits for vsync and depending on your vsync settings and how much time +---your game logic takes this time can dwarf the time in the game logic making it hard to +---see details in the on-screen profiler graph and lists. +---Also, by hiding this the FPS times in the header show the time spent each time excuding the +---time spent waiting for vsync. This shows you how long time your game is spending actively +---working each frame. +---This setting also effects the display of recorded frames but does not affect the actual +---recorded frames so it is possible to toggle this on and off when viewing recorded frames. +---By default the vsync wait times is displayed in the profiler. +---@param visible boolean # true to include it in the display, false to hide it. +function profiler.set_ui_vsync_wait_visible(visible) end + +---Pauses and displays a frame from the recording buffer in the on-screen profiler ui +---The frame to show can either be an absolute frame or a relative frame to the current frame. +---@param frame_index table # a table where you specify one of the following parameters: +function profiler.view_recorded_frame(frame_index) end + + + + +return profiler
\ No newline at end of file diff --git a/meta/3rd/Defold/library/render.lua b/meta/3rd/Defold/library/render.lua new file mode 100644 index 00000000..5e3a111e --- /dev/null +++ b/meta/3rd/Defold/library/render.lua @@ -0,0 +1,439 @@ +---Rendering API documentation +---Rendering functions, messages and constants. The "render" namespace is +---accessible only from render scripts. +---The rendering API was originally built on top of OpenGL ES 2.0, and it uses a subset of the +---OpenGL computer graphics rendering API for rendering 2D and 3D computer +---graphics. Our current target is OpenGLES 3.0 with fallbacks to 2.0 on some platforms. +--- It is possible to create materials and write shaders that +---require features not in OpenGL ES 2.0, but those will not work cross platform. +---@class render +render = {} +render.BLEND_CONSTANT_ALPHA = nil +render.BLEND_CONSTANT_COLOR = nil +render.BLEND_DST_ALPHA = nil +render.BLEND_DST_COLOR = nil +render.BLEND_ONE = nil +render.BLEND_ONE_MINUS_CONSTANT_ALPHA = nil +render.BLEND_ONE_MINUS_CONSTANT_COLOR = nil +render.BLEND_ONE_MINUS_DST_ALPHA = nil +render.BLEND_ONE_MINUS_DST_COLOR = nil +render.BLEND_ONE_MINUS_SRC_ALPHA = nil +render.BLEND_ONE_MINUS_SRC_COLOR = nil +render.BLEND_SRC_ALPHA = nil +render.BLEND_SRC_ALPHA_SATURATE = nil +render.BLEND_SRC_COLOR = nil +render.BLEND_ZERO = nil +render.BUFFER_COLOR0_BIT = nil +render.BUFFER_COLOR1_BIT = nil +render.BUFFER_COLOR2_BIT = nil +render.BUFFER_COLOR3_BIT = nil +render.BUFFER_COLOR_BIT = nil +render.BUFFER_DEPTH_BIT = nil +render.BUFFER_STENCIL_BIT = nil +render.COMPARE_FUNC_ALWAYS = nil +render.COMPARE_FUNC_EQUAL = nil +render.COMPARE_FUNC_GEQUAL = nil +render.COMPARE_FUNC_GREATER = nil +render.COMPARE_FUNC_LEQUAL = nil +render.COMPARE_FUNC_LESS = nil +render.COMPARE_FUNC_NEVER = nil +render.COMPARE_FUNC_NOTEQUAL = nil +render.FACE_BACK = nil +render.FACE_FRONT = nil +render.FACE_FRONT_AND_BACK = nil +render.FILTER_LINEAR = nil +render.FILTER_NEAREST = nil +render.FORMAT_DEPTH = nil +render.FORMAT_LUMINANCE = nil +---May be nil if the format isn't supported +render.FORMAT_R16F = nil +---May be nil if the format isn't supported +render.FORMAT_R32F = nil +---May be nil if the format isn't supported +render.FORMAT_RG16F = nil +---May be nil if the format isn't supported +render.FORMAT_RG32F = nil +render.FORMAT_RGB = nil +---May be nil if the format isn't supported +render.FORMAT_RGB16F = nil +---May be nil if the format isn't supported +render.FORMAT_RGB32F = nil +render.FORMAT_RGBA = nil +---May be nil if the format isn't supported +render.FORMAT_RGBA16F = nil +---May be nil if the format isn't supported +render.FORMAT_RGBA32F = nil +render.FORMAT_STENCIL = nil +render.RENDER_TARGET_DEFAULT = nil +render.STATE_BLEND = nil +render.STATE_CULL_FACE = nil +render.STATE_DEPTH_TEST = nil +render.STATE_POLYGON_OFFSET_FILL = nil +render.STATE_STENCIL_TEST = nil +render.STENCIL_OP_DECR = nil +render.STENCIL_OP_DECR_WRAP = nil +render.STENCIL_OP_INCR = nil +render.STENCIL_OP_INCR_WRAP = nil +render.STENCIL_OP_INVERT = nil +render.STENCIL_OP_KEEP = nil +render.STENCIL_OP_REPLACE = nil +render.STENCIL_OP_ZERO = nil +render.WRAP_CLAMP_TO_BORDER = nil +render.WRAP_CLAMP_TO_EDGE = nil +render.WRAP_MIRRORED_REPEAT = nil +render.WRAP_REPEAT = nil +---Clear buffers in the currently enabled render target with specified value. If the render target has been created with multiple +---color attachments, all buffers will be cleared with the same value. +---@param buffers table # table with keys specifying which buffers to clear and values set to clear values. Available keys are: +function render.clear(buffers) end + +---Constant buffers are used to set shader program variables and are optionally passed to the render.draw() function. +---The buffer's constant elements can be indexed like an ordinary Lua table, but you can't iterate over them with pairs() or ipairs(). +---@return constant_buffer # new constant buffer +function render.constant_buffer() end + +---Deletes a previously created render target. +---@param render_target render_target # render target to delete +function render.delete_render_target(render_target) end + +---If a material is currently enabled, disable it. +---The name of the material must be specified in the ".render" resource set +---in the "game.project" setting. +function render.disable_material() end + +---Disables a render state. +---@param state constant # state to disable +function render.disable_state(state) end + +---Disables a texture unit for a render target that has previourly been enabled. +---@param unit number # texture unit to disable +function render.disable_texture(unit) end + +---Draws all objects that match a specified predicate. An optional constant buffer can be +---provided to override the default constants. If no constants buffer is provided, a default +---system constants buffer is used containing constants as defined in materials and set through +---go.set <> (or particlefx.set_constant <>) on visual components. +---@param predicate predicate # predicate to draw for +---@param options table? # optional table with properties: +function render.draw(predicate, options) end + +---Draws all 3d debug graphics such as lines drawn with "draw_line" messages and physics visualization. +---@param options table? # optional table with properties: +function render.draw_debug3d(options) end + +---If another material was already enabled, it will be automatically disabled +---and the specified material is used instead. +---The name of the material must be specified in the ".render" resource set +---in the "game.project" setting. +---@param material_id string|hash # material id to enable +function render.enable_material(material_id) end + +---Enables a particular render state. The state will be enabled until disabled. +---@param state constant # state to enable +function render.enable_state(state) end + +---Sets the specified render target's specified buffer to be +---used as texture with the specified unit. +---A material shader can then use the texture to sample from. +---@param unit number # texture unit to enable texture for +---@param render_target render_target # render target from which to enable the specified texture unit +---@param buffer_type constant # buffer type from which to enable the texture +function render.enable_texture(unit, render_target, buffer_type) end + +---Returns the logical window height that is set in the "game.project" settings. +---Note that the actual window pixel size can change, either by device constraints +---or user input. +---@return number # specified window height +function render.get_height() end + +---Returns the specified buffer height from a render target. +---@param render_target render_target # render target from which to retrieve the buffer height +---@param buffer_type constant # which type of buffer to retrieve the height from +---@return number # the height of the render target buffer texture +function render.get_render_target_height(render_target, buffer_type) end + +---Returns the specified buffer width from a render target. +---@param render_target render_target # render target from which to retrieve the buffer width +---@param buffer_type constant # which type of buffer to retrieve the width from +---@return number # the width of the render target buffer texture +function render.get_render_target_width(render_target, buffer_type) end + +---Returns the logical window width that is set in the "game.project" settings. +---Note that the actual window pixel size can change, either by device constraints +---or user input. +---@return number # specified window width (number) +function render.get_width() end + +---Returns the actual physical window height. +---Note that this value might differ from the logical height that is set in the +---"game.project" settings. +---@return number # actual window height +function render.get_window_height() end + +---Returns the actual physical window width. +---Note that this value might differ from the logical width that is set in the +---"game.project" settings. +---@return number # actual window width +function render.get_window_width() end + +---This function returns a new render predicate for objects with materials matching +---the provided material tags. The provided tags are combined into a bit mask +---for the predicate. If multiple tags are provided, the predicate matches materials +---with all tags ANDed together. +---The current limit to the number of tags that can be defined is 64. +---@param tags table # table of tags that the predicate should match. The tags can be of either hash or string type +---@return predicate # new predicate +function render.predicate(tags) end + +---Creates a new render target according to the supplied +---specification table. +---The table should contain keys specifying which buffers should be created +---with what parameters. Each buffer key should have a table value consisting +---of parameters. The following parameter keys are available: +--- +---Key Values +---format render.FORMAT_LUMINANCErender.FORMAT_RGBrender.FORMAT_RGBArender.FORMAT_DEPTHrender.FORMAT_STENCILrender.FORMAT_RGBA32Frender.FORMAT_RGBA16F +---width number +---height number +---min_filter render.FILTER_LINEARrender.FILTER_NEAREST +---mag_filter render.FILTER_LINEARrender.FILTER_NEAREST +---u_wrap render.WRAP_CLAMP_TO_BORDERrender.WRAP_CLAMP_TO_EDGErender.WRAP_MIRRORED_REPEATrender.WRAP_REPEAT +---v_wrap render.WRAP_CLAMP_TO_BORDERrender.WRAP_CLAMP_TO_EDGErender.WRAP_MIRRORED_REPEATrender.WRAP_REPEAT +---The render target can be created to support multiple color attachments. Each attachment can have different format settings and texture filters, +---but attachments must be added in sequence, meaning you cannot create a render target at slot 0 and 3. +---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). +---@param name string # render target name +---@param parameters table # table of buffer parameters, see the description for available keys and values +---@return render_target # new render target +function render.render_target(name, parameters) end + +---Specifies the arithmetic used when computing pixel values that are written to the frame +---buffer. In RGBA mode, pixels can be drawn using a function that blends the source RGBA +---pixel values with the destination pixel values already in the frame buffer. +---Blending is initially disabled. +---source_factor specifies which method is used to scale the source color components. +---destination_factor specifies which method is used to scale the destination color +---components. +---Source color components are referred to as (Rs,Gs,Bs,As). +---Destination color components are referred to as (Rd,Gd,Bd,Ad). +---The color specified by setting the blendcolor is referred to as (Rc,Gc,Bc,Ac). +---The source scale factor is referred to as (sR,sG,sB,sA). +---The destination scale factor is referred to as (dR,dG,dB,dA). +---The color values have integer values between 0 and (kR,kG,kB,kA), where kc = 2mc - 1 and mc is the number of bitplanes for that color. I.e for 8 bit color depth, color values are between 0 and 255. +---Available factor constants and corresponding scale factors: +--- +---Factor constant Scale factor (fR,fG,fB,fA) +---render.BLEND_ZERO (0,0,0,0) +---render.BLEND_ONE (1,1,1,1) +---render.BLEND_SRC_COLOR (Rs/kR,Gs/kG,Bs/kB,As/kA) +---render.BLEND_ONE_MINUS_SRC_COLOR(1,1,1,1) - (Rs/kR,Gs/kG,Bs/kB,As/kA) +---render.BLEND_DST_COLOR (Rd/kR,Gd/kG,Bd/kB,Ad/kA) +---render.BLEND_ONE_MINUS_DST_COLOR(1,1,1,1) - (Rd/kR,Gd/kG,Bd/kB,Ad/kA) +---render.BLEND_SRC_ALPHA (As/kA,As/kA,As/kA,As/kA) +---render.BLEND_ONE_MINUS_SRC_ALPHA(1,1,1,1) - (As/kA,As/kA,As/kA,As/kA) +---render.BLEND_DST_ALPHA (Ad/kA,Ad/kA,Ad/kA,Ad/kA) +---render.BLEND_ONE_MINUS_DST_ALPHA(1,1,1,1) - (Ad/kA,Ad/kA,Ad/kA,Ad/kA) +---render.BLEND_CONSTANT_COLOR (Rc,Gc,Bc,Ac) +---render.BLEND_ONE_MINUS_CONSTANT_COLOR(1,1,1,1) - (Rc,Gc,Bc,Ac) +---render.BLEND_CONSTANT_ALPHA (Ac,Ac,Ac,Ac) +---render.BLEND_ONE_MINUS_CONSTANT_ALPHA(1,1,1,1) - (Ac,Ac,Ac,Ac) +---render.BLEND_SRC_ALPHA_SATURATE(i,i,i,1) where i = min(As, kA - Ad) /kA +---The blended RGBA values of a pixel comes from the following equations: +--- +--- +--- * Rd = min(kR, Rs * sR + Rd * dR) +--- +--- * Gd = min(kG, Gs * sG + Gd * dG) +--- +--- * Bd = min(kB, Bs * sB + Bd * dB) +--- +--- * Ad = min(kA, As * sA + Ad * dA) +--- +---Blend function (render.BLEND_SRC_ALPHA, render.BLEND_ONE_MINUS_SRC_ALPHA) is useful for +---drawing with transparency when the drawn objects are sorted from farthest to nearest. +---It is also useful for drawing antialiased points and lines in arbitrary order. +---@param source_factor constant # source factor +---@param destination_factor constant # destination factor +function render.set_blend_func(source_factor, destination_factor) end + +---Specifies whether the individual color components in the frame buffer is enabled for writing (true) or disabled (false). For example, if blue is false, nothing is written to the blue component of any pixel in any of the color buffers, regardless of the drawing operation attempted. Note that writing are either enabled or disabled for entire color components, not the individual bits of a component. +---The component masks are all initially true. +---@param red boolean # red mask +---@param green boolean # green mask +---@param blue boolean # blue mask +---@param alpha boolean # alpha mask +function render.set_color_mask(red, green, blue, alpha) end + +---Specifies whether front- or back-facing polygons can be culled +---when polygon culling is enabled. Polygon culling is initially disabled. +---If mode is render.FACE_FRONT_AND_BACK, no polygons are drawn, but other +---primitives such as points and lines are drawn. The initial value for +---face_type is render.FACE_BACK. +---@param face_type constant # face type +function render.set_cull_face(face_type) end + +---Specifies the function that should be used to compare each incoming pixel +---depth value with the value present in the depth buffer. +---The comparison is performed only if depth testing is enabled and specifies +---the conditions under which a pixel will be drawn. +---Function constants: +--- +--- +--- * render.COMPARE_FUNC_NEVER (never passes) +--- +--- * render.COMPARE_FUNC_LESS (passes if the incoming depth value is less than the stored value) +--- +--- * render.COMPARE_FUNC_LEQUAL (passes if the incoming depth value is less than or equal to the stored value) +--- +--- * render.COMPARE_FUNC_GREATER (passes if the incoming depth value is greater than the stored value) +--- +--- * render.COMPARE_FUNC_GEQUAL (passes if the incoming depth value is greater than or equal to the stored value) +--- +--- * render.COMPARE_FUNC_EQUAL (passes if the incoming depth value is equal to the stored value) +--- +--- * render.COMPARE_FUNC_NOTEQUAL (passes if the incoming depth value is not equal to the stored value) +--- +--- * render.COMPARE_FUNC_ALWAYS (always passes) +--- +---The depth function is initially set to render.COMPARE_FUNC_LESS. +---@param func constant # depth test function, see the description for available values +function render.set_depth_func(func) end + +---Specifies whether the depth buffer is enabled for writing. The supplied mask governs +---if depth buffer writing is enabled (true) or disabled (false). +---The mask is initially true. +---@param depth boolean # depth mask +function render.set_depth_mask(depth) end + +---Sets the scale and units used to calculate depth values. +---If render.STATE_POLYGON_OFFSET_FILL is enabled, each fragment's depth value +---is offset from its interpolated value (depending on the depth value of the +---appropriate vertices). Polygon offset can be used when drawing decals, rendering +---hidden-line images etc. +---factor specifies a scale factor that is used to create a variable depth +---offset for each polygon. The initial value is 0. +---units is multiplied by an implementation-specific value to create a +---constant depth offset. The initial value is 0. +---The value of the offset is computed as factor ? DZ + r ? units +---DZ is a measurement of the depth slope of the polygon which is the change in z (depth) +---values divided by the change in either x or y coordinates, as you traverse a polygon. +---The depth values are in window coordinates, clamped to the range [0, 1]. +---r is the smallest value that is guaranteed to produce a resolvable difference. +---It's value is an implementation-specific constant. +---The offset is added before the depth test is performed and before the +---value is written into the depth buffer. +---@param factor number # polygon offset factor +---@param units number # polygon offset units +function render.set_polygon_offset(factor, units) end + +---Sets the projection matrix to use when rendering. +---@param matrix matrix4 # projection matrix +function render.set_projection(matrix) end + +---Sets a render target. Subsequent draw operations will be to the +---render target until it is replaced by a subsequent call to set_render_target. +---@param render_target render_target # render target to set. render.RENDER_TARGET_DEFAULT to set the default render target +---@param options table? # optional table with behaviour parameters +function render.set_render_target(render_target, options) end + +---sets the render target size +---@param render_target render_target # render target to set size for +---@param width number # new render target width +---@param height number # new render target height +function render.set_render_target_size(render_target, width, height) end + +---Stenciling is similar to depth-buffering as it enables and disables drawing on a +---per-pixel basis. First, GL drawing primitives are drawn into the stencil planes. +---Second, geometry and images are rendered but using the stencil planes to mask out +---where to draw. +---The stencil test discards a pixel based on the outcome of a comparison between the +---reference value ref and the corresponding value in the stencil buffer. +---func specifies the comparison function. See the table below for values. +---The initial value is render.COMPARE_FUNC_ALWAYS. +---ref specifies the reference value for the stencil test. The value is clamped to +---the range [0, 2n-1], where n is the number of bitplanes in the stencil buffer. +---The initial value is 0. +---mask is ANDed with both the reference value and the stored stencil value when the test +---is done. The initial value is all 1's. +---Function constant: +--- +--- +--- * render.COMPARE_FUNC_NEVER (never passes) +--- +--- * render.COMPARE_FUNC_LESS (passes if (ref & mask) < (stencil & mask)) +--- +--- * render.COMPARE_FUNC_LEQUAL (passes if (ref & mask) <= (stencil & mask)) +--- +--- * render.COMPARE_FUNC_GREATER (passes if (ref & mask) > (stencil & mask)) +--- +--- * render.COMPARE_FUNC_GEQUAL (passes if (ref & mask) >= (stencil & mask)) +--- +--- * render.COMPARE_FUNC_EQUAL (passes if (ref & mask) = (stencil & mask)) +--- +--- * render.COMPARE_FUNC_NOTEQUAL (passes if (ref & mask) != (stencil & mask)) +--- +--- * render.COMPARE_FUNC_ALWAYS (always passes) +---@param func constant # stencil test function, see the description for available values +---@param ref number # reference value for the stencil test +---@param mask number # mask that is ANDed with both the reference value and the stored stencil value when the test is done +function render.set_stencil_func(func, ref, mask) end + +---The stencil mask controls the writing of individual bits in the stencil buffer. +---The least significant n bits of the parameter mask, where n is the number of +---bits in the stencil buffer, specify the mask. +---Where a 1 bit appears in the mask, the corresponding +---bit in the stencil buffer can be written. Where a 0 bit appears in the mask, +---the corresponding bit in the stencil buffer is never written. +---The mask is initially all 1's. +---@param mask number # stencil mask +function render.set_stencil_mask(mask) end + +---The stencil test discards a pixel based on the outcome of a comparison between the +---reference value ref and the corresponding value in the stencil buffer. +---To control the test, call render.set_stencil_func <>. +---This function takes three arguments that control what happens to the stored stencil +---value while stenciling is enabled. If the stencil test fails, no change is made to the +---pixel's color or depth buffers, and sfail specifies what happens to the stencil buffer +---contents. +---Operator constants: +--- +--- +--- * render.STENCIL_OP_KEEP (keeps the current value) +--- +--- * render.STENCIL_OP_ZERO (sets the stencil buffer value to 0) +--- +--- * render.STENCIL_OP_REPLACE (sets the stencil buffer value to ref, as specified by render.set_stencil_func <>) +--- +--- * render.STENCIL_OP_INCR (increments the stencil buffer value and clamp to the maximum representable unsigned value) +--- +--- * render.STENCIL_OP_INCR_WRAP (increments the stencil buffer value and wrap to zero when incrementing the maximum representable unsigned value) +--- +--- * render.STENCIL_OP_DECR (decrements the current stencil buffer value and clamp to 0) +--- +--- * render.STENCIL_OP_DECR_WRAP (decrements the current stencil buffer value and wrap to the maximum representable unsigned value when decrementing zero) +--- +--- * render.STENCIL_OP_INVERT (bitwise inverts the current stencil buffer value) +--- +---dppass and dpfail specify the stencil buffer actions depending on whether subsequent +---depth buffer tests succeed (dppass) or fail (dpfail). +---The initial value for all operators is render.STENCIL_OP_KEEP. +---@param sfail constant # action to take when the stencil test fails +---@param dpfail constant # the stencil action when the stencil test passes +---@param dppass constant # the stencil action when both the stencil test and the depth test pass, or when the stencil test passes and either there is no depth buffer or depth testing is not enabled +function render.set_stencil_op(sfail, dpfail, dppass) end + +---Sets the view matrix to use when rendering. +---@param matrix matrix4 # view matrix to set +function render.set_view(matrix) end + +---Set the render viewport to the specified rectangle. +---@param x number # left corner +---@param y number # bottom corner +---@param width number # viewport width +---@param height number # viewport height +function render.set_viewport(x, y, width, height) end + + + + +return render
\ No newline at end of file diff --git a/meta/3rd/Defold/library/resource.lua b/meta/3rd/Defold/library/resource.lua new file mode 100644 index 00000000..5db356fc --- /dev/null +++ b/meta/3rd/Defold/library/resource.lua @@ -0,0 +1,181 @@ +---Resource API documentation +---Functions and constants to access resources. +---@class resource +resource = {} +---LIVEUPDATE_BUNDLED_RESOURCE_MISMATCH +resource.LIVEUPDATE_BUNDLED_RESOURCE_MISMATCH = nil +---LIVEUPDATE_ENGINE_VERSION_MISMATCH +resource.LIVEUPDATE_ENGINE_VERSION_MISMATCH = nil +---LIVEUPDATE_FORMAT_ERROR +resource.LIVEUPDATE_FORMAT_ERROR = nil +---LIVEUPDATE_INVALID_RESOURCE +resource.LIVEUPDATE_INVALID_RESOURCE = nil +---LIVEUPDATE_OK +resource.LIVEUPDATE_OK = nil +---LIVEUPDATE_SCHEME_MISMATCH +resource.LIVEUPDATE_SCHEME_MISMATCH = nil +---LIVEUPDATE_SIGNATURE_MISMATCH +resource.LIVEUPDATE_SIGNATURE_MISMATCH = nil +---LIVEUPDATE_VERSION_MISMATCH +resource.LIVEUPDATE_VERSION_MISMATCH = nil +---luminance type texture format +resource.TEXTURE_FORMAT_LUMINANCE = nil +---RGB type texture format +resource.TEXTURE_FORMAT_RGB = nil +---RGBA type texture format +resource.TEXTURE_FORMAT_RGBA = nil +---2D texture type +resource.TEXTURE_TYPE_2D = nil +---Constructor-like function with two purposes: +--- +--- +--- * Load the specified resource as part of loading the script +--- +--- * Return a hash to the run-time version of the resource +--- +--- This function can only be called within go.property <> function calls. +---@param path string? # optional resource path string to the resource +---@return hash # a path hash to the binary version of the resource +function resource.atlas(path) end + +---Constructor-like function with two purposes: +--- +--- +--- * Load the specified resource as part of loading the script +--- +--- * Return a hash to the run-time version of the resource +--- +--- This function can only be called within go.property <> function calls. +---@param path string? # optional resource path string to the resource +---@return hash # a path hash to the binary version of the resource +function resource.buffer(path) end + +---Constructor-like function with two purposes: +--- +--- +--- * Load the specified resource as part of loading the script +--- +--- * Return a hash to the run-time version of the resource +--- +--- This function can only be called within go.property <> function calls. +---@param path string? # optional resource path string to the resource +---@return hash # a path hash to the binary version of the resource +function resource.font(path) end + +---gets the buffer from a resource +---@param path hash|string # The path to the resource +---@return buffer # The resource buffer +function resource.get_buffer(path) end + +---Return a reference to the Manifest that is currently loaded. +---@return number # reference to the Manifest that is currently loaded +function resource.get_current_manifest() end + +---Gets the text metrics from a font +---@param url hash # the font to get the (unscaled) metrics from +---@param text string # text to measure +---@param options table? # A table containing parameters for the text. Supported entries: +---@return table # a table with the following fields: +function resource.get_text_metrics(url, text, options) end + +---Is any liveupdate data mounted and currently in use? +---This can be used to determine if a new manifest or zip file should be downloaded. +---@return bool # true if a liveupdate archive (any format) has been loaded +function resource.is_using_liveupdate_data() end + +---Loads the resource data for a specific resource. +---@param path string # The path to the resource +---@return buffer # Returns the buffer stored on disc +function resource.load(path) end + +---Constructor-like function with two purposes: +--- +--- +--- * Load the specified resource as part of loading the script +--- +--- * Return a hash to the run-time version of the resource +--- +--- This function can only be called within go.property <> function calls. +---@param path string? # optional resource path string to the resource +---@return hash # a path hash to the binary version of the resource +function resource.material(path) end + +---Sets the resource data for a specific resource +---@param path string|hash # The path to the resource +---@param buffer buffer # The buffer of precreated data, suitable for the intended resource type +function resource.set(path, buffer) end + +---sets the buffer of a resource +---@param path hash|string # The path to the resource +---@param buffer buffer # The resource buffer +function resource.set_buffer(path, buffer) end + +---Update internal sound resource (wavc/oggc) with new data +---@param path hash|string # The path to the resource +---@param buffer string # A lua string containing the binary sound data +function resource.set_sound(path, buffer) end + +---Sets the pixel data for a specific texture. +---@param path hash|string # The path to the resource +---@param table table # A table containing info about the texture. Supported entries: +---@param buffer buffer # The buffer of precreated pixel data Currently, only 1 mipmap is generated. +function resource.set_texture(path, table, buffer) end + +---Stores a zip file and uses it for live update content. The contents of the +---zip file will be verified against the manifest to ensure file integrity. +---It is possible to opt out of the resource verification using an option passed +---to this function. +---The path is stored in the (internal) live update location. +---@param path string # the path to the original file on disc +---@param callback fun(self: object, status: constant) # the callback function executed after the storage has completed +---@param options table? # optional table with extra parameters. Supported entries: +function resource.store_archive(path, callback, options) end + +---Create a new manifest from a buffer. The created manifest is verified +---by ensuring that the manifest was signed using the bundled public/private +---key-pair during the bundle process and that the manifest supports the current +---running engine version. Once the manifest is verified it is stored on device. +---The next time the engine starts (or is rebooted) it will look for the stored +---manifest before loading resources. Storing a new manifest allows the +---developer to update the game, modify existing resources, or add new +---resources to the game through LiveUpdate. +---@param manifest_buffer string # the binary data that represents the manifest +---@param callback fun(self: object, status: constant) # the callback function executed once the engine has attempted to store the manifest. +function resource.store_manifest(manifest_buffer, callback) end + +---add a resource to the data archive and runtime index. The resource will be verified +---internally before being added to the data archive. +---@param manifest_reference number # The manifest to check against. +---@param data string # The resource data that should be stored. +---@param hexdigest string # The expected hash for the resource, retrieved through collectionproxy.missing_resources. +---@param callback fun(self: object, hexdigest: string, status: boolean) # The callback function that is executed once the engine has been attempted to store the resource. +function resource.store_resource(manifest_reference, data, hexdigest, callback) end + +---Constructor-like function with two purposes: +--- +--- +--- * Load the specified resource as part of loading the script +--- +--- * Return a hash to the run-time version of the resource +--- +--- This function can only be called within go.property <> function calls. +---@param path string? # optional resource path string to the resource +---@return hash # a path hash to the binary version of the resource +function resource.texture(path) end + +---Constructor-like function with two purposes: +--- +--- +--- * Load the specified resource as part of loading the script +--- +--- * Return a hash to the run-time version of the resource +--- +--- This function can only be called within go.property <> function calls. +---@param path string? # optional resource path string to the resource +---@return hash # a path hash to the binary version of the resource +function resource.tile_source(path) end + + + + +return resource
\ No newline at end of file diff --git a/meta/3rd/Defold/library/sound.lua b/meta/3rd/Defold/library/sound.lua new file mode 100644 index 00000000..647de702 --- /dev/null +++ b/meta/3rd/Defold/library/sound.lua @@ -0,0 +1,126 @@ +---Sound API documentation +---Sound API documentation +---@class sound +sound = {} +---Get mixer group gain +--- Note that gain is in linear scale, between 0 and 1. +---To get the dB value from the gain, use the formula 20 * log(gain). +---Inversely, to find the linear value from a dB value, use the formula +---10db/20. +---@param group string|hash # group name +---@return number # gain in linear scale +function sound.get_group_gain(group) end + +---Get a mixer group name as a string. +--- This function is to be used for debugging and +---development tooling only. The function does a reverse hash lookup, which does not +---return a proper string value when the game is built in release mode. +---@param group string|hash # group name +---@return string # group name +function sound.get_group_name(group) end + +---Get a table of all mixer group names (hashes). +---@return table # table of mixer group names +function sound.get_groups() end + +---Get peak value from mixer group. +--- Note that gain is in linear scale, between 0 and 1. +---To get the dB value from the gain, use the formula 20 * log(gain). +---Inversely, to find the linear value from a dB value, use the formula +---10db/20. +---Also note that the returned value might be an approximation and in particular +---the effective window might be larger than specified. +---@param group string|hash # group name +---@param window number # window length in seconds +---@return number # peak value for left channel +---@return number # peak value for right channel +function sound.get_peak(group, window) end + +---Get RMS (Root Mean Square) value from mixer group. This value is the +---square root of the mean (average) value of the squared function of +---the instantaneous values. +---For instance: for a sinewave signal with a peak gain of -1.94 dB (0.8 linear), +---the RMS is 0.8 ? 1/sqrt(2) which is about 0.566. +--- Note the returned value might be an approximation and in particular +---the effective window might be larger than specified. +---@param group string|hash # group name +---@param window number # window length in seconds +---@return number # RMS value for left channel +---@return number # RMS value for right channel +function sound.get_rms(group, window) end + +---Checks if background music is playing, e.g. from iTunes. +--- On non mobile platforms, +---this function always return false. +--- On Android you can only get a correct reading +---of this state if your game is not playing any sounds itself. This is a limitation +---in the Android SDK. If your game is playing any sounds, even with a gain of zero, this +---function will return false. +---The best time to call this function is: +--- +--- +--- * In the init function of your main collection script before any sounds are triggered +--- +--- * In a window listener callback when the window.WINDOW_EVENT_FOCUS_GAINED event is received +--- +---Both those times will give you a correct reading of the state even when your application is +---swapped out and in while playing sounds and it works equally well on Android and iOS. +---@return boolean # true if music is playing, otherwise false. +function sound.is_music_playing() end + +---Checks if a phone call is active. If there is an active phone call all +---other sounds will be muted until the phone call is finished. +--- On non mobile platforms, +---this function always return false. +---@return boolean # true if there is an active phone call, false otherwise. +function sound.is_phone_call_active() end + +---Pause all active voices +---@param url string|hash|url # the sound that should pause +---@param pause bool # true if the sound should pause +function sound.pause(url, pause) end + +---Make the sound component play its sound. Multiple voices are supported. The limit is set to 32 voices per sound component. +--- Note that gain is in linear scale, between 0 and 1. +---To get the dB value from the gain, use the formula 20 * log(gain). +---Inversely, to find the linear value from a dB value, use the formula +---10db/20. +--- A sound will continue to play even if the game object the sound component belonged to is deleted. You can call sound.stop() to stop the sound. +---@param url string|hash|url # the sound that should play +---@param play_properties table? # +---@param complete_function (fun(self: object, message_id: hash, message: table, sender: number))? # function to call when the sound has finished playing. +---@return number # The identifier for the sound voice +function sound.play(url, play_properties, complete_function) end + +---Set gain on all active playing voices of a sound. +--- Note that gain is in linear scale, between 0 and 1. +---To get the dB value from the gain, use the formula 20 * log(gain). +---Inversely, to find the linear value from a dB value, use the formula +---10db/20. +---@param url string|hash|url # the sound to set the gain of +---@param gain number? # sound gain between 0 and 1. The final gain of the sound will be a combination of this gain, the group gain and the master gain. +function sound.set_gain(url, gain) end + +---Set mixer group gain +--- Note that gain is in linear scale, between 0 and 1. +---To get the dB value from the gain, use the formula 20 * log(gain). +---Inversely, to find the linear value from a dB value, use the formula +---10db/20. +---@param group string|hash # group name +---@param gain number # gain in linear scale +function sound.set_group_gain(group, gain) end + +---Set panning on all active playing voices of a sound. +---The valid range is from -1.0 to 1.0, representing -45 degrees left, to +45 degrees right. +---@param url string|hash|url # the sound to set the panning value to +---@param pan number? # sound panning between -1.0 and 1.0 +function sound.set_pan(url, pan) end + +---Stop playing all active voices +---@param url string|hash|url # the sound that should stop +function sound.stop(url) end + + + + +return sound
\ No newline at end of file diff --git a/meta/3rd/Defold/library/sprite.lua b/meta/3rd/Defold/library/sprite.lua new file mode 100644 index 00000000..6e909d15 --- /dev/null +++ b/meta/3rd/Defold/library/sprite.lua @@ -0,0 +1,32 @@ +---Sprite API documentation +---Sprite API documentation +---@class sprite +sprite = {} +---Play an animation on a sprite component from its tile set +---An optional completion callback function can be provided that will be called when +---the animation has completed playing. If no function is provided, +---a animation_done <> message is sent to the script that started the animation. +---@param url string|hash|url # the sprite that should play the animation +---@param id # hash name hash of the animation to play +---@param complete_function (fun(self: object, message_id: hash, message: table, sender: number))? # function to call when the animation has completed. +---@param play_properties table? # optional table with properties: +function sprite.play_flipbook(url, id, complete_function, play_properties) end + +---Sets horizontal flipping of the provided sprite's animations. +---The sprite is identified by its URL. +---If the currently playing animation is flipped by default, flipping it again will make it appear like the original texture. +---@param url string|hash|url # the sprite that should flip its animations +---@param flip boolean # true if the sprite should flip its animations, false if not +function sprite.set_hflip(url, flip) end + +---Sets vertical flipping of the provided sprite's animations. +---The sprite is identified by its URL. +---If the currently playing animation is flipped by default, flipping it again will make it appear like the original texture. +---@param url string|hash|url # the sprite that should flip its animations +---@param flip boolean # true if the sprite should flip its animations, false if not +function sprite.set_vflip(url, flip) end + + + + +return sprite
\ No newline at end of file diff --git a/meta/3rd/Defold/library/system.lua b/meta/3rd/Defold/library/system.lua new file mode 100644 index 00000000..039f7490 --- /dev/null +++ b/meta/3rd/Defold/library/system.lua @@ -0,0 +1,161 @@ +---System API documentation +---Functions and messages for using system resources, controlling the engine, +---error handling and debugging. +---@class sys +sys = {} +---network connected through other, non cellular, connection +sys.NETWORK_CONNECTED = nil +---network connected through mobile cellular +sys.NETWORK_CONNECTED_CELLULAR = nil +---no network connection found +sys.NETWORK_DISCONNECTED = nil +---deserializes buffer into a lua table +---@param buffer string # buffer to deserialize from +---@return table # lua table with deserialized data +function sys.deserialize(buffer) end + +---Terminates the game application and reports the specified code to the OS. +---@param code number # exit code to report to the OS, 0 means clean exit +function sys.exit(code) end + +---Returns a table with application information for the requested app. +--- On iOS, the app_string is an url scheme for the app that is queried. Your +---game needs to list the schemes that are queried in an LSApplicationQueriesSchemes array +---in a custom "Info.plist". +--- On Android, the app_string is the package identifier for the app. +---@param app_string string # platform specific string with application package or query, see above for details. +---@return table # table with application information in the following fields: +function sys.get_application_info(app_string) end + +---The path from which the application is run. +---@return string # path to application executable +function sys.get_application_path() end + +---Get config value from the game.project configuration file. +---In addition to the project file, configuration values can also be passed +---to the runtime as command line arguments with the --config argument. +---@param key string # key to get value for. The syntax is SECTION.KEY +---@return string # config value as a string. nil if the config key doesn't exists +function sys.get_config(key) end + +---Get config value from the game.project configuration file with default value +---@param key string # key to get value for. The syntax is SECTION.KEY +---@param default_value string # default value to return if the value does not exist +---@return string # config value as a string. default_value if the config key does not exist +function sys.get_config(key, default_value) end + +--- Returns the current network connectivity status +---on mobile platforms. +---On desktop, this function always return sys.NETWORK_CONNECTED. +---@return constant # network connectivity status: +function sys.get_connectivity() end + +---Returns a table with engine information. +---@return table # table with engine information in the following fields: +function sys.get_engine_info() end + +---Returns an array of tables with information on network interfaces. +---@return table # an array of tables. Each table entry contain the following fields: +function sys.get_ifaddrs() end + +---The save-file path is operating system specific and is typically located under the user's home directory. +---@param application_id string # user defined id of the application, which helps define the location of the save-file +---@param file_name string # file-name to get path for +---@return string # path to save-file +function sys.get_save_file(application_id, file_name) end + +---Returns a table with system information. +---@param options table # (optional) options table - ignore_secure boolean this flag ignores values might be secured by OS e.g. device_ident +---@return table # table with system information in the following fields: +function sys.get_sys_info(options) end + +---If the file exists, it must have been created by sys.save to be loaded. +---@param filename string # file to read from +---@return table # lua table, which is empty if the file could not be found +function sys.load(filename) end + +---Loads a custom resource. Specify the full filename of the resource that you want +---to load. When loaded, the file data is returned as a string. +---If loading fails, the function returns nil plus the error message. +---In order for the engine to include custom resources in the build process, you need +---to specify them in the "custom_resources" key in your "game.project" settings file. +---You can specify single resource files or directories. If a directory is included +---in the resource list, all files and directories in that directory is recursively +---included: +---For example "main/data/,assets/level_data.json". +---@param filename string # resource to load, full path +---@return string # loaded data, or nil if the resource could not be loaded +---@return string # the error message, or nil if no error occurred +function sys.load_resource(filename) end + +---Open URL in default application, typically a browser +---@param url string # url to open +---@param attributes table? # table with attributes target - string : Optional. Specifies the target attribute or the name of the window. The following values are supported: - _self - (default value) URL replaces the current page. - _blank - URL is loaded into a new window, or tab. - _parent - URL is loaded into the parent frame. - _top - URL replaces any framesets that may be loaded. - name - The name of the window (Note: the name does not specify the title of the new window). +---@return boolean # a boolean indicating if the url could be opened or not +function sys.open_url(url, attributes) end + +---Reboots the game engine with a specified set of arguments. +---Arguments will be translated into command line arguments. Calling reboot +---function is equivalent to starting the engine with the same arguments. +---On startup the engine reads configuration from "game.project" in the +---project root. +---@param arg1 string # argument 1 +---@param arg2 string # argument 2 +---@param arg3 string # argument 3 +---@param arg4 string # argument 4 +---@param arg5 string # argument 5 +---@param arg6 string # argument 6 +function sys.reboot(arg1, arg2, arg3, arg4, arg5, arg6) end + +---The table can later be loaded by sys.load. +---Use sys.get_save_file to obtain a valid location for the file. +---Internally, this function uses a workspace buffer sized output file sized 512kb. +---This size reflects the output file size which must not exceed this limit. +---Additionally, the total number of rows that any one table may contain is limited to 65536 +---(i.e. a 16 bit range). When tables are used to represent arrays, the values of +---keys are permitted to fall within a 32 bit range, supporting sparse arrays, however +---the limit on the total number of rows remains in effect. +---@param filename string # file to write to +---@param table table # lua table to save +---@return boolean # a boolean indicating if the table could be saved or not +function sys.save(filename, table) end + +---The buffer can later deserialized by sys.deserialize. +---This method has all the same limitations as sys.save. +---@param table table # lua table to serialize +---@return string # serialized data buffer +function sys.serialize(table) end + +---Sets the host that is used to check for network connectivity against. +---@param host string # hostname to check against +function sys.set_connectivity_host(host) end + +---Set the Lua error handler function. +---The error handler is a function which is called whenever a lua runtime error occurs. +---@param error_handler fun(source: string, message: string, traceback: string) # the function to be called on error +function sys.set_error_handler(error_handler) end + +---Set game update-frequency (frame cap). This option is equivalent to display.update_frequency in +---the "game.project" settings but set in run-time. If Vsync checked in "game.project", the rate will +---be clamped to a swap interval that matches any detected main monitor refresh rate. If Vsync is +---unchecked the engine will try to respect the rate in software using timers. There is no +---guarantee that the frame cap will be achieved depending on platform specifics and hardware settings. +---@param frequency number # target frequency. 60 for 60 fps +function sys.set_update_frequency(frequency) end + +---Set the vsync swap interval. The interval with which to swap the front and back buffers +---in sync with vertical blanks (v-blank), the hardware event where the screen image is updated +---with data from the front buffer. A value of 1 swaps the buffers at every v-blank, a value of +---2 swaps the buffers every other v-blank and so on. A value of 0 disables waiting for v-blank +---before swapping the buffers. Default value is 1. +---When setting the swap interval to 0 and having vsync disabled in +---"game.project", the engine will try to respect the set frame cap value from +---"game.project" in software instead. +---This setting may be overridden by driver settings. +---@param swap_interval number # target swap interval. +function sys.set_vsync_swap_interval(swap_interval) end + + + + +return sys
\ No newline at end of file diff --git a/meta/3rd/Defold/library/tilemap.lua b/meta/3rd/Defold/library/tilemap.lua new file mode 100644 index 00000000..d9e4e8bb --- /dev/null +++ b/meta/3rd/Defold/library/tilemap.lua @@ -0,0 +1,78 @@ +---Tilemap API documentation +---Functions and messages used to manipulate tile map components. +---@class tilemap +tilemap = {} +---flip tile horizontally +tilemap.H_FLIP = nil +---rotate tile 180 degrees clockwise +tilemap.ROTATE_180 = nil +---rotate tile 270 degrees clockwise +tilemap.ROTATE_270 = nil +---rotate tile 90 degrees clockwise +tilemap.ROTATE_90 = nil +---flip tile vertically +tilemap.V_FLIP = nil +---Get the bounds for a tile map. This function returns multiple values: +---The lower left corner index x and y coordinates (1-indexed), +---the tile map width and the tile map height. +---The resulting values take all tile map layers into account, meaning that +---the bounds are calculated as if all layers were collapsed into one. +---@param url string|hash|url # the tile map +---@return number # x coordinate of the bottom left corner +---@return number # y coordinate of the bottom left corner +---@return number # number of columns (width) in the tile map +---@return number # number of rows (height) in the tile map +function tilemap.get_bounds(url) end + +---Get the tile set at the specified position in the tilemap. +---The position is identified by the tile index starting at origin +---with index 1, 1. (see tilemap.set_tile() <>) +---Which tile map and layer to query is identified by the URL and the +---layer name parameters. +---@param url string|hash|url # the tile map +---@param layer string|hash # name of the layer for the tile +---@param x number # x-coordinate of the tile +---@param y number # y-coordinate of the tile +---@return number # index of the tile +function tilemap.get_tile(url, layer, x, y) end + +---Replace a tile in a tile map with a new tile. +---The coordinates of the tiles are indexed so that the "first" tile just +---above and to the right of origin has coordinates 1,1. +---Tiles to the left of and below origin are indexed 0, -1, -2 and so forth. +--- +---+-------+-------+------+------+ +---| 0,3 | 1,3 | 2,3 | 3,3 | +---+-------+-------+------+------+ +---| 0,2 | 1,2 | 2,2 | 3,2 | +---+-------+-------+------+------+ +---| 0,1 | 1,1 | 2,1 | 3,1 | +---+-------O-------+------+------+ +---| 0,0 | 1,0 | 2,0 | 3,0 | +---+-------+-------+------+------+ +--- +--- +---The coordinates must be within the bounds of the tile map as it were created. +---That is, it is not possible to extend the size of a tile map by setting tiles outside the edges. +---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. +---Transform bitmask is arithmetic sum of one or both FLIP constants (tilemap.H_FLIP, tilemap.V_FLIP) and/or one of ROTATION constants +---(tilemap.ROTATE_90, tilemap.ROTATE_180, tilemap.ROTATE_270). +---Flip always applies before rotation (clockwise). +---@param url string|hash|url # the tile map +---@param layer string|hash # name of the layer for the tile +---@param x number # x-coordinate of the tile +---@param y number # y-coordinate of the tile +---@param tile number # index of new tile to set. 0 resets the cell +---@param transform_bitmask number? # optional flip and/or rotation should be applied to the tile +function tilemap.set_tile(url, layer, x, y, tile, transform_bitmask) end + +---Sets the visibility of the tilemap layer +---@param url string|hash|url # the tile map +---@param layer string|hash # name of the layer for the tile +---@param visible boolean # should the layer be visible +function tilemap.set_visible(url, layer, visible) end + + + + +return tilemap
\ No newline at end of file diff --git a/meta/3rd/Defold/library/timer.lua b/meta/3rd/Defold/library/timer.lua new file mode 100644 index 00000000..4a112fcd --- /dev/null +++ b/meta/3rd/Defold/library/timer.lua @@ -0,0 +1,36 @@ +---Timer API documentation +---Timers allow you to set a delay and a callback to be called when the timer completes. +---The timers created with this API are updated with the collection timer where they +---are created. If you pause or speed up the collection (using set_time_step) it will +---also affect the new timer. +---@class timer +timer = {} +---Indicates an invalid timer handle +timer.INVALID_TIMER_HANDLE = nil +---You may cancel a timer from inside a timer callback. +---Cancelling a timer that is already executed or cancelled is safe. +---@param handle hash # the timer handle returned by timer.delay() +---@return boolean # if the timer was active, false if the timer is already cancelled / complete +function timer.cancel(handle) end + +---Adds a timer and returns a unique handle +---You may create more timers from inside a timer callback. +---Using a delay of 0 will result in a timer that triggers at the next frame just before +---script update functions. +---If you want a timer that triggers on each frame, set delay to 0.0f and repeat to true. +---Timers created within a script will automatically die when the script is deleted. +---@param delay number # time interval in seconds +---@param _repeat boolean # true = repeat timer until cancel, false = one-shot timer +---@param callback fun(self: object, handle: number, time_elapsed: number) # timer callback function +---@return hash # handle identifier for the create timer, returns timer.INVALID_TIMER_HANDLE if the timer can not be created +function timer.delay(delay, _repeat, callback) end + +---Manual triggering a callback for a timer. +---@param handle hash # the timer handle returned by timer.delay() +---@return boolean # if the timer was active, false if the timer is already cancelled / complete +function timer.trigger(handle) end + + + + +return timer
\ No newline at end of file diff --git a/meta/3rd/Defold/library/vector_math.lua b/meta/3rd/Defold/library/vector_math.lua new file mode 100644 index 00000000..8196bfd6 --- /dev/null +++ b/meta/3rd/Defold/library/vector_math.lua @@ -0,0 +1,406 @@ +---Vector math API documentation +---Functions for mathematical operations on vectors, matrices and quaternions. +--- +--- +--- * The vector types (vmath.vector3 and vmath.vector4) supports addition and subtraction +--- with vectors of the same type. Vectors can be negated and multiplied (scaled) or divided by numbers. +--- +--- * The quaternion type (vmath.quat) supports multiplication with other quaternions. +--- +--- * The matrix type (vmath.matrix4) can be multiplied with numbers, other matrices +--- and vmath.vector4 values. +--- +--- * All types performs equality comparison by each component value. +--- +---The following components are available for the various types: +--- +--- vector3 +---x, y and z. Example: v.y +--- vector4 +---x, y, z, and w. Example: v.w +--- quaternion +---x, y, z, and w. Example: q.w +--- matrix4 +---m00 to m33 where the first number is the row (starting from 0) and the second +---number is the column. Columns can be accessed with c0 to c3, returning a vector4. +---Example: m.m21 which is equal to m.c1.z +--- vector +---indexed by number 1 to the vector length. Example: v[3] + +---@class vmath +vmath = {} +---Calculates the conjugate of a quaternion. The result is a +---quaternion with the same magnitudes but with the sign of +---the imaginary (vector) parts changed: +---q* = [w, -v] +---@param q1 quaternion # quaternion of which to calculate the conjugate +---@return quaternion # the conjugate +function vmath.conj(q1) end + +---Given two linearly independent vectors P and Q, the cross product, +---P ? Q, is a vector that is perpendicular to both P and Q and +---therefore normal to the plane containing them. +---If the two vectors have the same direction (or have the exact +---opposite direction from one another, i.e. are not linearly independent) +---or if either one has zero length, then their cross product is zero. +---@param v1 vector3 # first vector +---@param v2 vector3 # second vector +---@return vector3 # a new vector representing the cross product +function vmath.cross(v1, v2) end + +---The returned value is a scalar defined as: +---P ? Q = |P| |Q| cos ? +---where ? is the angle between the vectors P and Q. +--- +--- +--- * If the dot product is positive then the angle between the vectors is below 90 degrees. +--- +--- * If the dot product is zero the vectors are perpendicular (at right-angles to each other). +--- +--- * If the dot product is negative then the angle between the vectors is more than 90 degrees. +---@param v1 vector3|vector4 # first vector +---@param v2 vector3|vector4 # second vector +---@return number # dot product +function vmath.dot(v1, v2) end + +---The resulting matrix is the inverse of the supplied matrix. +--- For ortho-normal matrices, e.g. regular object transformation, +---use vmath.ortho_inv() instead. +---The specialized inverse for ortho-normalized matrices is much faster +---than the general inverse. +---@param m1 matrix4 # matrix to invert +---@return matrix4 # inverse of the supplied matrix +function vmath.inv(m1) end + +---Returns the length of the supplied vector or quaternion. +---If you are comparing the lengths of vectors or quaternions, you should compare +---the length squared instead as it is slightly more efficient to calculate +---(it eliminates a square root calculation). +---@param v vector3|vector4|quat # value of which to calculate the length +---@return number # length +function vmath.length(v) end + +---Returns the squared length of the supplied vector or quaternion. +---@param v vector3|vector4|quat # value of which to calculate the squared length +---@return number # squared length +function vmath.length_sqr(v) end + +---Linearly interpolate between two vectors. The function +---treats the vectors as positions and interpolates between +---the positions in a straight line. Lerp is useful to describe +---transitions from one place to another over time. +--- The function does not clamp t between 0 and 1. +---@param t number # interpolation parameter, 0-1 +---@param v1 vector3|vector4 # vector to lerp from +---@param v2 vector3|vector4 # vector to lerp to +---@return vector3|vector4 # the lerped vector +function vmath.lerp(t, v1, v2) end + +---Linearly interpolate between two quaternions. Linear +---interpolation of rotations are only useful for small +---rotations. For interpolations of arbitrary rotations, +---vmath.slerp <> yields much better results. +--- The function does not clamp t between 0 and 1. +---@param t number # interpolation parameter, 0-1 +---@param q1 quaternion # quaternion to lerp from +---@param q2 quaternion # quaternion to lerp to +---@return quaternion # the lerped quaternion +function vmath.lerp(t, q1, q2) end + +---Linearly interpolate between two values. Lerp is useful +---to describe transitions from one value to another over time. +--- The function does not clamp t between 0 and 1. +---@param t number # interpolation parameter, 0-1 +---@param n1 number # number to lerp from +---@param n2 number # number to lerp to +---@return number # the lerped number +function vmath.lerp(t, n1, n2) end + +---The resulting identity matrix describes a transform with +---no translation or rotation. +---@return matrix4 # identity matrix +function vmath.matrix4() end + +---Creates a new matrix with all components set to the +---corresponding values from the supplied matrix. I.e. +---the function creates a copy of the given matrix. +---@param m1 matrix4 # existing matrix +---@return matrix4 # matrix which is a copy of the specified matrix +function vmath.matrix4(m1) end + +---The resulting matrix describes a rotation around the axis by the specified angle. +---@param v vector3 # axis +---@param angle number # angle in radians +---@return matrix4 # matrix represented by axis and angle +function vmath.matrix4_axis_angle(v, angle) end + +---The resulting matrix describes the same rotation as the quaternion, but does not have any translation (also like the quaternion). +---@param q quaternion # quaternion to create matrix from +---@return matrix4 # matrix represented by quaternion +function vmath.matrix4_from_quat(q) end + +---Constructs a frustum matrix from the given values. The left, right, +---top and bottom coordinates of the view cone are expressed as distances +---from the center of the near clipping plane. The near and far coordinates +---are expressed as distances from the tip of the view frustum cone. +---@param left number # coordinate for left clipping plane +---@param right number # coordinate for right clipping plane +---@param bottom number # coordinate for bottom clipping plane +---@param top number # coordinate for top clipping plane +---@param near number # coordinate for near clipping plane +---@param far number # coordinate for far clipping plane +---@return matrix4 # matrix representing the frustum +function vmath.matrix4_frustum(left, right, bottom, top, near, far) end + +---The resulting matrix is created from the supplied look-at parameters. +---This is useful for constructing a view matrix for a camera or +---rendering in general. +---@param eye vector3 # eye position +---@param look_at vector3 # look-at position +---@param up vector3 # up vector +---@return matrix4 # look-at matrix +function vmath.matrix4_look_at(eye, look_at, up) end + +---Creates an orthographic projection matrix. +---This is useful to construct a projection matrix for a camera or rendering in general. +---@param left number # coordinate for left clipping plane +---@param right number # coordinate for right clipping plane +---@param bottom number # coordinate for bottom clipping plane +---@param top number # coordinate for top clipping plane +---@param near number # coordinate for near clipping plane +---@param far number # coordinate for far clipping plane +---@return matrix4 # orthographic projection matrix +function vmath.matrix4_orthographic(left, right, bottom, top, near, far) end + +---Creates a perspective projection matrix. +---This is useful to construct a projection matrix for a camera or rendering in general. +---@param fov number # angle of the full vertical field of view in radians +---@param aspect number # aspect ratio +---@param near number # coordinate for near clipping plane +---@param far number # coordinate for far clipping plane +---@return matrix4 # perspective projection matrix +function vmath.matrix4_perspective(fov, aspect, near, far) end + +---The resulting matrix describes a rotation around the x-axis +---by the specified angle. +---@param angle number # angle in radians around x-axis +---@return matrix4 # matrix from rotation around x-axis +function vmath.matrix4_rotation_x(angle) end + +---The resulting matrix describes a rotation around the y-axis +---by the specified angle. +---@param angle number # angle in radians around y-axis +---@return matrix4 # matrix from rotation around y-axis +function vmath.matrix4_rotation_y(angle) end + +---The resulting matrix describes a rotation around the z-axis +---by the specified angle. +---@param angle number # angle in radians around z-axis +---@return matrix4 # matrix from rotation around z-axis +function vmath.matrix4_rotation_z(angle) end + +---The resulting matrix describes a translation of a point +---in euclidean space. +---@param position vector3|vector4 # position vector to create matrix from +---@return matrix4 # matrix from the supplied position vector +function vmath.matrix4_translation(position) end + +---Performs an element wise multiplication between two vectors of the same type +---The returned value is a vector defined as (e.g. for a vector3): +---v = vmath.mul_per_elem(a, b) = vmath.vector3(a.x * b.x, a.y * b.y, a.z * b.z) +---@param v1 vector3|vector4 # first vector +---@param v2 vector3|vector4 # second vector +---@return vector3|vector4 # multiplied vector +function vmath.mul_per_elem(v1, v2) end + +---Normalizes a vector, i.e. returns a new vector with the same +---direction as the input vector, but with length 1. +--- The length of the vector must be above 0, otherwise a +---division-by-zero will occur. +---@param v1 vector3|vector4|quat # vector to normalize +---@return vector3|vector4|quat # new normalized vector +function vmath.normalize(v1) end + +---The resulting matrix is the inverse of the supplied matrix. +---The supplied matrix has to be an ortho-normal matrix, e.g. +---describe a regular object transformation. +--- For matrices that are not ortho-normal +---use the general inverse vmath.inv() instead. +---@param m1 matrix4 # ortho-normalized matrix to invert +---@return matrix4 # inverse of the supplied matrix +function vmath.ortho_inv(m1) end + +---Calculates the extent the projection of the first vector onto the second. +---The returned value is a scalar p defined as: +---p = |P| cos ? / |Q| +---where ? is the angle between the vectors P and Q. +---@param v1 vector3 # vector to be projected on the second +---@param v2 vector3 # vector onto which the first will be projected, must not have zero length +---@return number # the projected extent of the first vector onto the second +function vmath.project(v1, v2) end + +---Creates a new identity quaternion. The identity +---quaternion is equal to: +---vmath.quat(0, 0, 0, 1) +---@return quaternion # new identity quaternion +function vmath.quat() end + +---Creates a new quaternion with all components set to the +---corresponding values from the supplied quaternion. I.e. +---This function creates a copy of the given quaternion. +---@param q1 quaternion # existing quaternion +---@return quaternion # new quaternion +function vmath.quat(q1) end + +---Creates a new quaternion with the components set +---according to the supplied parameter values. +---@param x number # x coordinate +---@param y number # y coordinate +---@param z number # z coordinate +---@param w number # w coordinate +---@return quaternion # new quaternion +function vmath.quat(x, y, z, w) end + +---The resulting quaternion describes a rotation of angle +---radians around the axis described by the unit vector v. +---@param v vector3 # axis +---@param angle number # angle +---@return quaternion # quaternion representing the axis-angle rotation +function vmath.quat_axis_angle(v, angle) end + +---The resulting quaternion describes the rotation from the +---identity quaternion (no rotation) to the coordinate system +---as described by the given x, y and z base unit vectors. +---@param x vector3 # x base vector +---@param y vector3 # y base vector +---@param z vector3 # z base vector +---@return quaternion # quaternion representing the rotation of the specified base vectors +function vmath.quat_basis(x, y, z) end + +---The resulting quaternion describes the rotation that, +---if applied to the first vector, would rotate the first +---vector to the second. The two vectors must be unit +---vectors (of length 1). +--- The result is undefined if the two vectors point in opposite directions +---@param v1 vector3 # first unit vector, before rotation +---@param v2 vector3 # second unit vector, after rotation +---@return quaternion # quaternion representing the rotation from first to second vector +function vmath.quat_from_to(v1, v2) end + +---The resulting quaternion describes a rotation of angle +---radians around the x-axis. +---@param angle number # angle in radians around x-axis +---@return quaternion # quaternion representing the rotation around the x-axis +function vmath.quat_rotation_x(angle) end + +---The resulting quaternion describes a rotation of angle +---radians around the y-axis. +---@param angle number # angle in radians around y-axis +---@return quaternion # quaternion representing the rotation around the y-axis +function vmath.quat_rotation_y(angle) end + +---The resulting quaternion describes a rotation of angle +---radians around the z-axis. +---@param angle number # angle in radians around z-axis +---@return quaternion # quaternion representing the rotation around the z-axis +function vmath.quat_rotation_z(angle) end + +---Returns a new vector from the supplied vector that is +---rotated by the rotation described by the supplied +---quaternion. +---@param q quaternion # quaternion +---@param v1 vector3 # vector to rotate +---@return vector3 # the rotated vector +function vmath.rotate(q, v1) end + +---Spherically interpolates between two vectors. The difference to +---lerp is that slerp treats the vectors as directions instead of +---positions in space. +---The direction of the returned vector is interpolated by the angle +---and the magnitude is interpolated between the magnitudes of the +---from and to vectors. +--- Slerp is computationally more expensive than lerp. +---The function does not clamp t between 0 and 1. +---@param t number # interpolation parameter, 0-1 +---@param v1 vector3|vector4 # vector to slerp from +---@param v2 vector3|vector4 # vector to slerp to +---@return vector3|vector4 # the slerped vector +function vmath.slerp(t, v1, v2) end + +---Slerp travels the torque-minimal path maintaining constant +---velocity, which means it travels along the straightest path along +---the rounded surface of a sphere. Slerp is useful for interpolation +---of rotations. +---Slerp travels the torque-minimal path, which means it travels +---along the straightest path the rounded surface of a sphere. +--- The function does not clamp t between 0 and 1. +---@param t number # interpolation parameter, 0-1 +---@param q1 quaternion # quaternion to slerp from +---@param q2 quaternion # quaternion to slerp to +---@return quaternion # the slerped quaternion +function vmath.slerp(t, q1, q2) end + +---Creates a vector of arbitrary size. The vector is initialized +---with numeric values from a table. +--- The table values are converted to floating point +---values. If a value cannot be converted, a 0 is stored in that +---value position in the vector. +---@param t table # table of numbers +---@return vector # new vector +function vmath.vector(t) end + +---Creates a new zero vector with all components set to 0. +---@return vector3 # new zero vector +function vmath.vector3() end + +---Creates a new vector with all components set to the +---supplied scalar value. +---@param n number # scalar value to splat +---@return vector3 # new vector +function vmath.vector3(n) end + +---Creates a new vector with all components set to the +---corresponding values from the supplied vector. I.e. +---This function creates a copy of the given vector. +---@param v1 vector3 # existing vector +---@return vector3 # new vector +function vmath.vector3(v1) end + +---Creates a new vector with the components set to the +---supplied values. +---@param x number # x coordinate +---@param y number # y coordinate +---@param z number # z coordinate +---@return vector3 # new vector +function vmath.vector3(x, y, z) end + +---Creates a new zero vector with all components set to 0. +---@return vector4 # new zero vector +function vmath.vector4() end + +---Creates a new vector with all components set to the +---supplied scalar value. +---@param n number # scalar value to splat +---@return vector4 # new vector +function vmath.vector4(n) end + +---Creates a new vector with all components set to the +---corresponding values from the supplied vector. I.e. +---This function creates a copy of the given vector. +---@param v1 vector4 # existing vector +---@return vector4 # new vector +function vmath.vector4(v1) end + +---Creates a new vector with the components set to the +---supplied values. +---@param x number # x coordinate +---@param y number # y coordinate +---@param z number # z coordinate +---@param w number # w coordinate +---@return vector4 # new vector +function vmath.vector4(x, y, z, w) end + + + + +return vmath
\ No newline at end of file diff --git a/meta/3rd/Defold/library/window.lua b/meta/3rd/Defold/library/window.lua new file mode 100644 index 00000000..e62ae7c4 --- /dev/null +++ b/meta/3rd/Defold/library/window.lua @@ -0,0 +1,56 @@ +---Window API documentation +---Functions and constants to access the window, window event listeners +---and screen dimming. +---@class window +window = {} +---dimming mode off +window.DIMMING_OFF = nil +---dimming mode on +window.DIMMING_ON = nil +---dimming mode unknown +window.DIMMING_UNKNOWN = nil +---deiconified window event +window.WINDOW_EVENT_DEICONIFIED = nil +---focus gained window event +window.WINDOW_EVENT_FOCUS_GAINED = nil +---focus lost window event +window.WINDOW_EVENT_FOCUS_LOST = nil +---iconify window event +window.WINDOW_EVENT_ICONFIED = nil +---resized window event +window.WINDOW_EVENT_RESIZED = nil +--- Returns the current dimming mode set on a mobile device. +---The dimming mode specifies whether or not a mobile device should dim the screen after a period without user interaction. +---On platforms that does not support dimming, window.DIMMING_UNKNOWN is always returned. +---@return constant # The mode for screen dimming +function window.get_dim_mode() end + +---This returns the current lock state of the mouse cursor +---@return boolean # The lock state +function window.get_mouse_lock() end + +---This returns the current window size (width and height). +---@return number # The window width +---@return number # The window height +function window.get_size() end + +--- Sets the dimming mode on a mobile device. +---The dimming mode specifies whether or not a mobile device should dim the screen after a period without user interaction. The dimming mode will only affect the mobile device while the game is in focus on the device, but not when the game is running in the background. +---This function has no effect on platforms that does not support dimming. +---@param mode constant # The mode for screen dimming +function window.set_dim_mode(mode) end + +---Sets a window event listener. +---@param callback fun(self: object, event: constant, data: table) # A callback which receives info about window events. Pass an empty function or nil if you no longer wish to receive callbacks. +function window.set_listener(callback) end + +---Set the locking state for current mouse cursor on a PC platform. +---This function locks or unlocks the mouse cursor to the center point of the window. While the cursor is locked, +---mouse position updates will still be sent to the scripts as usual. +---@param flag boolean # The lock state for the mouse cursor +function window.set_mouse_lock(flag) end + + + + +return window
\ No newline at end of file diff --git a/meta/3rd/Defold/library/zlib.lua b/meta/3rd/Defold/library/zlib.lua new file mode 100644 index 00000000..9d05c192 --- /dev/null +++ b/meta/3rd/Defold/library/zlib.lua @@ -0,0 +1,18 @@ +---Zlib compression API documentation +---Functions for compression and decompression of string buffers. +---@class zlib +zlib = {} +---A lua error is raised is on error +---@param buf string # buffer to deflate +---@return string # deflated buffer +function zlib.deflate(buf) end + +---A lua error is raised is on error +---@param buf string # buffer to inflate +---@return string # inflated buffer +function zlib.inflate(buf) end + + + + +return zlib
\ No newline at end of file diff --git a/meta/3rd/OpenResty/library/ngx.lua b/meta/3rd/OpenResty/library/ngx.lua index 1971641f..a223709d 100644 --- a/meta/3rd/OpenResty/library/ngx.lua +++ b/meta/3rd/OpenResty/library/ngx.lua @@ -106,6 +106,7 @@ ngx.HTTP_VERSION_NOT_SUPPORTED = 505 ngx.HTTP_INSUFFICIENT_STORAGE = 507 ---@alias ngx.http.status_code +---| integer ---| `ngx.HTTP_CONTINUE` ---| `ngx.HTTP_SWITCHING_PROTOCOLS` ---| `ngx.HTTP_OK` diff --git a/meta/3rd/busted/config.lua b/meta/3rd/busted/config.lua index 9a0b09f3..b8254783 100644 --- a/meta/3rd/busted/config.lua +++ b/meta/3rd/busted/config.lua @@ -1,8 +1,3 @@ -files = { - ".*_spec%.lua", - ".*_test%.lua", -} - configs = { { key = "Lua.workspace.library", diff --git a/meta/3rd/love2d/library/love/graphics.lua b/meta/3rd/love2d/library/love/graphics.lua index d6adf2e4..335f94f8 100644 --- a/meta/3rd/love2d/library/love/graphics.lua +++ b/meta/3rd/love2d/library/love/graphics.lua @@ -566,13 +566,13 @@ function love.graphics.newFont(filename) end --- ---Creates a new Image from a filepath, FileData, an ImageData, or a CompressedImageData, and optionally generates or specifies mipmaps for the image. --- ----@overload fun(fileData: love.FileData, flags?: table):love.Image ----@overload fun(imageData: love.ImageData, flags?: table):love.Image ----@overload fun(compressedImageData: love.CompressedImageData, flags?: table):love.Image +---@overload fun(fileData: love.FileData, settings?: table):love.Image +---@overload fun(imageData: love.ImageData, settings?: table):love.Image +---@overload fun(compressedImageData: love.CompressedImageData, settings?: table):love.Image ---@param filename string # The filepath to the image file. ----@param flags? {dpiscale: number, linear: boolean, mipmaps: boolean} # A table containing the following fields: +---@param settings? {dpiscale: number, linear: boolean, mipmaps: boolean} # A table containing the following fields: ---@return love.Image image # A new Image object which can be drawn on screen. -function love.graphics.newImage(filename, flags) end +function love.graphics.newImage(filename, settings) end --- ---Creates a new specifically formatted image. @@ -840,8 +840,7 @@ function love.graphics.scale(sx, sy) end --- ---Sets the background color. --- ----@overload fun() ----@overload fun() +---@overload fun(rgba: table) ---@param red number # The red component (0-1). ---@param green number # The green component (0-1). ---@param blue number # The blue component (0-1). @@ -1694,18 +1693,19 @@ function ParticleSystem:setBufferSize(size) end --- ---In versions prior to 11.0, color component values were within the range of 0 to 255 instead of 0 to 1. --- +---@overload fun(self: love.ParticleSystem, rgba1: table, rgba2: table, rgba8: table) ---@param r1 number # First color, red component (0-1). ---@param g1 number # First color, green component (0-1). ---@param b1 number # First color, blue component (0-1). ----@param a1 number # First color, alpha component (0-1). ----@param r2 number # Second color, red component (0-1). ----@param g2 number # Second color, green component (0-1). ----@param b2 number # Second color, blue component (0-1). ----@param a2 number # Second color, alpha component (0-1). ----@param r8 number # Eighth color, red component (0-1). ----@param g8 number # Eighth color, green component (0-1). ----@param b8 number # Eighth color, blue component (0-1). ----@param a8 number # Eighth color, alpha component (0-1). +---@param a1? number # First color, alpha component (0-1). +---@param r2? number # Second color, red component (0-1). +---@param g2? number # Second color, green component (0-1). +---@param b2? number # Second color, blue component (0-1). +---@param a2? number # Second color, alpha component (0-1). +---@param r8? number # Eighth color, red component (0-1). +---@param g8? number # Eighth color, green component (0-1). +---@param b8? number # Eighth color, blue component (0-1). +---@param a8? number # Eighth color, alpha component (0-1). function ParticleSystem:setColors(r1, g1, b1, a1, r2, g2, b2, a2, r8, g8, b8, a8) end --- @@ -1823,8 +1823,8 @@ function ParticleSystem:setSizeVariation(variation) end ---At least one size must be specified. A maximum of eight may be used. --- ---@param size1 number # The first size. ----@param size2 number # The second size. ----@param size8 number # The eighth size. +---@param size2? number # The second size. +---@param size8? number # The eighth size. function ParticleSystem:setSizes(size1, size2, size8) end --- diff --git a/meta/3rd/love2d/library/love/physics.lua b/meta/3rd/love2d/library/love/physics.lua index 93cb67e4..9ee6a44f 100644 --- a/meta/3rd/love2d/library/love/physics.lua +++ b/meta/3rd/love2d/library/love/physics.lua @@ -2278,8 +2278,8 @@ function World:rayCast(fixture, x, y, xn, yn, fraction) end --- ---@param beginContact function # Gets called when two fixtures begin to overlap. ---@param endContact function # Gets called when two fixtures cease to overlap. This will also be called outside of a world update, when colliding objects are destroyed. ----@param preSolve function # Gets called before a collision gets resolved. ----@param postSolve function # Gets called after the collision has been resolved. +---@param preSolve? function # Gets called before a collision gets resolved. +---@param postSolve? function # Gets called after the collision has been resolved. function World:setCallbacks(beginContact, endContact, preSolve, postSolve) end --- diff --git a/meta/3rd/lovr/library/lovr/filesystem.lua b/meta/3rd/lovr/library/lovr/filesystem.lua index 4f8214db..cbdb25aa 100644 --- a/meta/3rd/lovr/library/lovr/filesystem.lua +++ b/meta/3rd/lovr/library/lovr/filesystem.lua @@ -17,12 +17,22 @@ --- <tr> --- <td>macOS</td> --- <td><code>/Users/<user>/Library/Application Support/LOVR/<identity></code></td> +--- </tr> +--- <tr> +--- <td>Linux</td> +--- <td><code>/home/<user>/.local/share/LOVR/<identity></code></td> +--- </tr> +--- <tr> +--- <td>Android</td> +--- <td><code>/sdcard/Android/data/<identity>/files</code></td> --- </tr> </table> --- ---`<identity>` should be a unique identifier for your app. --- ---It can be set either in `lovr.conf` or by using `lovr.filesystem.setIdentity`. --- +---On Android, the identity can not be changed and will always be the package id, like `org.lovr.app`. +--- ---All filenames are relative to either the save directory or the directory containing the project source. --- ---Files in the save directory take precedence over files in the project. @@ -134,7 +144,7 @@ function lovr.filesystem.getRequirePath() end ---### NOTE: ---The save directory takes the following form: --- ----``` <appdata>/LOVR/<identity> ``` +--- <appdata>/LOVR/<identity> --- ---Where `<appdata>` is `lovr.filesystem.getAppdataDirectory` and `<identity>` is `lovr.filesystem.getIdentity` and can be customized using `lovr.conf`. --- @@ -279,14 +289,6 @@ function lovr.filesystem.setIdentity(identity) end function lovr.filesystem.setRequirePath(path) end --- ----Sets the location of the project's source. ---- ----This can only be done once, and is usually done internally. ---- ----@param identity string # The path containing the project's source. -function lovr.filesystem.setSource(identity) end - ---- ---Unmounts a directory or archive previously mounted with `lovr.filesystem.mount`. --- --- diff --git a/meta/3rd/lovr/library/lovr/graphics.lua b/meta/3rd/lovr/library/lovr/graphics.lua index 2ebe5dec..f6ed83a8 100644 --- a/meta/3rd/lovr/library/lovr/graphics.lua +++ b/meta/3rd/lovr/library/lovr/graphics.lua @@ -462,7 +462,6 @@ function lovr.graphics.newMaterial(properties) end --- ---- glTF: Morph targets are not supported. ---- glTF: Only the default scene is loaded. ----- glTF: Only the default scene is loaded. ---- glTF: Currently, each skin in a Model can have up to 256 joints. ---- glTF: Meshes can't appear multiple times in the node hierarchy with different skins, they need --- to use 1 skin consistently. @@ -1797,7 +1796,7 @@ function Pass:line(x1, y1, z1, x2, y2, z2, ...) end ---@param start? number # The 1-based index of the first vertex to render from the vertex buffer (or the first index, when using an index buffer). ---@param count? number # The number of vertices to render (or the number of indices, when using an index buffer). When `nil`, as many vertices or indices as possible will be drawn (based on the length of the Buffers and `start`). ---@param instances? number # The number of copies of the mesh to render. ----@param base? number # nil +---@param base? number # A base offset to apply to vertex indices. function Pass:mesh(vertices, transform, start, count, instances, base) end --- @@ -2814,7 +2813,7 @@ function Texture:newView(parent, type, layer, layerCount, mipmap, mipmapCount) e --- ---Example: --- ----``` layout(std140) uniform ObjectScales { float scales[64]; }; ``` +--- layout(std140) uniform ObjectScales { float scales[64]; }; --- ---The `std430` layout corresponds to the std430 layout used for storage buffers in GLSL. --- @@ -2822,7 +2821,7 @@ function Texture:newView(parent, type, layer, layerCount, mipmap, mipmapCount) e --- ---Example: --- ----``` layout(std430) buffer TileSizes { vec2 sizes[]; } ``` +--- layout(std430) buffer TileSizes { vec2 sizes[]; } --- ---@alias lovr.BufferLayout --- diff --git a/meta/3rd/lovr/library/lovr/physics.lua b/meta/3rd/lovr/library/lovr/physics.lua index 5ec53ce6..661b49cd 100644 --- a/meta/3rd/lovr/library/lovr/physics.lua +++ b/meta/3rd/lovr/library/lovr/physics.lua @@ -1411,8 +1411,8 @@ function World:getResponseTime() end --- ---The default step count is 20. --- ----@param steps number # The step count. -function World:getStepCount(steps) end +---@return number steps # The step count. +function World:getStepCount() end --- ---Returns the tightness of joints in the World. @@ -1536,6 +1536,21 @@ function World:newMeshCollider(vertices, indices) end function World:newSphereCollider(x, y, z, radius) end --- +---Adds a new Collider to the World with a TerrainShape already attached. +--- +--- +---### NOTE: +---The collider will be positioned at 0, 0, 0. +--- +---Unlike other colliders, it will automatically be set as kinematic when created. +--- +---@overload fun(self: lovr.World, scale: number, heightmap: lovr.Image, stretch?: number):lovr.Collider +---@overload fun(self: lovr.World, scale: number, callback: function, samples?: number):lovr.Collider +---@param scale number # The width and depth of the terrain, in meters. +---@return lovr.Collider collider # The new Collider. +function World:newTerrainCollider(scale) end + +--- ---Returns an iterator that can be used to iterate over "overlaps", or potential collisions between pairs of shapes in the World. --- ---This should be called after using `World:computeOverlaps` to compute the list of overlaps. Usually this is called automatically by `World:update`. diff --git a/meta/3rd/luaecs/config.lua b/meta/3rd/luaecs/config.lua new file mode 100644 index 00000000..0f79fabf --- /dev/null +++ b/meta/3rd/luaecs/config.lua @@ -0,0 +1,2 @@ +name = "luaecs" +words = { "ecs%.world()" } diff --git a/meta/3rd/luaecs/library/ecs.lua b/meta/3rd/luaecs/library/ecs.lua new file mode 100644 index 00000000..56b421ca --- /dev/null +++ b/meta/3rd/luaecs/library/ecs.lua @@ -0,0 +1,380 @@ +---@meta + +---Library of https://github.com/cloudwu/luaecs + +---We use a component id and a index in a component pooid, then we can +---get this component's entity id ,then get all other components. +---@class ITER +---@field index integer index of the component pool +---@field cid integer component type id +---@field iter ENTITY_GROUPITER #userdata + +---Return depend the pattern, every pattern will be return a table. +---This is a C function, and it will be used as the __call metamethod of the +---ECSWorld#_groupiter 's return usedata's metatable. +---If the pattern of select is a component name but not a condition,then return +---is the component pool index and component id. +---@alias ENTITY_GROUPITER fun():ITER + +---Every entity must defined which component it contains on new. +---@class ECSWorld +local meta = {} + +---Register a component, use Lua table to describe data struct. +---The table is a name field and data field list, and can has a type field, field will be 'filed_name:type'. +---Then, will caulate the size of component type's data. +---Support type is: int, float, bool, int64, dword, word, byte, double, userdata +---* if type is `lua`, the size is ecs._LUAOBJECT, -1; +---* if type is `raw`, we must set the type's size explict; +---* or the size may bigger than 0, which caculated from the data field list. +---* or if the size is 0, it is a one value component, if it has type field, then the size is the type size; +---* or if the size litter then 0, it is a tag. +---``` +---In C, this is init a component pool, every component pool's data will in a continus memory. +--- {name = 'vector', 'x:float','y:float'} -- normal component +--- {name = 'object',type='lua'}} -- lua component +--- {name = 'hp', type='int'} -- one value component +--- {name = 'mark'}, -- tag, default it boolean +----{name = 'rawobj', type='raw', size= '20'} -- raw object +--- {name = 'byname', order = true} -- order tag +--- Then the c api _newtype will malloc a continus memory of the types' size. +---@param typeclass table +---@see ECSWorld#_newtype +function meta:register(typeclass) +end + +---Construct a new entity, use Lua table to describe it. +---The key is the component type, must register it before, +---so, every kv pair is a component. +---Every component pool will get the new entity id. +---@param obj? table #{name = "hello", position= {x = 1, y = 2}} +---@return integer #eid +function meta:new(obj) +end + +---Return the info of a list of component names. +---May be, for test use? +---@param t string[] component name list +---@return userdata #ctx info +---@see ECSWorld#_context +function meta:context(t) +end + +---Select a patterns of entitys, the mainkey( first key) can't not be has absent condtion. +---The pattern is a space-separated combination of `componentname[:?]action`, and the `action` can be +---* in : read the component +---* out : write the component +---* update : read / write +---* absent : check if the component is not exist +---* exist (default) : check if the component is exist +---* new : create the component +---* ? means it's an optional action if the component is not exist +---NOTICE: If you use action `new` , you must guarantee the component is clear (None entity has this component) before iteration. +---If opt and inout is absent, the return is the id info of the entitys.{ {pooid, cid}} +---**Return value will only has components in he pattern** +---**Return value will like {component_index, component_id,ENTITY_GROUPITER,component1, component2} +---@param pat string #key [{opt inout}] , opt is : or ?, inout is in, out, update, exist(default), absent, new.like t:in, b:out, id?update +---@return ENTITY_GROUPITER #iter function +---@see ECSWorld#_groupiter +function meta:select(pat) +end + +---Sync all then component of the entity represent by a iter to LUA +---@param iter number|ITER #ITER or entity id +---@return table +---@see ECSWorld#_read +---@see ECSWorld#access +---@see ECSWorld#fetch +function meta:readall(iter) +end + +---Clear a component type of name `name` +---@param name string component name +---@see ECSWorld#_clear +function meta:clear(name) +end + +---Clear all component types. +---@see ECSWorld#clear +function meta:clearall() +end + +---Dump all indexes of a component of name `name` +---@param name string +---@return integer[] +---@see ECSWorld#_dumpid +function meta:dumpid(name) +end + +---Update world, will free removed(default, or with tag `tagname`) entity. +---@param tagname? string #tagname, default is REMOVED, but we also can use other tag to delete entities. +---@see ECSWorld#_update +function meta:update(tagname) +end + +local M = { + _MAXTYPE = 255, + _METHODS = meta, + _TYPE_INT = 0, + _TYPE_FLOAT = 1, + _TYPE_BOOL = 2, + _TYPE_INT64 = 3, + _TYPE_DWORD = 4, + _TYPE_WORD = 5, + _TYPE_BYTE = 6, + _TYPE_DOUBLE = 7, + _TYPE_USERDATA = 8, + _TYPE_COUNT = 9, + _LUAOBJECT = -1, + _REMOVED = 0, + _ORDERKEY = -2, + NULL = 0x0, -- userdata +} + +---Lua function +---Construct a new LuaECS World +---@return ECSWorld +function M.world() +end + +---Like new(obj), but use a specifie entity +---@param eid integer #entity id +---@param obj table #describe all component of the type +function meta:import(eid, obj) +end + +-- Create a template first +---local t = w:template { +--- name = "foobar" +---} +-- instance the template into an entity, and add visible tag. +--- The additional components ( { visible = true } ) is optional. +--- local eid = w:template_instance(w:new(), t, { visible = true }) +---Use a templat to Construct an entity. +---@param eid integer #entity id +---@param temp string #template name +---@param obj table +function meta:template_instance(eid, temp, obj) +end + +---Get an entity's one component, can can write the value. +---@param eid integer +---@param pat string #only one key +---@param value? any # when with this values, is write. +---@return any|nil # pattern key is tag, return boolean; lua type, return lua data; else table; if write, return nil. +---@see ECSWorld#readall +---@see ECSWorld#fetch +function meta:access(eid, pat, value) +end + +---Count the pattern 's object number +---@param pat string +---@return integer +function meta:count(pat) +end + +---Extend an iter with pattern. +---@param iter ITER +---@param expat string +---@see ECSWorld#_read +function meta:extend(iter, expat) end + +---Get component id by name +---@param name string +---@return integer #component id +function meta:component_id(name) end + +---Persist Use +function meta:read_component(reader, name, offset, stride, n) end + +---Get the first entity of pattern `pattern` +---We can use this as a signletone component. +---@param pattern string +---@return ITER +function meta:first(pattern) end + +---Check pattern `pattern` whether has entitys. +---Work same as ECSWorld#first but return boolean. +---@param pattern string +---@return boolean +function meta:check(pattern) end + +---Register a template. +---@param obj table #component and value pairs +function meta:template(obj) end + +---You can tags entities in groups with `w:group_enable(tagname, groupid1, groupid2,...)` +---Enable tag `tagname` on multi groups +---@param tagname string tagname +---@param ... number #group id s +---@see ECSWorld#_group_enable +function meta:group_enable(tagname, ...) end + +---Get a component's type. +---@param name string +---@return string # tag | lua | c | M._TYPE* +function meta:type(name) end + +---This will reset `tagname`'s component pool. +---Set tag on entitys in pattern `pat` +---@param tagname string +---@param pat string +function meta:filter(tagname, pat) end + +---Fetch entity's component with pattern `pat` +---You can use out, update and then w:sumit() to modify entity. +---@param eid integer +---@param pat? string +---@see ECSWorld#readall +---@see ECSWorld#access +---@return table # entity with pat specified component +function meta:fetch(eid, pat) end + +----------- C API ------------- +---C API +---Get the world size +---@return integer, integer #capaticy size, used size +function meta:memory() end + +---C API +---shrink_component_pool +function meta:collect() end + +---C API +---New component type. +---@param cid integer component id, cacul from the Lua +---@param size integer # size +---@see ECSWorld#register +function meta:_newtype(cid, size) +end + +--- C API +---Return a new entity +---@return integer entity id +function meta:_newentity() +end + +--- C API +---Check the entity is exist +---@param eid integer +---@return integer #entity's index in the world, start at 0 +---@see ECSWorld#exist +function meta:_indexentity(eid) end + +--- C API +---Add entity of id `eid` to the component pool of id `cid`, return the pool index. +---@param eid integer entity id +---@param cid integer component id, +---@return integer #pool index id +function meta:_addcomponent(eid, cid) +end + +--- C API +---Update world. +---Remove all entity which removed(default) or with component id `cid`, and will rearrange the world. +---@param cid? integer #tagid +---@see ECSWorld#update +function meta:_update(cid) +end + +--- C API +---Clear component of id `cid` +---@param cid integer component id +---@see ECSWorld#clear +function meta:_clear(cid) +end + +--- C API +---Return the info of a list of component ids. +---@param t integer[] +---@return userdata #ctx info +---@see ECSWorld#context +function meta:_context(t) +end + +--- C API +---Return an iter function for a list of pattren. +---@param pat_desc table[] #{ {name, id, type, [opt, r, w, exist, absent, new] } +---@return ENTITY_GROUPITER #iter C function +function meta:_groupiter(pat_desc) +end + +--- C API +function meta:_mergeiter(...) end + +--- C API +---Get a iter of entity eid. +---@param eid integer +---@return ITER # the cid will by -1 +function meta:_fetch(eid) end + +--- C API +---Entity exists? +---@param eid integer +function meta:exist(eid) end + +--- C API +--- Remove an entity with eid +--- The removed entity will has a tag REMOVED +---@param eid number +function meta:remove(eid) +end + +---C API +---@param ref ENTITY_GROUPITER #the iter of component +---@param cv any #the inited component +---@param index integer #the index of the component pool +function meta:_object(ref, cv, index) +end + +---@param pattern string +---@param iter ITER +function meta:_read(pattern, iter) +end + +---C API +---Commit an mod of a group iter with out or new +---@param iter ITER +function meta:submit(iter) end + +---@see ECSWorld:#first +function meta:_first(...) end + +---Dump all id of a component of id `cid` +---@param cid integer +---@return integer[] +---@see ECSWorld#dumpid +function meta:_dumpid(cid) +end + +---@see ECSWorld:count +function meta:_count(...) end + +---@see ECSWorld:filter +function meta:_filter(...) end + +function meta:_access(...) end + +function meta:__gc(...) end + +---C API +--- Add entity (eid) into a group with groupid (32bit integer) +---**NOTE:We can add entity to a group, but we can not remove it from a group.** +---**NOTE:We can iterate a group, but we can not random visit a group member.** +---@param groupid number #32bit +---@param eid number +function meta:group_add(groupid, eid) end + +---C API. Add tag of group's entitys +---**NOTICE: this call will clear the the tag's component pool.** +---@param tagid number +---@param ... number #max number is 1024 +---@see ECSWorld#group_enable +function meta:_group_enable(tagid, ...) end + +---C api, get the eid list of a group +---@param groupid number +---@return table # eid list +function meta:group_get(groupid) end + +return M diff --git a/meta/3rd/luassert/config.lua b/meta/3rd/luassert/config.lua index a1a001da..f88cb12e 100644 --- a/meta/3rd/luassert/config.lua +++ b/meta/3rd/luassert/config.lua @@ -1 +1 @@ -words = { "assert%.%w+" } +words = { "require[%s%(\"\']+luassert[%)\"\']" } diff --git a/meta/3rd/skynet/config.lua b/meta/3rd/skynet/config.lua index ef137afe..79b0871b 100644 --- a/meta/3rd/skynet/config.lua +++ b/meta/3rd/skynet/config.lua @@ -1 +1,2 @@ +name = "skynet" words = { "skynet.start" } diff --git a/meta/3rd/skynet/library/skynet.lua b/meta/3rd/skynet/library/skynet.lua index 843722c4..f09d996c 100644 --- a/meta/3rd/skynet/library/skynet.lua +++ b/meta/3rd/skynet/library/skynet.lua @@ -13,34 +13,34 @@ ---|+'"trace"' ---@alias SERVICEADDR '".servicename"' | '":0000000C"' | integer ---@alias MESSAGEHANDLER fun(session:integer, source:integer, cmd:string, ...) -local skynet = { - -- read skynet.h - PTYPE_TEXT = 0, - PTYPE_RESPONSE = 1, - PTYPE_MULTICAST = 2, - PTYPE_CLIENT = 3, - PTYPE_SYSTEM = 4, - PTYPE_HARBOR = 5, - PTYPE_SOCKET = 6, - PTYPE_ERROR = 7, - PTYPE_QUEUE = 8, -- used in deprecated mqueue, use skynet.queue instead - PTYPE_DEBUG = 9, - PTYPE_LUA = 10, - PTYPE_SNAX = 11, - PTYPE_TRACE = 12, -- use for debug trace - PNAME_TEXT = "text", - PNAME_RESPONSE = "response", - PNAME_MULTICAST = "muliticast", - PNAME_CLIENT = "client", - PNAME_SYSTEM = "system", - PNAME_HARBOR = "harbor", - PNAME_SOCKET = "socket", - PNAME_ERROR = "error", - PNAME_QUEUE = "queue", - PNAME_DEBUG = "debug", - PNAME_LUA = "lua", - PNAME_SNAX = "snax", - PNAME_TRACE = "trace", +local skynet = { + -- read skynet.h + PTYPE_TEXT = 0, + PTYPE_RESPONSE = 1, + PTYPE_MULTICAST = 2, + PTYPE_CLIENT = 3, + PTYPE_SYSTEM = 4, + PTYPE_HARBOR = 5, + PTYPE_SOCKET = 6, + PTYPE_ERROR = 7, + PTYPE_QUEUE = 8, -- used in deprecated mqueue, use skynet.queue instead + PTYPE_DEBUG = 9, + PTYPE_LUA = 10, + PTYPE_SNAX = 11, + PTYPE_TRACE = 12, -- use for debug trace + PNAME_TEXT = "text", + PNAME_RESPONSE = "response", + PNAME_MULTICAST = "muliticast", + PNAME_CLIENT = "client", + PNAME_SYSTEM = "system", + PNAME_HARBOR = "harbor", + PNAME_SOCKET = "socket", + PNAME_ERROR = "error", + PNAME_QUEUE = "queue", + PNAME_DEBUG = "debug", + PNAME_LUA = "lua", + PNAME_SNAX = "snax", + PNAME_TRACE = "trace", } @@ -103,8 +103,8 @@ end ---* 你需要挂起一个请求,等将来时机满足,再回应它。而回应的时候已经在别的 coroutine 中了。 ---针对这种情况,你可以调用 skynet.response(skynet.pack) 获得一个闭包,以后调用这个闭包即可把回应消息发回。 ---这里的参数 skynet.pack 是可选的,你可以传入其它打包函数,默认即是 skynet.pack 。 ----@param msg lightuserdata ----@param sz integer +---@param msg lightuserdata|string +---@param sz? integer function skynet.ret(msg, sz) end @@ -205,7 +205,7 @@ end ---@param addr SERVICEADDR @目标服务地址 ---@param typename string @类型名 ---@param msg lightuserdata ----@param sz number +---@param sz? number function skynet.rawsend(addr, typename, msg, sz) end @@ -217,6 +217,7 @@ end ---@param addr SERVICEADDR @目标服务地址 ---@param typename string @类型名 ---@vararg any @传输的数据 +---@return ... function skynet.call(addr, typename, ...) end @@ -227,8 +228,8 @@ end ---* 挂起期间,状态可能会变更,造成重入 ---@param addr SERVICEADDR @目标服务地址 ---@param typename string @类型名 ----@param msg lightuserdata ----@param sz number +---@param msg lightuserdata|string +---@param sz? number function skynet.rawcall(addr, typename, msg, sz) end @@ -240,8 +241,10 @@ request.__call = request.add ---@param obj table # {addr, typename, ...} function request:add(obj) end + function request:close() end + function request:select(timeout) end @@ -249,6 +252,7 @@ end ---@return request function skynet.request(obj) end + ---* 返回一个唯一的会话ID ---@return number function skynet.genid() @@ -293,7 +297,7 @@ end --- 用于启动一个新的 Lua 服务。name 是脚本的名字(不用写 .lua 后缀)。只有被启动的脚本的 start 函数返回后,这个 API 才会返回启动的服务的地址,这是一个阻塞 API 。如果被启动的脚本在初始化环节抛出异常,或在初始化完成前就调用 skynet.exit 退出,skynet.newservice 都会抛出异常。如果被启动的脚本的 start 函数是一个永不结束的循环,那么 newservice 也会被永远阻塞住。 --- > 启动参数其实是以字符串拼接的方式传递过去的。所以不要在参数中传递复杂的 Lua 对象。接收到的参数都是字符串,且字符串中不可以有空格(否则会被分割成多个参数)。这种参数传递方式是历史遗留下来的,有很多潜在的问题。目前推荐的惯例是,让你的服务响应一个启动消息。在 newservice 之后,立刻调用 skynet.call 发送启动请求。 ---@param name string #脚本名字 ----@vararg string #可选参数 +---@vararg string|number #可选参数 function skynet.newservice(name, ...) end @@ -546,4 +550,5 @@ end function skynet.info_func(fun) end + return skynet diff --git a/meta/3rd/skynet/library/skynet/db/mongo.lua b/meta/3rd/skynet/library/skynet/db/mongo.lua index 66ab9351..ca24493c 100644 --- a/meta/3rd/skynet/library/skynet/db/mongo.lua +++ b/meta/3rd/skynet/library/skynet/db/mongo.lua @@ -204,7 +204,7 @@ end function mongo_cursor:limit(amount) end ---统计行数 ----@param with_limit_and_skip boolean +---@param with_limit_and_skip? boolean function mongo_cursor:count(with_limit_and_skip) end ---是否有下一行 diff --git a/meta/3rd/skynet/library/skynet/db/redis.lua b/meta/3rd/skynet/library/skynet/db/redis.lua index c335502a..0d807c25 100644 --- a/meta/3rd/skynet/library/skynet/db/redis.lua +++ b/meta/3rd/skynet/library/skynet/db/redis.lua @@ -1,5 +1,5 @@ ---@meta -local redis = {} +local redis = {} ---@class redisconfig ---@field host string @@ -19,31 +19,50 @@ local redis = {} local command = {} function command:disconnect() end + +---Is key exists +---@param k string +---@return boolean function command:exists(k) end + +---Does value is a member of set key. +---@param key string #key of a set +---@param value string #value function command:sismember(key, value) end + +---Pipline command +---If resp is a table and exits, return boolean, resp. +---Or return the last result. boolean, out +---@param ops string[] +---@param resp? table function command:pipeline(ops, resp) end --- watch mode, only can do SUBSCRIBE, PSUBSCRIBE, UNSUBSCRIBE, PUNSUBSCRIBE, PING and QUIT command. --- we can call watch:message in endless loop. ---@class watch -local watch = {} +local watch = {} function watch:disconnect() end + ---阻塞模式读取消息 function watch:message() end + ---subscribe channel function watch:subscribe(...) end + ---pattern subscribe channels function watch:psubscribe(...) end + ---unsubscribe function watch:unsubscribe(...) end + ---punsubscribe function watch:punsubscribe(...) end diff --git a/meta/3rd/skynet/library/skynet/socket.lua b/meta/3rd/skynet/library/skynet/socket.lua index 53284b13..9f26c72e 100644 --- a/meta/3rd/skynet/library/skynet/socket.lua +++ b/meta/3rd/skynet/library/skynet/socket.lua @@ -11,52 +11,62 @@ local socket = {} ---@return number @skynet对套接字描述符的表示 function socket.open(addr, port) end + ---* 绑定系统文件描述符 ---@param os_fd number ---@return number @skynet对套接字描述符的表示 function socket.bind(os_fd) end + ---* 等价于 socket.bind(0),绑定到标准输出 ---@return number @skynet对套接字描述符的表示 function socket.stdin() end + ---* accept 是一个函数。每当一个监听的 id 对应的 socket 上有连接接入的时候,都会调用 accept 函数。这个函数会得到接入连接的 id 以及 ip 地址。你可以做后续操作。 ---* 开始收发套接字数据,并设置一个回调 ---* 这个函数会将套接字索引与一个 Lua 的结构封装起来,并在协程内挂起 (skynet.wait) ---* 当有数据事件到达时,就会 skynet.wakeup 协程来 ---@param id number @skynet套接字索引 ----@param accept fun(...) @事件回调函数 +---@param accept? fun(...) @事件回调函数,监听字才需要这个 ---@return number | nil, error function socket.start(id, accept) end + ---* 暂停收发一个套接字上的数据 ---@param id number @skynet套接字索引 function socket.pause(id) end + ---* 强行关闭一个连接。和 close 不同的是,它不会等待可能存在的其它 coroutine 的读操作。 ---* 一般不建议使用这个 API ,但如果你需要在 __gc 元方法中关闭连接的话,shutdown 是一个比 close 更好的选择(因为在 gc 过程中无法切换 coroutine) ---@param id number @skynet套接字索引 function socket.shutdown(id) end + ---* 在极其罕见的情况下,需要粗暴的直接关闭某个连接,而避免 socket.close 的阻塞等待流程,可以使用它。 ---@param id number @skynet套接字索引 function socket.close_fd(id) end + ---* 关闭一个连接,这个 API 有可能阻塞住执行流。因为如果有其它 coroutine 正在阻塞读这个 id 对应的连接,会先驱使读操作结束,close 操作才返回。 ---@param id number @skynet套接字索引 function socket.close(id) end + ---从一个 socket 上读 sz 指定的字节数。如果读到了指定长度的字符串,它把这个字符串返回。如果连接断开导致字节数不够,将返回一个 false 加上读到的字符串。如果 sz 为 nil ,则返回尽可能多的字节数,但至少读一个字节(若无新数据,会阻塞)。 ---@param id number @skynet套接字索引 ---@param sz number | nil @要读取的字节数,nil 尽可能多的读 ---@return string | nil, string function socket.read(id, sz) end + ---* 从一个 socket 上读所有的数据,直到 socket 主动断开,或在其它 coroutine 用 socket.close 关闭它。 ---@param id number @skynet套接字索引 ---@return buffer | nil, buffer function socket.readall(id) end + ---* 从一个 socket 上读一行数据。sep 指行分割符。默认的 sep 为 "\n"。读到的字符串是不包含这个分割符的。 ---@param id number @skynet套接字索引 ---@return buffer | nil, buffer @@ -67,11 +77,13 @@ end ---@param id number @skynet套接字索引 function socket.block(id) end + ---* 是否合法套接字 ---@param id number @skynet套接字索引 ---@return boolean function socket.invalid(id) end + ---* 是否已断开 ---@param id number @skynet套接字索引 ---@return boolean @@ -80,40 +92,49 @@ end ---* 监听一个端口,返回一个 id ,供 start 使用。 ---@param host string @地址,可以是 ip:port ----@param port number @断开,可为 nil,此时从 host 内获取端口信息 ----@param backlog number @队列长度 +---@param port? number @端口,可为 nil,此时从 host 内获取端口信息 +---@param backlog? number @队列长度 ---@return number @skynet套接字索引 function socket.listen(host, port, backlog) end + ---* 清除 socket id 在本服务内的数据结构,但并不关闭这个 socket 。这可以用于你把 id 发送给其它服务,以转交 socket 的控制权。 function socket.abandon(id) end + ---* 设置缓冲区大小 ---@param id number @skynet套接字索引 ---@param limit number @缓冲区大小 function socket.limit(id, limit) end + function socket.udp(callback, host, port) end + function socket.udp_connect(id, addr, port, callback) end + function socket.warning(id, callback) end + function socket.onclose(id, callback) end + ---* 把一个字符串置入正常的写队列,skynet 框架会在 socket 可写时发送它。 ---* 这和 socketdriver.send 是一个 ---@see socketdriver#send ---@param id number @skynet套接字索引 ---@param msg string @数据 ----@param sz number @大小 +---@param sz? number @大小,如果是字符串则不需要 function socket.write(id, msg, sz) end + ---* 把字符串写入低优先级队列。如果正常的写队列还有写操作未完成时,低优先级队列上的数据永远不会被发出。只有在正常写队列为空时,才会处理低优先级队列。但是,每次写的字符串都可以看成原子操作。不会只发送一半,然后转去发送正常写队列的数据。 ---@param id number @skynet套接字索引 ---@param msg string @数据 function socket.lwrite() end + function socket.header() end diff --git a/meta/template/basic.lua b/meta/template/basic.lua index 262075c7..9b6210e1 100644 --- a/meta/template/basic.lua +++ b/meta/template/basic.lua @@ -56,7 +56,7 @@ _G = {} ---@version 5.1 ---#DES 'getfenv' ----@param f? integer|async fun() +---@param f? integer|async fun(...):... ---@return table ---@nodiscard function getfenv(f) end @@ -158,7 +158,7 @@ function pairs(t) end ---#if VERSION == 5.1 and not JIT then ---@param f function ---#else ----@param f async fun() +---@param f async fun(...):... ---#end ---@param arg1? any ---@return boolean success @@ -204,7 +204,7 @@ function select(index, ...) end ---@version 5.1 ---#DES 'setfenv' ----@param f async fun()|integer +---@param f async fun(...):...|integer ---@param table table ---@return function function setfenv(f, table) end @@ -273,7 +273,7 @@ function warn(message, ...) end function xpcall(f, err) end ---#else ---#DES 'xpcall>5.2' ----@param f async fun() +---@param f async fun(...):... ---@param msgh function ---@param arg1? any ---@return boolean success diff --git a/meta/template/coroutine.lua b/meta/template/coroutine.lua index 6ff5d6de..e807f357 100644 --- a/meta/template/coroutine.lua +++ b/meta/template/coroutine.lua @@ -5,7 +5,7 @@ coroutine = {} ---#DES 'coroutine.create' ----@param f async fun() +---@param f async fun(...):... ---@return thread ---@nodiscard function coroutine.create(f) end @@ -54,7 +54,7 @@ function coroutine.running() end function coroutine.status(co) end ---#DES 'coroutine.wrap' ----@param f async fun() +---@param f async fun(...):... ---@return fun(...):... ---@nodiscard function coroutine.wrap(f) end diff --git a/meta/template/debug.lua b/meta/template/debug.lua index 7cb417b2..48ba52d9 100644 --- a/meta/template/debug.lua +++ b/meta/template/debug.lua @@ -63,7 +63,7 @@ function debug.gethook(co) end ---#DES 'debug.getinfo' ---@overload fun(f: integer|function, what?: infowhat):debuginfo ---@param thread thread ----@param f integer|async fun() +---@param f integer|async fun(...):... ---@param what? infowhat ---@return debuginfo ---@nodiscard @@ -81,9 +81,9 @@ function debug.getinfo(thread, f, what) end function debug.getlocal(thread, level, index) end ---#else ---#DES 'debug.getlocal>5.2' ----@overload fun(f: integer|async fun(), index: integer):string, any +---@overload fun(f: integer|async fun(...):..., index: integer):string, any ---@param thread thread ----@param f integer|async fun() +---@param f integer|async fun(...):... ---@param index integer ---@return string name ---@return any value @@ -103,7 +103,7 @@ function debug.getmetatable(object) end function debug.getregistry() end ---#DES 'debug.getupvalue' ----@param f async fun() +---@param f async fun(...):... ---@param up integer ---@return string name ---@return any value @@ -146,11 +146,11 @@ function debug.setfenv(object, env) end ---|+'"l"' # ---#DESTAIL 'hookmask.l' ---#DES 'debug.sethook' ----@overload fun(hook: async fun(), mask: hookmask, count?: integer) ----@overload fun(thread: thread) ----@overload fun() +---@overload fun(hook: (async fun(...):...), mask: hookmask, count?: integer) +---@overload fun(thread: thread):... +---@overload fun(...):... ---@param thread thread ----@param hook async fun() +---@param hook async fun(...):... ---@param mask hookmask ---@param count? integer function debug.sethook(thread, hook, mask, count) end @@ -172,7 +172,7 @@ function debug.setlocal(thread, level, index, value) end function debug.setmetatable(value, meta) end ---#DES 'debug.setupvalue' ----@param f async fun() +---@param f async fun(...):... ---@param up integer ---@param value any ---@return string name @@ -204,7 +204,7 @@ function debug.traceback(thread, message, level) end ---@version >5.2, JIT ---#DES 'debug.upvalueid' ----@param f async fun() +---@param f async fun(...):... ---@param n integer ---@return lightuserdata id ---@nodiscard @@ -212,9 +212,9 @@ function debug.upvalueid(f, n) end ---@version >5.2, JIT ---#DES 'debug.upvaluejoin' ----@param f1 async fun() +---@param f1 async fun(...):... ---@param n1 integer ----@param f2 async fun() +---@param f2 async fun(...):... ---@param n2 integer function debug.upvaluejoin(f1, n1, f2, n2) end diff --git a/meta/template/ffi.lua b/meta/template/ffi.lua index 0d726c1e..2ca83dd5 100644 --- a/meta/template/ffi.lua +++ b/meta/template/ffi.lua @@ -2,13 +2,17 @@ ---@meta ---@class ffi.namespace*: table +---@field [string] function ----@class ffi.cdecl*: string ---@class ffi.ctype*: userdata +---@overload fun(init?: any, ...): ffi.cdata* +---@overload fun(nelem?: integer, init?: any, ...): ffi.cdata* local ctype + +---@class ffi.cdecl*: string ---@class ffi.cdata*: userdata ----@alias ffi.ct* ffi.cdecl*|ffi.ctype*|ffi.cdata* ----@class ffi.cb*: userdata +---@alias ffi.ct* ffi.ctype*|ffi.cdecl*|ffi.cdata* +---@class ffi.cb*: ffi.cdata* local cb ---@class ffi.VLA*: userdata ---@class ffi.VLS*: userdata @@ -20,8 +24,9 @@ local cb ---@field arch string local ffi = {} ----@param def string -function ffi.cdef(def) end +---@param def string +---@param params? any +function ffi.cdef(def, params, ...) end ---@param name string ---@param global? boolean @@ -29,6 +34,7 @@ function ffi.cdef(def) end ---@nodiscard function ffi.load(name, global) end +---@overload fun(ct: ffi.ct*, init: any, ...) ---@param ct ffi.ct* ---@param nelem? integer ---@param init? any @@ -36,19 +42,16 @@ function ffi.load(name, global) end ---@nodiscard function ffi.new(ct, nelem, init, ...) end ----@param nelem? integer ----@param init? any ----@return ffi.cdata* cdata -function ffi.ctype(nelem, init, ...) end - ----@param ct ffi.ct* +---@param ct ffi.ct* +---@param params? any ---@return ffi.ctype* ctype ---@nodiscard -function ffi.typeof(ct) end +function ffi.typeof(ct, params, ...) end ---@param ct ffi.ct* ---@param init any ---@return ffi.cdata* cdata +---@nodiscard function ffi.cast(ct, init) end ---@param ct ffi.ct* diff --git a/meta/template/jit.lua b/meta/template/jit.lua index c88377ed..d1684a04 100644 --- a/meta/template/jit.lua +++ b/meta/template/jit.lua @@ -9,17 +9,17 @@ ---@field arch string jit = {} ----@overload fun() +---@overload fun(...):... ---@param func function|boolean ---@param recursive? boolean function jit.on(func, recursive) end ----@overload fun() +---@overload fun(...):... ---@param func function|boolean ---@param recursive? boolean function jit.off(func, recursive) end ----@overload fun() +---@overload fun(...):... ---@overload fun(tr: number) ---@param func function|boolean ---@param recursive? boolean diff --git a/meta/template/string.lua b/meta/template/string.lua index e8016f76..c68e1117 100644 --- a/meta/template/string.lua +++ b/meta/template/string.lua @@ -20,7 +20,7 @@ function string.byte(s, i, j) end function string.char(byte, ...) end ---#DES 'string.dump' ----@param f async fun() +---@param f async fun(...):... ---@param strip? boolean ---@return string ---@nodiscard |