pineapple.lua 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. local S = farming.translate
  2. -- pineapple top
  3. minetest.register_craftitem("farming:pineapple_top", {
  4. description = S("Pineapple Top"),
  5. inventory_image = "farming_pineapple_top.png",
  6. groups = {compostability = 48, seed = 2, flammable = 2},
  7. on_place = function(itemstack, placer, pointed_thing)
  8. return farming.place_seed(itemstack, placer, pointed_thing, "farming:pineapple_1")
  9. end
  10. })
  11. -- pineapple
  12. minetest.register_node("farming:pineapple", {
  13. description = S("Pineapple"),
  14. drawtype = "plantlike",
  15. tiles = {"farming_pineapple.png"},
  16. inventory_image = "farming_pineapple.png",
  17. wield_image = "farming_pineapple.png",
  18. paramtype = "light",
  19. sunlight_propagates = true,
  20. walkable = false,
  21. selection_box = {
  22. type = "fixed",
  23. fixed = {-0.27, -0.37, -0.27, 0.27, 0.44, 0.27}
  24. },
  25. groups = {compostability = 65, food_pineapple = 1, fleshy = 3, dig_immediate = 3, flammable = 2}
  26. })
  27. -- pineapple
  28. minetest.register_craftitem("farming:pineapple_ring", {
  29. description = S("Pineapple Ring"),
  30. inventory_image = "farming_pineapple_ring.png",
  31. groups = {compostability = 45, food_pineapple_ring = 1, flammable = 2},
  32. on_use = minetest.item_eat(1)
  33. })
  34. minetest.register_craft( {
  35. output = "farming:pineapple_ring 5",
  36. recipe = {{"group:food_pineapple"}},
  37. replacements = {{"farming:pineapple", "farming:pineapple_top"}}
  38. })
  39. -- pineapple juice
  40. minetest.register_craftitem("farming:pineapple_juice", {
  41. description = S("Pineapple Juice"),
  42. inventory_image = "farming_pineapple_juice.png",
  43. on_use = minetest.item_eat(4, "vessels:drinking_glass"),
  44. groups = {vessel = 1, drink = 1, compostability = 35}
  45. })
  46. local tmp = farming.use_utensils and "farming:juicer" or ""
  47. minetest.register_craft({
  48. output = "farming:pineapple_juice",
  49. recipe = {
  50. {"group:food_pineapple_ring", "group:food_pineapple_ring",
  51. "group:food_pineapple_ring"},
  52. {"", "vessels:drinking_glass", ""},
  53. {"", tmp, ""}
  54. },
  55. replacements = {
  56. {"group:food_juicer", "farming:juicer"}
  57. }
  58. })
  59. minetest.register_craft({
  60. output = "farming:pineapple_juice 2",
  61. recipe = {
  62. {"group:food_pineapple", ""},
  63. {"vessels:drinking_glass", "vessels:drinking_glass"},
  64. {tmp, ""}
  65. },
  66. replacements = {
  67. {"group:food_juicer", "farming:juicer"}
  68. }
  69. })
  70. -- crop definition
  71. local def = {
  72. drawtype = "plantlike",
  73. visual_scale = 1.5,
  74. tiles = {"farming_pineapple_1.png"},
  75. paramtype = "light",
  76. sunlight_propagates = true,
  77. walkable = false,
  78. buildable_to = true,
  79. drop = "",
  80. waving = 1,
  81. selection_box = farming.select,
  82. groups = {
  83. handy = 1, snappy = 3, flammable = 2, plant = 1, attached_node = 1,
  84. not_in_creative_inventory = 1, growing = 1
  85. },
  86. sounds = farming.sounds.node_sound_leaves_defaults()
  87. }
  88. -- stage 1
  89. minetest.register_node("farming:pineapple_1", table.copy(def))
  90. -- stage 2
  91. def.tiles = {"farming_pineapple_2.png"}
  92. minetest.register_node("farming:pineapple_2", table.copy(def))
  93. -- stage 3
  94. def.tiles = {"farming_pineapple_3.png"}
  95. minetest.register_node("farming:pineapple_3", table.copy(def))
  96. -- stage 4
  97. def.tiles = {"farming_pineapple_4.png"}
  98. minetest.register_node("farming:pineapple_4", table.copy(def))
  99. -- stage 5
  100. def.tiles = {"farming_pineapple_5.png"}
  101. minetest.register_node("farming:pineapple_5", table.copy(def))
  102. -- stage 6
  103. def.tiles = {"farming_pineapple_6.png"}
  104. minetest.register_node("farming:pineapple_6", table.copy(def))
  105. -- stage 7
  106. def.tiles = {"farming_pineapple_7.png"}
  107. minetest.register_node("farming:pineapple_7", table.copy(def))
  108. -- stage 8 (final)
  109. def.tiles = {"farming_pineapple_8.png"}
  110. def.groups.growing = nil
  111. def.selection_box = farming.select_final
  112. def.drop = {
  113. items = {
  114. {items = {"farming:pineapple"}, rarity = 1},
  115. {items = {"farming:pineapple"}, rarity = 2}
  116. }
  117. }
  118. minetest.register_node("farming:pineapple_8", table.copy(def))
  119. -- add to registered_plants
  120. farming.registered_plants["farming:pineapple"] = {
  121. crop = "farming:pineapple",
  122. seed = "farming:pineapple_top",
  123. minlight = farming.min_light,
  124. maxlight = farming.max_light,
  125. steps = 8
  126. }
  127. -- mapgen
  128. local mg = farming.mapgen == "v6"
  129. def = {
  130. grow_on = mg and {"default:dirt_with_grass"} or {"default:dirt_with_dry_grass",
  131. "default:dry_dirt_with_dry_grass"},
  132. grow_near = mg and "group:sand" or nil,
  133. num = mg and 1 or -1
  134. }
  135. minetest.register_decoration({
  136. deco_type = "simple",
  137. place_on = def.grow_on,
  138. sidelen = 16,
  139. noise_params = {
  140. offset = 0,
  141. scale = farming.pineapple,
  142. spread = {x = 100, y = 100, z = 100},
  143. seed = 354,
  144. octaves = 3,
  145. persist = 0.6
  146. },
  147. y_min = 11,
  148. y_max = 30,
  149. decoration = {"farming:pineapple_8"},
  150. spawn_by = def.grow_near,
  151. num_spawn_by = def.num
  152. })