diff --git a/classes/MetaDataRef.lua b/classes/MetaDataRef.lua index c3046a4..c637d3f 100644 --- a/classes/MetaDataRef.lua +++ b/classes/MetaDataRef.lua @@ -1,50 +1,73 @@ ---- @meta +---@meta - ---- Base class used by [`StorageRef`], [`NodeMetaRef`], [`ItemStackMetaRef`], ---- and [`PlayerMetaRef`]. +---Base class used by [`StorageRef`], [`NodeMetaRef`], [`ItemStackMetaRef`], +---and [`PlayerMetaRef`]. --- ---- Note: If a metadata value is in the format `${k}`, an attempt to get the value ---- will return the value associated with key `k`. There is a low recursion limit. ---- This behavior is **deprecated** and will be removed in a future version. Usage ---- of the `${k}` syntax in formspecs is not deprecated. +---Note: If a metadata value is in the format `${k}`, an attempt to get the value +---will return the value associated with key `k`. There is a low recursion limit. +---This behavior is **deprecated** and will be removed in a future version. Usage +---of the `${k}` syntax in formspecs is not deprecated. --- ---- @class MetaDataRef +---@class MetaDataRef MetaDataRef = {} ----@param key string ----@return boolean|nil +---Returns `true` if `key` present, otherwise `false`. +--- +---Returns `nil` when the MetaData is inexistent. +---@param key string +---@return boolean? function MetaDataRef:contains(key) end ----@param key string ----@return string|nil +---Returns the value stored at `key` as a string if present. +--- +---Returns nil otherwise. +---@param key string +---@return string? function MetaDataRef:get(key) end ----@param key string ----@param value string value "" will delete the key ----@return string +---Set the string `value` at `key`. +--- +---Value of `""` will delete the key. +---@param key string +---@param value string function MetaDataRef:set_string(key, value) end ----@param key string ----@return string +---Returns a string value at `key` or `""` if not present. +---@param key string +---@return string function MetaDataRef:get_string(key) end ----@param key string ----@param value number ----@return number +---Set an integer number `value` to `key`. +--- +---Range: [s32]. +--- +---Some systems internally have a larger value range +---but but you should not rely on this behavior to ensure portability of your code. +--- +---The value will be converted into a string when stored. +---@param key string +---@param value integer function MetaDataRef:set_int(key, value) end ----@param key string ----@return number Returns `0` if `key` not present. +---Returns the value stored at `key` as an integer. +--- +---Returns `0` if key not present. +---@param key string +---@return integer function MetaDataRef:get_int(key) end ----@param key string ----@param value number ----@return number +---Store a number (a 64-bit floating-point number) exactly. +--- +---The value will be converted into a string when stored. +---@param key string +---@param value number function MetaDataRef:set_float(key, value) end ----@param key string ----@return number +---Returns a 64-bit floating-point number stored at `key`. +--- +---Returns `0` if key not present. +---@param key string +---@return number function MetaDataRef:get_float(key) end --- Returns a list of all keys in the metadata. diff --git a/classes/VoxelManip.lua b/classes/VoxelManip.lua index 5c7e3c4..f3ea9b9 100644 --- a/classes/VoxelManip.lua +++ b/classes/VoxelManip.lua @@ -94,9 +94,9 @@ function VoxelManip:set_param2_data(param2_data) end --- @overload fun(p1:MapPosition, p2:MapPosition) --- @overload fun(propagate_shadow:boolean) --- @overload fun() ---- @param p1 MapPosition ---- @param p2 MapPosition ---- @param propagate_shadow boolean +--- @param p1 MapPosition? +--- @param p2 MapPosition? +--- @param propagate_shadow boolean? function VoxelManip:calc_lighting(p1, p2, propagate_shadow) end --- Update liquid flow diff --git a/core_namespace.lua b/core_namespace.lua index 313f189..de57147 100644 --- a/core_namespace.lua +++ b/core_namespace.lua @@ -279,7 +279,7 @@ function core.get_translator(text_domain) end --- not have localization enabled. However, if we have for instance a translation --- file named `wool.fr.tr` containing the following: --- ---- @1 Wool=Laine @1 +--- \@1 Wool=Laine @1 --- Red=Rouge --- --- this will be displayed as "Laine Rouge" on clients with a French locale. @@ -578,7 +578,7 @@ function core.register_allow_player_inventory_action(callback) end --- * Does not accept or handle any return value. --- --- [View in lua_api.txt](https://github.com/minetest/minetest/blob/5.4.1/doc/lua_api.txt#L4732-L4735) ---- @param callback fun(player:ObjectRef|Player, action:"move"|"put"|"take", inventory:InvRef, inventory_info:table):integer? +--- @param callback fun(player:Player, action:"move"|"put"|"take", inventory:InvRef, inventory_info:table):integer? function core.register_on_player_inventory_action(callback) end --- * Called by `builtin` and mods when a player violates protection at a --- position (eg, digs a node or punches a protected entity). @@ -2105,7 +2105,7 @@ function core.write_json(data, styled) end --- * Example: `serialize({foo='bar'})`, returns `'return { ["foo"] = "bar" }'` --- --- [View in lua_api.txt](https://github.com/minetest/minetest/blob/5.4.1/doc/lua_api.txt#L5686-L5689) ---- @param table +--- @param table table --- @return string function core.serialize(table) end --- Returns a table diff --git a/definitions/NodeDefinition.lua b/definitions/NodeDefinition.lua index 9a6079a..ce23858 100644 --- a/definitions/NodeDefinition.lua +++ b/definitions/NodeDefinition.lua @@ -622,23 +622,23 @@ local NodeDefinition = { --- Called after the actual action has happened, according to what was --- allowed. --- No return value. - --- @type (fun(pos:MapPosition, from_list:string, from_index:number, to_list:string, to_index:number, count:number, player:Player): void)? + --- @type (fun(pos:MapPosition, from_list:string, from_index:number, to_list:string, to_index:number, count:number, player:Player): any)? on_metadata_inventory_move = nil, --- Called after the actual action has happened, according to what was --- allowed. --- No return value. - --- @type (fun(pos:MapPosition, listname:string, index:number, stack:ItemStack, player:Player): void)? + --- @type (fun(pos:MapPosition, listname:string, index:number, stack:ItemStack, player:Player): any)? on_metadata_inventory_put = nil, --- Called after the actual action has happened, according to what was --- allowed. --- No return value. - --- @type (fun(pos:MapPosition, listname:string, index:number, stack:ItemStack, player:Player): void)? + --- @type (fun(pos:MapPosition, listname:string, index:number, stack:ItemStack, player:Player): any)? on_metadata_inventory_take = nil, --- intensity: 1.0 = mid range of regular TNT. --- If defined, called when an explosion touches the node, instead of --- removing the node. - --- @type (fun(pos:MapPosition, intensity:number): void)? + --- @type (fun(pos:MapPosition, intensity:number): any)? on_blast = nil, --- stores which mod actually registered a node diff --git a/lua_ext/string.lua b/lua_ext/string.lua index 8c0a06c..de47265 100644 --- a/lua_ext/string.lua +++ b/lua_ext/string.lua @@ -2,17 +2,18 @@ --- e.g. `"a,b":split(",")` returns `{"a","b"}` +--- @param s string --- @param separator? string cannot be empty, default: `","` --- @param include_empty? boolean default: `false` --- @param max_splits? number if it's negative, splits aren't limited, default: `-1` --- @param sep_is_pattern? boolean it specifies whether separator is a plain string or a pattern (regex), default: `false` --- @return string[] -function string:split(separator, include_empty, max_splits, sep_is_pattern) end +function string.split(s, separator, include_empty, max_splits, sep_is_pattern) end --- Returns the string without whitespace pre- and suffixes --- e.g. `"\n \t\tfoo bar\t ":trim()` returns `"foo bar"` --- @return string -function string:trim() end +function string.trim() end --- Backported from Lua 5.4, see https://www.lua.org/manual/5.4/manual.html#6.4.2 ---