You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

248 lines
6.1KB

  1. local S = moretrees.intllib
  2. for i in ipairs(moretrees.treelist) do
  3. local treename = moretrees.treelist[i][1]
  4. minetest.register_craft({
  5. type = "shapeless",
  6. output = "moretrees:"..treename.."_planks 4",
  7. recipe = {
  8. "moretrees:"..treename.."_trunk"
  9. }
  10. })
  11. minetest.register_craft({
  12. type = "fuel",
  13. recipe = "moretrees:"..treename.."_sapling",
  14. burntime = 10,
  15. })
  16. end
  17. minetest.register_craft({
  18. type = "shapeless",
  19. output = "moretrees:rubber_tree_planks 4",
  20. recipe = {
  21. "moretrees:rubber_tree_trunk_empty"
  22. }
  23. })
  24. minetest.register_craft({
  25. type = "fuel",
  26. recipe = "group:moretrees_leaves",
  27. burntime = 1,
  28. })
  29. -- Food recipes!
  30. minetest.register_craftitem("moretrees:coconut_milk", {
  31. description = S("Coconut Milk"),
  32. inventory_image = "moretrees_coconut_milk_inv.png",
  33. wield_image = "moretrees_coconut_milk.png",
  34. on_use = minetest.item_eat(2),
  35. })
  36. minetest.register_craftitem("moretrees:raw_coconut", {
  37. description = S("Raw Coconut"),
  38. inventory_image = "moretrees_raw_coconut.png",
  39. on_use = minetest.item_eat(4),
  40. })
  41. minetest.register_craftitem("moretrees:date", {
  42. description = S("Date"),
  43. inventory_image = "moretrees_date.png",
  44. on_use = minetest.item_eat(1),
  45. })
  46. minetest.register_craftitem("moretrees:date_nut_snack", {
  47. description = S("Date & nut snack"),
  48. inventory_image = "moretrees_date_nut_snack.png",
  49. on_use = minetest.item_eat(4),
  50. })
  51. minetest.register_craftitem("moretrees:date_nut_batter", {
  52. description = S("Date-nut cake batter"),
  53. inventory_image = "moretrees_date_nut_batter.png",
  54. })
  55. minetest.register_craftitem("moretrees:date_nut_cake", {
  56. description = S("Date-nut cake"),
  57. inventory_image = "moretrees_date_nut_cake.png",
  58. on_use = minetest.item_eat(32),
  59. })
  60. minetest.register_craftitem("moretrees:date_nut_bar", {
  61. description = S("Date-nut energy bar"),
  62. inventory_image = "moretrees_date_nut_bar.png",
  63. on_use = minetest.item_eat(4),
  64. })
  65. minetest.register_craftitem("moretrees:acorn_muffin_batter", {
  66. description = S("Acorn Muffin batter"),
  67. inventory_image = "moretrees_acorn_muffin_batter.png",
  68. })
  69. minetest.register_craftitem("moretrees:acorn_muffin", {
  70. description = S("Acorn Muffin"),
  71. inventory_image = "moretrees_acorn_muffin.png",
  72. on_use = minetest.item_eat(4),
  73. })
  74. minetest.register_craftitem("moretrees:spruce_nuts", {
  75. description = S("Roasted Spruce Cone Nuts"),
  76. inventory_image = "moretrees_spruce_nuts.png",
  77. on_use = minetest.item_eat(1),
  78. })
  79. minetest.register_craftitem("moretrees:cedar_nuts", {
  80. description = S("Roasted Cedar Cone Nuts"),
  81. inventory_image = "moretrees_cedar_nuts.png",
  82. on_use = minetest.item_eat(1),
  83. })
  84. minetest.register_craftitem("moretrees:fir_nuts", {
  85. description = S("Roasted Fir Cone Nuts"),
  86. inventory_image = "moretrees_fir_nuts.png",
  87. on_use = minetest.item_eat(1),
  88. })
  89. for i in ipairs(moretrees.cutting_tools) do
  90. local tool = moretrees.cutting_tools[i]
  91. minetest.register_craft({
  92. type = "shapeless",
  93. output = "moretrees:coconut_milk",
  94. recipe = {
  95. "moretrees:coconut",
  96. "vessels:drinking_glass",
  97. tool
  98. },
  99. replacements = {
  100. { "moretrees:coconut", "moretrees:raw_coconut" },
  101. }
  102. })
  103. end
  104. -- give tool back with wear preserved
  105. minetest.register_on_craft(function(itemstack, player, old_craft_grid, craft_inv)
  106. if (itemstack:get_name() == "moretrees:coconut_milk") then
  107. for i, j in pairs(old_craft_grid) do
  108. -- find tool used to do the craft
  109. local ocg_name = j:get_name()
  110. if ((ocg_name ~= "") and (ocg_name ~= "moretrees:coconut") and (ocg_name ~= "vessels:drinking_glass")) then
  111. -- create a new tool and set wear
  112. local t = ItemStack(ocg_name)
  113. local w = j:get_wear()
  114. -- works if tool used is an axe
  115. local uses = j:get_tool_capabilities().groupcaps.choppy.uses or 0
  116. if (w == 0 and uses ~= 0) then
  117. -- tool has never been used
  118. -- use tool once
  119. t:set_wear(65535/(9*(uses - 1)))
  120. else
  121. -- set wear back
  122. t:set_wear(w)
  123. -- use tool once
  124. if (uses ~= 0) then
  125. t:add_wear(65535/(9*(uses - 1)))
  126. end
  127. end
  128. -- add to craft inventory
  129. craft_inv:add_item("craft", t)
  130. end
  131. end
  132. end
  133. end)
  134. minetest.register_craft({
  135. type = "shapeless",
  136. output = "moretrees:date_nut_snack",
  137. recipe = {
  138. "moretrees:date",
  139. "moretrees:date",
  140. "moretrees:date",
  141. "moretrees:spruce_nuts",
  142. "moretrees:cedar_nuts",
  143. "moretrees:fir_nuts",
  144. }
  145. })
  146. -- The date-nut cake is an exceptional food item due to its highly
  147. -- concentrated nature (32 food units). Because of that, it requires
  148. -- many different ingredients, and, starting from the base ingredients
  149. -- found or harvested in nature, it requires many steps to prepare.
  150. local flour
  151. if minetest.registered_nodes["farming:flour"] then
  152. flour = "farming:flour"
  153. else
  154. flour = "moretrees:acorn_muffin_batter"
  155. end
  156. minetest.register_craft({
  157. type = "shapeless",
  158. output = "moretrees:date_nut_batter",
  159. recipe = {
  160. "moretrees:date_nut_snack",
  161. "moretrees:date_nut_snack",
  162. "moretrees:date_nut_snack",
  163. "moretrees:coconut_milk",
  164. "moretrees:date_nut_snack",
  165. "moretrees:raw_coconut",
  166. "moretrees:coconut_milk",
  167. flour,
  168. "moretrees:raw_coconut",
  169. },
  170. replacements = {
  171. { "moretrees:coconut_milk", "vessels:drinking_glass 2" }
  172. }
  173. })
  174. minetest.register_craft({
  175. type = "cooking",
  176. output = "moretrees:date_nut_cake",
  177. recipe = "moretrees:date_nut_batter",
  178. })
  179. minetest.register_craft({
  180. type = "shapeless",
  181. output = "moretrees:date_nut_bar 8",
  182. recipe = {"moretrees:date_nut_cake"},
  183. })
  184. minetest.register_craft({
  185. type = "shapeless",
  186. output = "moretrees:acorn_muffin_batter",
  187. recipe = {
  188. "moretrees:acorn",
  189. "moretrees:acorn",
  190. "moretrees:acorn",
  191. "moretrees:acorn",
  192. "moretrees:coconut_milk",
  193. },
  194. replacements = {
  195. { "moretrees:coconut_milk", "vessels:drinking_glass" }
  196. }
  197. })
  198. minetest.register_craft({
  199. type = "cooking",
  200. output = "moretrees:acorn_muffin 4",
  201. recipe = "moretrees:acorn_muffin_batter",
  202. })
  203. minetest.register_craft({
  204. type = "cooking",
  205. output = "moretrees:spruce_nuts 4",
  206. recipe = "moretrees:spruce_cone",
  207. })
  208. minetest.register_craft({
  209. type = "cooking",
  210. output = "moretrees:cedar_nuts 4",
  211. recipe = "moretrees:cedar_cone",
  212. })
  213. minetest.register_craft({
  214. type = "cooking",
  215. output = "moretrees:fir_nuts 4",
  216. recipe = "moretrees:fir_cone",
  217. })