init.lua 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. -- Adding a comment for junk'n'stuff.
  2. -- Another junk line.
  3. -- Yet another line full of junk.
  4. -- More trash.
  5. -- Localize for performance.
  6. local math_random = math.random
  7. -- This is both seed and edible fruit.
  8. minetest.register_node("blueberries:fruit", {
  9. description = "Blueberries",
  10. tiles = {"blueberries_blueberries.png"},
  11. wield_image = "blueberries_blueberries.png",
  12. inventory_image = "blueberries_blueberries.png",
  13. drawtype = "signlike",
  14. paramtype = "light",
  15. paramtype2 = "wallmounted",
  16. walkable = false,
  17. sunlight_propagates = true,
  18. selection_box = {
  19. type = "fixed",
  20. fixed = {-0.5, -0.5, -0.5, 0.5, -5/16, 0.5}
  21. },
  22. groups = utility.dig_groups("seeds", {seed = 1, attached_node = 1, flammable = 2, foodrot = 1, notify_destruct = 1}),
  23. on_place = function(itemstack, placer, pointed_thing)
  24. return farming.place_seed(itemstack, placer, pointed_thing, "blueberries:fruit")
  25. end,
  26. on_timer = farming.grow_plant,
  27. minlight = 13,
  28. maxlight = 15,
  29. _farming_next_plant = "blueberries:plant_1",
  30. fertility = {"grassland"},
  31. sounds = default.node_sound_dirt_defaults({
  32. dug = {name = "default_grass_footstep", gain = 0.2},
  33. place = {name = "default_place_node", gain = 0.25},
  34. }),
  35. on_use = minetest.item_eat(1),
  36. })
  37. -- blueberry muffin (thanks to sosogirl123 @ deviantart.com for muffin image)
  38. minetest.register_craftitem("blueberries:muffin", {
  39. description = "Blueberry Muffin",
  40. inventory_image = "blueberries_muffin.png",
  41. on_use = minetest.item_eat(2),
  42. groups = {foodrot=1},
  43. })
  44. minetest.register_craft({
  45. output = "blueberries:muffin 2",
  46. recipe = {
  47. {"blueberries:fruit", "farming:bread", "blueberries:fruit"},
  48. }
  49. })
  50. local crop_def = {
  51. drawtype = "plantlike",
  52. paramtype = "light",
  53. paramtype2 = "meshoptions",
  54. place_param2 = 2,
  55. sunlight_propagates = true,
  56. waving = 1,
  57. walkable = false,
  58. buildable_to = true,
  59. drop = "",
  60. selection_box = {
  61. type = "fixed",
  62. fixed = {-0.5, -0.5, -0.5, 0.5, -5/16, 0.5}
  63. },
  64. groups = utility.dig_groups("crop", {
  65. flammable = 2, plant = 1, attached_node = 1,
  66. not_in_creative_inventory = 1, notify_destruct = 1,
  67. }),
  68. sounds = default.node_sound_leaves_defaults(),
  69. on_timer = farming.grow_plant,
  70. minlight = 13,
  71. maxlight = default.LIGHT_MAX,
  72. movement_speed_multiplier = default.SLOW_SPEED_PLANTS,
  73. }
  74. crop_def._farming_next_plant = "blueberries:plant_2"
  75. crop_def._farming_prev_plant = "blueberries:plant_1" -- No "seed" node really.
  76. crop_def.tiles = {"blueberries_plant_1.png"}
  77. minetest.register_node("blueberries:plant_1", table.copy(crop_def))
  78. crop_def.description = "Blueberry Bush"
  79. crop_def.inventory_image = "blueberries_plant_2.png"
  80. crop_def._farming_next_plant = "blueberries:plant_3"
  81. crop_def._farming_prev_plant = "blueberries:plant_1"
  82. crop_def.tiles = {"blueberries_plant_2.png"}
  83. crop_def.after_dig_node =
  84. function(pos, oldnode, oldmetadata, digger)
  85. if digger and digger:is_player() then
  86. local wielditem = digger:get_wielded_item()
  87. if string.find(wielditem:get_name(), "shovel") then
  88. -- If player digs with a shovel, then the bush is removed.
  89. -- The player gets 1 bush, which can be used for decoration.
  90. local inv = digger:get_inventory()
  91. local leftover = inv:add_item("main", ItemStack(oldnode.name))
  92. minetest.add_item(pos, leftover)
  93. else
  94. -- Restore bush. Player did not actually dig it up.
  95. minetest.after(0, function()
  96. minetest.set_node(pos, {name="blueberries:plant_2", param2=2})
  97. local timer = minetest.get_node_timer(pos)
  98. timer:start(math_random(300, 700))
  99. end)
  100. end
  101. end
  102. end
  103. minetest.register_node("blueberries:plant_2", table.copy(crop_def))
  104. crop_def.description = "Blueberry Bush with Blossoms"
  105. crop_def.inventory_image = "blueberries_plant_3.png"
  106. crop_def._farming_next_plant = "blueberries:plant_4"
  107. crop_def._farming_prev_plant = "blueberries:plant_2"
  108. crop_def.tiles = {"blueberries_plant_3.png"}
  109. minetest.register_node("blueberries:plant_3", table.copy(crop_def))
  110. crop_def.description = "Blueberry Bush with Blueberries"
  111. crop_def.inventory_image = "blueberries_plant_4.png"
  112. crop_def._farming_next_plant = nil
  113. crop_def._farming_prev_plant = "blueberries:plant_3"
  114. crop_def.tiles = {"blueberries_plant_4.png"}
  115. crop_def.after_dig_node =
  116. function(pos, oldnode, oldmetadata, digger)
  117. if digger and digger:is_player() then
  118. local wielditem = digger:get_wielded_item()
  119. if string.find(wielditem:get_name(), "shovel") then
  120. -- If player digs with a shovel, then the bush is removed.
  121. -- The player gets 1 bush, which can be used for decoration.
  122. local inv = digger:get_inventory()
  123. local leftover = inv:add_item("main", ItemStack("blueberries:plant_4"))
  124. minetest.add_item(pos, leftover)
  125. else
  126. local inv = digger:get_inventory()
  127. local leftover = inv:add_item("main", ItemStack("blueberries:fruit " .. math_random(1, 5)))
  128. minetest.add_item(pos, leftover)
  129. -- Restore bush. Player did not actually dig it up.
  130. minetest.after(0, function()
  131. minetest.set_node(pos, {name="blueberries:plant_2", param2=2})
  132. local timer = minetest.get_node_timer(pos)
  133. timer:start(math_random(300, 700))
  134. end)
  135. end
  136. end
  137. end
  138. minetest.register_node("blueberries:plant_4", table.copy(crop_def))