From a8a2da4059bf6a0c22ee69239e5ebfb6a96f7304 Mon Sep 17 00:00:00 2001 From: Alexander Chibrikin Date: Thu, 22 Jan 2026 15:13:25 +0300 Subject: [PATCH] Extract `core_namespace/registration/gameplay.lua`; actualize & fix annotations for it. --- core_namespace.lua | 49 +--------------- core_namespace/registration/gameplay.lua | 71 ++++++++++++++++++++++++ 2 files changed, 73 insertions(+), 47 deletions(-) create mode 100644 core_namespace/registration/gameplay.lua diff --git a/core_namespace.lua b/core_namespace.lua index f9b11fc..b0fea17 100644 --- a/core_namespace.lua +++ b/core_namespace.lua @@ -311,54 +311,9 @@ function core.translate(textdomain, str, ...) end -- Registration functions: -- Environment: -- see ./core_namespace/registration/environment.lua - - - -- Gameplay: ---- * Check recipe table syntax for different types below. ---- ---- [View in lua_api.txt](https://github.com/minetest/minetest/blob/5.4.1/doc/lua_api.txt#L4531-L4532) -function core.register_craft(recipe) end ---- * Will erase existing craft based either on output item or on input recipe. ---- * Specify either output or input only. If you specify both, input will be ---- ignored. For input use the same recipe table syntax as for ---- `core.register_craft(recipe)`. For output specify only the item, ---- without a quantity. ---- * Returns false if no erase candidate could be found, otherwise returns true. ---- * **Warning**! The type field ("shaped", "cooking" or any other) will be ---- ignored if the recipe contains output. Erasing is then done independently ---- from the crafting method. ---- ---- [View in lua_api.txt](https://github.com/minetest/minetest/blob/5.4.1/doc/lua_api.txt#L4533-L4542) -function core.clear_craft(recipe) end ---- [View in lua_api.txt](https://github.com/minetest/minetest/blob/5.4.1/doc/lua_api.txt#L4543-L4543) ---- @param cmd string ---- @param chatcommand_definition ChatCommandDefinition -function core.register_chatcommand(cmd, chatcommand_definition) end ---- * Overrides fields of a chatcommand registered with `register_chatcommand`. ---- ---- [View in lua_api.txt](https://github.com/minetest/minetest/blob/5.4.1/doc/lua_api.txt#L4544-L4545) -function core.override_chatcommand(name, redefinition) end ---- * Unregisters a chatcommands registered with `register_chatcommand`. ---- ---- [View in lua_api.txt](https://github.com/minetest/minetest/blob/5.4.1/doc/lua_api.txt#L4546-L4547) -function core.unregister_chatcommand(name) end ---- * `definition` can be a description or a definition table (see [Privilege ---- definition]). ---- * If it is a description, the priv will be granted to singleplayer and admin ---- by default. ---- * To allow players with `basic_privs` to grant, see the `basic_privs` ---- minetest.conf setting. ---- ---- [View in lua_api.txt](https://github.com/minetest/minetest/blob/5.4.1/doc/lua_api.txt#L4548-L4554) ---- @param name string ---- @param definition string|PrivilegeDefinition -function core.register_privilege(name, definition) end ---- * Registers an auth handler that overrides the builtin one. ---- * This function can be called by a single mod once only. ---- ---- [View in lua_api.txt](https://github.com/minetest/minetest/blob/5.4.1/doc/lua_api.txt#L4555-L4557) -function core.register_authentication_handler(authentication_handler_definition) end +-- see ./core_namespace/registration/gameplay.lua + -- Global callback registration functions: --- * Called every server step, usually interval of 0.1s diff --git a/core_namespace/registration/gameplay.lua b/core_namespace/registration/gameplay.lua new file mode 100644 index 0000000..92e7a30 --- /dev/null +++ b/core_namespace/registration/gameplay.lua @@ -0,0 +1,71 @@ +--- @meta + +--- Registers a crafting recipe. +--- * Check recipe table syntax for different types below. +--- [TODO]: Link to recipe table syntax documentation. +--- @param recipe table +function core.register_craft(recipe) end + +--- * Will erase existing craft based either on output item or on input recipe. +--- * Specify either output or input only. If you specify both, input will be +--- ignored. For input use the same recipe table syntax as for +--- `core.register_craft(recipe)`. For output specify only the item, +--- without a quantity. +--- * Returns false if no erase candidate could be found, otherwise returns true. +--- * **Warning**! The type field ("shaped", "cooking" or any other) will be +--- ignored if the recipe contains output. Erasing is then done independently +--- from the crafting method. +--- +--- @param recipe table +--- @return boolean +function core.clear_craft(recipe) end + +--- Registers a chatcommand. +--- * `cmd` is the name of the command without the leading slash. +--- * `chatcommand_definition` is a table containing the following fields: +--- * `description` (string) A short description of the command. +--- * `params` (string) A string describing the parameters of the command. +--- * `privs` (table) A table specifying the privileges required to use the command. +--- * `func` (function) The function to be called when the command is executed. \ +--- It receives two parameters: +--- * `name` (string) the name of the player who executed the command, and +--- * `param` (string) the parameters passed to the command. +--- +--- It should return two values: +--- * `success` (boolean) and +--- * `message` (string). +--- +--- If `success` is false, `message` will be sent to the player as an error message. \ +--- If `success` is true, `message` will be sent as a regular chat message. +--- If it returns `false` and no `message`, the help message is shown. +--- +--- @param cmd string +--- @param chatcommand_definition ChatCommandDefinition +function core.register_chatcommand(cmd, chatcommand_definition) end + +--- Overrides fields of a chatcommand registered with `register_chatcommand`. +--- +--- @param name string +--- @param redefinition ChatCommandDefinition +function core.override_chatcommand(name, redefinition) end + +--- Unregisters a chatcommands registered with `register_chatcommand`. +--- +--- @param name string +function core.unregister_chatcommand(name) end + +--- Registers a privilege. +--- * `definition` can be a description or a definition table +--- * If it is a description, the priv will be granted to singleplayer and admin by default. +--- * To allow players with `basic_privs` to grant, see the `basic_privs` minetest.conf setting. +--- +--- @param name string +--- @param definition string|PrivilegeDefinition +function core.register_privilege(name, definition) end + +--- Registers an authentication handler. +--- * Registers an auth handler that overrides the builtin one. +--- * This function can be called by a single mod once only. +--- +--- @param authentication_handler_definition AuthenticationHandlerDefinition +function core.register_authentication_handler(authentication_handler_definition) end