peanuts.lua 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  1. local crop_def = {}
  2. local mope = "sandwiches:mortar_pestle"
  3. if minetest.global_exists("farming") and farming.mod == "redo" then
  4. mope = "farming:mortar_pestle"
  5. -- peanut seeds
  6. minetest.register_node("sandwiches:seed_peanut", {
  7. description = "Peanuts Seed",
  8. tiles = {"seed_peanut.png"},
  9. inventory_image = "sandwiches_seed_peanut.png",
  10. wield_image = "sandwiches_seed_peanut.png",
  11. drawtype = "signlike",
  12. groups = {seed = 1, snappy = 3, attached_node = 1, flammable = 4},
  13. paramtype = "light",
  14. paramtype2 = "wallmounted",
  15. walkable = false,
  16. sunlight_propagates = true,
  17. selection_box = {
  18. type = "fixed",
  19. fixed = {
  20. {-0.5, -0.5, -0.5, 0.5, -0.35, 0.5},
  21. },
  22. },
  23. on_place = function(itemstack, placer, pointed_thing)
  24. return farming.place_seed(itemstack, placer, pointed_thing, "sandwiches:peanut_1")
  25. end,
  26. })
  27. minetest.register_craftitem("sandwiches:peanuts", {
  28. description = "Peanuts",
  29. on_use = minetest.item_eat(1),
  30. inventory_image = "sandwiches_peanut.png", -- not peanutS due to compatibility with the default farming mod
  31. groups = {food = 1, food_peanut = 1, food_peanuts = 1, flammable = 1},
  32. })
  33. minetest.register_alias("sandwiches:seed_peanuts", "sandwiches:seed_peanut")
  34. --minetest.register_alias("sandwiches:peanuts", "sandwiches:peanut")
  35. -- peanut plant definition
  36. crop_def = {
  37. drawtype = "plantlike",
  38. tiles = {"sandwiches_peanut_1.png"},
  39. paramtype = "light",
  40. sunlight_propagates = true,
  41. walkable = false,
  42. buildable_to = true,
  43. drop = "",
  44. selection_box = {
  45. type = "fixed",
  46. fixed = {
  47. {-0.5, -0.5, -0.5, 0.5, -0.35, 0.5},
  48. },
  49. },
  50. groups = { snappy = 3, flammable = 4, plant = 1, flora = 1, attached_node = 1,
  51. not_in_creative_inventory = 1, growing = 1 },
  52. sounds = default.node_sound_leaves_defaults()
  53. }
  54. -- stage 1
  55. minetest.register_node("sandwiches:peanut_1", table.copy(crop_def))
  56. -- stage 2
  57. crop_def.tiles = {"sandwiches_peanut_2.png"}
  58. minetest.register_node("sandwiches:peanut_2", table.copy(crop_def))
  59. -- stage 3
  60. crop_def.tiles = {"sandwiches_peanut_3.png"}
  61. crop_def.drop = {
  62. items = {
  63. {items = {'sandwiches:peanuts 2'}, rarity = 1},
  64. {items = {'sandwiches:peanuts'}, rarity = 2},
  65. }
  66. }
  67. minetest.register_node("sandwiches:peanut_3", table.copy(crop_def))
  68. -- stage 4
  69. crop_def.tiles = {"sandwiches_peanut_4.png"}
  70. crop_def.drop = {
  71. items = {
  72. {items = {'sandwiches:peanuts 4'}, rarity = 1},
  73. {items = {'sandwiches:peanuts 2'}, rarity = 2},
  74. {items = {'sandwiches:peanuts'}, rarity = 4},
  75. {items = {'sandwiches:seed_peanut 2'}, rarity = 1},
  76. {items = {'sandwiches:seed_peanut 2'}, rarity = 3},
  77. }
  78. }
  79. minetest.register_node("sandwiches:peanut_4", table.copy(crop_def))
  80. -- stage 5 (spreading stage)
  81. -- as the crop grows to the 5th stage, it has less seeds
  82. -- because they are "used" when spreading
  83. crop_def.tiles = {"sandwiches_peanut_5.png"}
  84. crop_def.drop = {
  85. items = {
  86. {items = {'sandwiches:peanuts 3'}, rarity = 1},
  87. {items = {'sandwiches:peanuts 2'}, rarity = 2},
  88. {items = {'sandwiches:peanuts'}, rarity = 4},
  89. {items = {'sandwiches:seed_peanut'}, rarity = 1},
  90. {items = {'sandwiches:seed_peanut'}, rarity = 2},
  91. }
  92. }
  93. minetest.register_node("sandwiches:peanut_5", table.copy(crop_def))
  94. -- stage 6 (final)
  95. -- the plant is "exhausted" from the spreading
  96. crop_def.tiles = {"sandwiches_peanut_6.png"}
  97. crop_def.groups.growing = 0
  98. crop_def.drop = {
  99. items = {
  100. {items = {'sandwiches:peanuts 3'}, rarity = 1},
  101. {items = {'sandwiches:peanuts 2'}, rarity = 2},
  102. {items = {'sandwiches:peanuts'}, rarity = 4},
  103. {items = {'sandwiches:seed_peanut'}, rarity = 1},
  104. {items = {'sandwiches:seed_peanut'}, rarity = 4},
  105. }
  106. }
  107. minetest.register_node("sandwiches:peanut_6", table.copy(crop_def))
  108. if minetest.get_modpath("bonemeal") then
  109. bonemeal:add_crop({ {"sandwiches:peanut_", 5, "sandwiches:seed_peanut"}, })
  110. end
  111. else -- farming-redo not present -----------------------------------------------
  112. farming.register_plant("sandwiches:peanut", {
  113. description = "Peanut Seed",
  114. harvest_description = "Peanuts",
  115. inventory_image = "sandwiches_seed_peanut.png",
  116. steps = 6,
  117. minlight = 12,
  118. maxlight = default.LIGHT_MAX,
  119. fertility = {"grassland"},
  120. groups = {flammable = 4, attached_node = 1, snappy = 3, plant = 1, flora = 1,},
  121. })
  122. if minetest.registered_items["sandwiches:peanuts"] then
  123. minetest.override_item("sandwiches:peanuts", {
  124. --description = "Peanuts",
  125. on_use = minetest.item_eat(1),
  126. inventory_image = "sandwiches_peanut.png",
  127. groups = {food = 1, food_peanut = 1, food_peanuts = 1, flammable = 1},
  128. })
  129. end
  130. if minetest.get_modpath("bonemeal") then
  131. bonemeal:add_crop({ {"sandwiches:peanut_", 5, "sandwiches:seed_peanut"}, })
  132. end
  133. end -- register different plant nodes
  134. minetest.register_abm({
  135. name = "sandwiches:peanut_spreading_abm",
  136. nodenames = {"sandwiches:peanut_5"},
  137. interval = 5,
  138. chance = 5,
  139. action = function(pos, node)
  140. -- Check 3x3x3 nodes around the currently triggered node
  141. local soil_positions = minetest.find_nodes_in_area_under_air(
  142. vector.add(pos, -1), vector.add(pos, 1),
  143. {"farming:soil_wet", "farming:soil"}
  144. )
  145. if(next(soil_positions) ~= null) then
  146. local found_soil_pos = soil_positions[math.random(#soil_positions)]
  147. found_soil_pos.y = found_soil_pos.y +1
  148. minetest.set_node(found_soil_pos, {name="sandwiches:peanut_1"})
  149. if(math.random(10) > 5) then
  150. minetest.set_node(pos,{name="sandwiches:peanut_6"})
  151. end
  152. end
  153. end
  154. })
  155. -- WILD PEANUTS --
  156. minetest.register_node("sandwiches:wild_peanut", {
  157. description = "Wild Peanuts",
  158. paramtype = "light",
  159. walkable = false,
  160. drop = {
  161. items = {
  162. {items = {'sandwiches:peanuts'}, rarity = 1},
  163. {items = {'sandwiches:peanuts'}, rarity = 2},
  164. {items = {'sandwiches:seed_peanut 2'}, rarity = 1},
  165. {items = {'sandwiches:seed_peanut'}, rarity = 3},
  166. }
  167. },
  168. drawtype = "plantlike",
  169. paramtype2 = "facedir",
  170. tiles = {"sandwiches_peanut_4.png"},
  171. inventory_image = "sandwiches_peanut_4.png",
  172. wield_image = "sandwiches_peanut_4.png",
  173. groups = {snappy = 3, dig_immediate=1, flammable=2, plant=1, flora = 1, attached_node = 1, not_in_creative_inventory = 1},
  174. sounds = default.node_sound_leaves_defaults(),
  175. selection_box = {
  176. type = "fixed",
  177. fixed = { {-0.5, -0.5, -0.5, 0.5, -0.35, 0.5}, },
  178. },
  179. })
  180. minetest.register_decoration({
  181. deco_type = "simple",
  182. place_on = {"default:dirt_with_grass", "default:dirt"},
  183. sidelen = 16,
  184. noise_params = {
  185. offset = 0,
  186. scale = 0.0003,
  187. spread = {x = 70, y = 70, z = 70},
  188. seed = 2570,
  189. octaves = 3,
  190. persist = 0.6
  191. },
  192. y_min = 0,
  193. y_max = 100,
  194. decoration = "sandwiches:wild_peanut",
  195. })
  196. -- PEANUT BUTTER --
  197. minetest.register_craftitem("sandwiches:peanut_butter", {
  198. description = "Peanut Butter",
  199. on_use = minetest.item_eat(2),
  200. groups = {food = 2, food_peanut_butter = 1, flammable = 1},
  201. inventory_image = "sandwiches_peanut_butter.png"
  202. })
  203. minetest.register_craft({
  204. output = "sandwiches:peanut_butter 5",
  205. type = "shapeless";
  206. recipe = {"sandwiches:peanuts", "sandwiches:peanuts", "sandwiches:peanuts",
  207. "sandwiches:peanuts", "sandwiches:peanuts", "sandwiches:peanuts",
  208. "group:food_mortar_pestle","sandwiches:peanuts", "sandwiches:peanuts",
  209. },
  210. replacements = {{"group:food_mortar_pestle", mope }},
  211. })