diff --git a/classes/MetaDataRef.lua b/classes/MetaDataRef.lua index ad51ff0..4342e6b 100644 --- a/classes/MetaDataRef.lua +++ b/classes/MetaDataRef.lua @@ -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 diff --git a/definitions/ChatCommandDefinition.lua b/definitions/ChatCommandDefinition.lua new file mode 100644 index 0000000..e0c193e --- /dev/null +++ b/definitions/ChatCommandDefinition.lua @@ -0,0 +1,29 @@ +-- Used by `minetest.register_chatcommand`. +--- @class ChatCommandDefinition +local ChatCommandDefinition = { + --- Short parameter description. Example: `" "`. + --- 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: `` + --- * `[]` signifies param is optional and not required when the command is used. + --- For example, if you require param1 but param2 is optional: + --- ` []` + --- * `|` signifies exclusive or. The command requires one param from the options + --- provided. For example: ` | ` + --- * `()` signifies grouping. For example, when param1 and param2 are both + --- required, or only param3 is required: `( ) | ` + --- @type string|nil + params = nil, + + --- @type string|nil Full description. Example: `"Remove privilege from player"`. + description = nil, + + --- @type table|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, +} diff --git a/minetest_types.lua b/minetest_types.lua index 14e7326..5aa24e3 100644 --- a/minetest_types.lua +++ b/minetest_types.lua @@ -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