strawberry.lua 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. local S = ethereal.intllib
  2. -- Strawberry (can also be planted as seed)
  3. minetest.register_craftitem("ethereal:strawberry", {
  4. description = S("Strawberry"),
  5. inventory_image = "strawberry.png",
  6. wield_image = "strawberry.png",
  7. groups = {food_strawberry = 1, food_berry = 1, flammable = 2},
  8. on_place = function(itemstack, placer, pointed_thing)
  9. return farming.place_seed(itemstack, placer, pointed_thing, "ethereal:strawberry_1")
  10. end,
  11. on_use = minetest.item_eat(1),
  12. })
  13. -- Define Strawberry Bush growth stages
  14. local crop_def = {
  15. drawtype = "plantlike",
  16. tiles = {"strawberry_1.png"},
  17. paramtype = "light",
  18. sunlight_propagates = true,
  19. waving = 1,
  20. walkable = false,
  21. buildable_to = true,
  22. drop = "",
  23. selection_box = {
  24. type = "fixed",
  25. fixed = {-0.5, -0.5, -0.5, 0.5, -5/16, 0.5}
  26. },
  27. groups = {
  28. snappy = 3, flammable = 2, plant = 1, attached_node = 1,
  29. not_in_creative_inventory = 1, growing = 1
  30. },
  31. sounds = default.node_sound_leaves_defaults(),
  32. }
  33. --stage 1
  34. minetest.register_node("ethereal:strawberry_1", table.copy(crop_def))
  35. -- stage 2
  36. crop_def.tiles = {"strawberry_2.png"}
  37. minetest.register_node("ethereal:strawberry_2", table.copy(crop_def))
  38. -- stage 3
  39. crop_def.tiles = {"strawberry_3.png"}
  40. minetest.register_node("ethereal:strawberry_3", table.copy(crop_def))
  41. -- stage 4
  42. crop_def.tiles = {"strawberry_4.png"}
  43. minetest.register_node("ethereal:strawberry_4", table.copy(crop_def))
  44. -- stage 5
  45. crop_def.tiles = {"strawberry_5.png"}
  46. minetest.register_node("ethereal:strawberry_5", table.copy(crop_def))
  47. -- stage 6
  48. crop_def.tiles = {"strawberry_6.png"}
  49. crop_def.drop = {
  50. items = {
  51. {items = {"ethereal:strawberry 1"},rarity = 2},
  52. {items = {"ethereal:strawberry 2"},rarity = 3},
  53. }
  54. }
  55. minetest.register_node("ethereal:strawberry_6", table.copy(crop_def))
  56. -- stage 7
  57. crop_def.tiles = {"strawberry_7.png"}
  58. crop_def.drop = {
  59. items = {
  60. {items = {"ethereal:strawberry 1"},rarity = 1},
  61. {items = {"ethereal:strawberry 2"},rarity = 3},
  62. }
  63. }
  64. minetest.register_node("ethereal:strawberry_7", table.copy(crop_def))
  65. -- stage 8
  66. crop_def.tiles = {"strawberry_8.png"}
  67. crop_def.groups.growing = 0
  68. crop_def.drop = {
  69. items = {
  70. {items = {"ethereal:strawberry 2"},rarity = 1},
  71. {items = {"ethereal:strawberry 3"},rarity = 3},
  72. }
  73. }
  74. minetest.register_node("ethereal:strawberry_8", table.copy(crop_def))
  75. -- growing routine if farming redo isn't present
  76. if not farming or not farming.mod or farming.mod ~= "redo" then
  77. minetest.register_abm({
  78. label = "Ethereal grow strawberry",
  79. nodenames = {
  80. "ethereal:strawberry_1", "ethereal:strawberry_2", "ethereal:strawberry_3",
  81. "ethereal:strawberry_4", "ethereal:strawberry_5", "ethereal:strawberry_6",
  82. "ethereal:strawberry_7"
  83. },
  84. neighbors = {"farming:soil_wet"},
  85. interval = 9,
  86. chance = 20,
  87. catch_up = false,
  88. action = function(pos, node)
  89. -- are we on wet soil?
  90. pos.y = pos.y - 1
  91. if minetest.get_item_group(minetest.get_node(pos).name, "soil") < 3 then
  92. return
  93. end
  94. pos.y = pos.y + 1
  95. -- do we have enough light?
  96. local light = minetest.get_node_light(pos)
  97. if not light
  98. or light < 13 then
  99. return
  100. end
  101. -- grow to next stage
  102. local num = node.name:split("_")[2]
  103. node.name = "ethereal:strawberry_" .. tonumber(num + 1)
  104. minetest.swap_node(pos, node)
  105. end
  106. })
  107. end -- END IF