From 196936acbc4c940e27f48003ee2bc7abf32191ea Mon Sep 17 00:00:00 2001 From: alek13 Date: Fri, 20 Sep 2024 16:53:32 +0300 Subject: [PATCH] `Core`: `builtin`: ability to add custom craft methods for `minetest.{register_craft|get_craft_result}()`. Closes lord-server/lord#1685 --- minetest_ns.lua | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/minetest_ns.lua b/minetest_ns.lua index 0c909c1..e598ad3 100644 --- a/minetest_ns.lua +++ b/minetest_ns.lua @@ -1458,6 +1458,17 @@ function minetest.strip_param2_color(param2, paramtype2) end --- --- [View in lua_api.txt](https://github.com/minetest/minetest/blob/5.4.1/doc/lua_api.txt#L5280-L5284) function minetest.get_node_drops(node, toolname) end + +--- @class RecipeInput +--- @field method string `"normal"` or `"cooking"` or `"fuel"` +--- @field width number for example `3` +--- @field items ItemStack[] for example `{stack1, stack2, stack3, stack4, stack 5, stack 6, stack 7, stack 8, stack 9}` + +--- @class RecipeOutput +--- @field item ItemStack +--- @field time number +--- @field replacements ItemStack[][] + --- Returns `output, decremented_input` --- * `input.method` = `"normal"` or `"cooking"` or `"fuel"` --- * `input.width` = for example `3` @@ -1471,6 +1482,8 @@ function minetest.get_node_drops(node, toolname) end --- * `decremented_input` = like `input` --- --- [View in lua_api.txt](https://github.com/minetest/minetest/blob/5.4.1/doc/lua_api.txt#L5285-L5295) +--- @param input RecipeInput +--- @return RecipeOutput, RecipeInput function minetest.get_craft_result(input) end --- Returns input --- * returns last registered recipe for output item (node) @@ -1482,6 +1495,8 @@ function minetest.get_craft_result(input) end --- * `input.items` = `nil` if no recipe found --- --- [View in lua_api.txt](https://github.com/minetest/minetest/blob/5.4.1/doc/lua_api.txt#L5296-L5303) +--- @param output string node or item tech name such as `"default:torch"` +--- @return RecipeInput function minetest.get_craft_recipe(output) end --- @class RecipeEntryTable