pumpkin.lua 5.4 KB

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