recipe.lua 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. ---@meta
  2. ---Crafting recipes
  3. -------------------
  4. -- Used by `minetest.register_craft`.
  5. ---@alias mt.CraftRecipe mt.CraftRecipeRepair|mt.CraftRecipeFuel|mt.CraftRecipeShaped|mt.CraftRecipeCooking|mt.CraftRecipeShapeless
  6. ---@class mt.CraftRecipeShaped
  7. ---@field output string|nil
  8. ---@field recipe string[][]|nil
  9. -- Replace one input item with another item on crafting.
  10. ---@field replacements nil|{[1]:string, [2]:string}[]
  11. ---@class mt.CraftRecipeShapeless
  12. ---@field type "shapeless"|nil
  13. ---@field output string|nil
  14. ---@field recipe string[]|nil
  15. -- Replace one input item with another item on crafting.
  16. ---@field replacements nil|{[1]:string, [2]:string}[]
  17. -- Adds a shapeless recipe for *every* tool that doesn't have the `disable_repair=1`
  18. -- group. Player can put 2 equal tools in the craft grid to get one "repaired" tool
  19. -- back.
  20. --
  21. -- The wear of the output is determined by the wear of both tools, plus a
  22. -- 'repair bonus' given by `additional_wear`. To reduce the wear (i.e. 'repair'),
  23. -- you want `additional_wear` to be negative.
  24. --
  25. -- The formula used to calculate the resulting wear is:
  26. --
  27. -- 65536 - ( (65536 - tool_1_wear) + (65536 - tool_2_wear) + 65536 * additional_wear )
  28. --
  29. -- The result is rounded and can't be lower than 0. If the result is 65536 or higher,
  30. -- no crafting is possible.
  31. ---@class mt.CraftRecipeRepair
  32. ---@field type "toolrepair"|nil
  33. ---@field additional_wear number|nil Multiplier of 65536.
  34. ---@class mt.CraftRecipeCooking
  35. ---@field type "cooking"|nil
  36. ---@field output string|nil
  37. ---@field recipe string|nil
  38. ---@field cooktime number|nil
  39. ---@class mt.CraftRecipeFuel
  40. ---@field type "fuel"|nil
  41. ---@field recipe string|nil
  42. ---@field burntime number|nil
  43. -- Replace one input item with another item on crafting.
  44. ---@field replacements nil|{[1]:string, [2]:string}[]