pumpkin.lua 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  1. local S = farming.translate
  2. -- pumpkin slice
  3. minetest.register_craftitem("farming:pumpkin_slice", {
  4. description = S("Pumpkin Slice"),
  5. inventory_image = "farming_pumpkin_slice.png",
  6. groups = {compostability = 48, seed = 2, food_pumpkin_slice = 1, flammable = 2},
  7. on_place = function(itemstack, placer, pointed_thing)
  8. return farming.place_seed(itemstack, placer, pointed_thing, "farming:pumpkin_1")
  9. end,
  10. on_use = minetest.item_eat(2)
  11. })
  12. minetest.register_craft({
  13. output = "farming:pumpkin",
  14. recipe = {
  15. {"farming:pumpkin_slice", "farming:pumpkin_slice"},
  16. {"farming:pumpkin_slice", "farming:pumpkin_slice"}
  17. }
  18. })
  19. local tmp = farming.use_utensils and "farming:cutting_board" or ""
  20. minetest.register_craft({
  21. output = "farming:pumpkin_slice 4",
  22. recipe = {{"farming:pumpkin", tmp}},
  23. replacements = {{"farming:cutting_board", "farming:cutting_board"}}
  24. })
  25. -- jack 'o lantern
  26. minetest.register_node("farming:jackolantern", {
  27. description = S("Jack 'O Lantern (punch to turn on and off)"),
  28. tiles = {
  29. "farming_pumpkin_bottom.png^farming_pumpkin_top.png", "farming_pumpkin_bottom.png",
  30. "farming_pumpkin_side.png", "farming_pumpkin_side.png",
  31. "farming_pumpkin_side.png", "farming_pumpkin_side.png^farming_pumpkin_face_off.png"
  32. },
  33. paramtype2 = "facedir",
  34. groups = {handy = 1, snappy = 2, choppy = 2, oddly_breakable_by_hand = 2, flammable = 2},
  35. sounds = farming.sounds.node_sound_wood_defaults(),
  36. on_punch = function(pos, node, puncher)
  37. local name = puncher:get_player_name() or ""
  38. if minetest.is_protected(pos, name) then return end
  39. node.name = "farming:jackolantern_on"
  40. minetest.swap_node(pos, node)
  41. end
  42. })
  43. minetest.register_node("farming:jackolantern_on", {
  44. tiles = {
  45. "farming_pumpkin_bottom.png^farming_pumpkin_top.png", "farming_pumpkin_bottom.png",
  46. "farming_pumpkin_side.png", "farming_pumpkin_side.png",
  47. "farming_pumpkin_side.png", "farming_pumpkin_side.png^farming_pumpkin_face_on.png"
  48. },
  49. light_source = minetest.LIGHT_MAX - 1,
  50. paramtype2 = "facedir",
  51. groups = {
  52. handy = 1, snappy = 2, choppy = 2, oddly_breakable_by_hand = 2, flammable = 2,
  53. not_in_creative_inventory = 1
  54. },
  55. sounds = farming.sounds.node_sound_wood_defaults(),
  56. drop = "farming:jackolantern",
  57. on_punch = function(pos, node, puncher)
  58. local name = puncher:get_player_name() or ""
  59. if minetest.is_protected(pos, name) then return end
  60. node.name = "farming:jackolantern"
  61. minetest.swap_node(pos, node)
  62. end
  63. })
  64. minetest.register_craft({
  65. output = "farming:jackolantern",
  66. recipe = {
  67. {"default:torch"},
  68. {"group:food_pumpkin"}
  69. }
  70. })
  71. --- wooden scarecrow base
  72. minetest.register_node("farming:scarecrow_bottom", {
  73. description = S("Scarecrow Bottom"),
  74. paramtype = "light",
  75. sunlight_propagates = true,
  76. paramtype2 = "facedir",
  77. tiles = {"default_wood.png"},
  78. drawtype = "nodebox",
  79. node_box = {
  80. type = "fixed",
  81. fixed = {
  82. {-1/16, -8/16, -1/16, 1/16, 8/16, 1/16},
  83. {-12/16, 4/16, -1/16, 12/16, 2/16, 1/16},
  84. }
  85. },
  86. groups = {handy = 1, snappy = 3, flammable = 2}
  87. })
  88. minetest.register_craft({
  89. output = "farming:scarecrow_bottom",
  90. recipe = {
  91. {"", "group:stick", ""},
  92. {"group:stick", "group:stick", "group:stick"},
  93. {"", "group:stick", ""}
  94. }
  95. })
  96. -- pumpkin bread
  97. minetest.register_craftitem("farming:pumpkin_bread", {
  98. description = S("Pumpkin Bread"),
  99. inventory_image = "farming_pumpkin_bread.png",
  100. on_use = minetest.item_eat(8),
  101. groups = {compostability = 65, food_bread = 1, flammable = 2}
  102. })
  103. minetest.register_craftitem("farming:pumpkin_dough", {
  104. description = S("Pumpkin Dough"),
  105. inventory_image = "farming_pumpkin_dough.png"
  106. })
  107. minetest.register_craft({
  108. output = "farming:pumpkin_dough",
  109. recipe = {
  110. {"group:food_pumpkin_slice", "group:food_flour", "group:food_pumpkin_slice"}
  111. }
  112. })
  113. minetest.register_craft({
  114. type = "cooking",
  115. output = "farming:pumpkin_bread",
  116. recipe = "farming:pumpkin_dough",
  117. cooktime = 10
  118. })
  119. -- pumpkin definition
  120. local def = {
  121. drawtype = "plantlike",
  122. tiles = {"farming_pumpkin_1.png"},
  123. paramtype = "light",
  124. sunlight_propagates = true,
  125. waving = 1,
  126. walkable = false,
  127. buildable_to = true,
  128. drop = "",
  129. selection_box = farming.select,
  130. groups = {
  131. handy = 1, snappy = 3, flammable = 2, plant = 1, attached_node = 1,
  132. not_in_creative_inventory = 1, growing = 1
  133. },
  134. sounds = farming.sounds.node_sound_leaves_defaults()
  135. }
  136. -- stage 1
  137. minetest.register_node("farming:pumpkin_1", table.copy(def))
  138. -- stage 2
  139. def.tiles = {"farming_pumpkin_2.png"}
  140. minetest.register_node("farming:pumpkin_2", table.copy(def))
  141. -- stage 3
  142. def.tiles = {"farming_pumpkin_3.png"}
  143. minetest.register_node("farming:pumpkin_3", table.copy(def))
  144. -- stage 4
  145. def.tiles = {"farming_pumpkin_4.png"}
  146. minetest.register_node("farming:pumpkin_4", table.copy(def))
  147. -- stage 5
  148. def.tiles = {"farming_pumpkin_5.png"}
  149. minetest.register_node("farming:pumpkin_5", table.copy(def))
  150. -- stage 6
  151. def.tiles = {"farming_pumpkin_6.png"}
  152. minetest.register_node("farming:pumpkin_6", table.copy(def))
  153. -- stage 7
  154. def.tiles = {"farming_pumpkin_7.png"}
  155. minetest.register_node("farming:pumpkin_7", table.copy(def))
  156. -- stage 8 (final)
  157. minetest.register_node("farming:pumpkin_8", {
  158. description = S("Pumpkin"),
  159. tiles = {
  160. "farming_pumpkin_bottom.png^farming_pumpkin_top.png",
  161. "farming_pumpkin_bottom.png",
  162. "farming_pumpkin_side.png"
  163. },
  164. groups = {
  165. compostability = 65, food_pumpkin = 1, snappy = 3, choppy = 3, oddly_breakable_by_hand = 2,
  166. flammable = 2, plant = 1
  167. },
  168. drop = "farming:pumpkin_8",
  169. sounds = farming.sounds.node_sound_wood_defaults(),
  170. paramtype2 = "facedir",
  171. on_place = minetest.rotate_node
  172. })
  173. minetest.register_alias("farming:pumpkin", "farming:pumpkin_8")
  174. -- add to registered_plants
  175. farming.registered_plants["farming:pumpkin"] = {
  176. crop = "farming:pumpkin",
  177. seed = "farming:pumpkin_slice",
  178. minlight = farming.min_light,
  179. maxlight = farming.max_light,
  180. steps = 8
  181. }
  182. -- mapgen
  183. local mg = farming.mapgen == "v6"
  184. def = {
  185. y_max = mg and 20 or 6,
  186. near = mg and "group:water" or nil,
  187. num = mg and 1 or -1,
  188. }
  189. minetest.register_decoration({
  190. deco_type = "simple",
  191. place_on = {"mcl_core:dirt_with_grass, default:dirt_with_grass"},
  192. sidelen = 16,
  193. noise_params = {
  194. offset = 0,
  195. scale = farming.pumpkin,
  196. spread = {x = 100, y = 100, z = 100},
  197. seed = 576,
  198. octaves = 3,
  199. persist = 0.6
  200. },
  201. y_min = 1,
  202. y_max = def.y_max,
  203. decoration = "farming:pumpkin_8",
  204. spawn_by = def.near,
  205. num_spawn_by = def.num
  206. })