Minetest type hinting enchancements

This commit is contained in:
2024-05-13 00:23:48 +03:00
committed by Alexander Chibrikin
parent 58978becdc
commit 3382f78275
3 changed files with 36 additions and 2 deletions

View File

@@ -18,7 +18,7 @@ function MetaDataRef:contains(key) end
function MetaDataRef:get(key) end
---@param key string
---@param value string
---@param value string value "" will delete the key
---@return number
function MetaDataRef:set_string(key, value) end

View File

@@ -0,0 +1,29 @@
-- Used by `minetest.register_chatcommand`.
--- @class ChatCommandDefinition
local ChatCommandDefinition = {
--- Short parameter description. Example: `"<name> <privilege>"`.
--- Note that in params, use of symbols is as follows:
--- * `<>` signifies a placeholder to be replaced when the command is used. For
--- example, when a player name is needed: `<name>`
--- * `[]` signifies param is optional and not required when the command is used.
--- For example, if you require param1 but param2 is optional:
--- `<param1> [<param2>]`
--- * `|` signifies exclusive or. The command requires one param from the options
--- provided. For example: `<param1> | <param2>`
--- * `()` signifies grouping. For example, when param1 and param2 are both
--- required, or only param3 is required: `(<param1> <param2>) | <param3>`
--- @type string|nil
params = nil,
--- @type string|nil Full description. Example: `"Remove privilege from player"`.
description = nil,
--- @type table<string,boolean>|nil Require the "privs" privilege to run. Example: `{privs=true}`.
privs = nil,
--- Called when command is run. Returns boolean success and text output.
--- Special case: The help message is shown to the player if `func`
--- returns false without a text output.
--- @type fun(name:string, param:string):boolean,string
func = function(name, param) end,
}

View File

@@ -606,7 +606,7 @@ function minetest.register_on_joinplayer(callback) end
--- * `timed_out`: True for timeout, false for other reasons.
---
--- [View in lua_api.txt](https://github.com/minetest/minetest/blob/5.4.1/doc/lua_api.txt#L4641-L4643)
--- @param callback fun(player:ObjectRef, timed_out)
--- @param callback fun(player:ObjectRef|Player, timed_out)
function minetest.register_on_leaveplayer(callback) end
--- * Called when a client attempts to log into an account.
--- * `name`: The name of the account being authenticated.
@@ -1955,6 +1955,7 @@ function minetest.request_http_api() end
--- * must be called during mod load time
---
--- [View in lua_api.txt](https://github.com/minetest/minetest/blob/5.4.1/doc/lua_api.txt#L5630-L5632)
--- @return StorageRef
function minetest.get_mod_storage() end
-- Misc.:
@@ -2051,6 +2052,10 @@ function minetest.parse_json(string, nullvalue) end
--- returns `"[10, {\"a\": false}]"`
---
--- [View in lua_api.txt](https://github.com/minetest/minetest/blob/5.4.1/doc/lua_api.txt#L5672-L5685)
--- @overload fun(data)
--- @param data table
--- @param styled boolean
--- @return string|nil
function minetest.write_json(data, styled) end
--- Returns a string
--- * Convert a table containing tables, strings, numbers, booleans and `nil`s