init.lua 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. local S = function(s)
  2. return s
  3. end
  4. minetest.register_node("onions:seed", {
  5. description = "Allium Seeds",
  6. tiles = {"allium_seeds.png"},
  7. wield_image = "allium_seeds.png",
  8. inventory_image = "allium_seeds.png",
  9. drawtype = "signlike",
  10. paramtype = "light",
  11. paramtype2 = "wallmounted",
  12. walkable = false,
  13. sunlight_propagates = true,
  14. selection_box = {
  15. type = "fixed",
  16. fixed = {-0.5, -0.5, -0.5, 0.5, -5/16, 0.5}
  17. },
  18. groups = utility.dig_groups("seeds", {seed = 1, seed_oil = 1, attached_node = 1, flammable = 2, notify_destruct = 1}),
  19. on_place = function(itemstack, placer, pointed_thing)
  20. return farming.place_seed(itemstack, placer, pointed_thing, "onions:seed")
  21. end,
  22. on_timer = farming.grow_plant,
  23. minlight = 13,
  24. maxlight = 15,
  25. _farming_next_plant = "onions:allium_sprouts_1",
  26. fertility = {"grassland"},
  27. sounds = default.node_sound_dirt_defaults({
  28. dug = {name = "default_grass_footstep", gain = 0.2},
  29. place = {name = "default_place_node", gain = 0.25},
  30. }),
  31. })
  32. -- onion
  33. minetest.register_craftitem("onions:onion", {
  34. description = S("Wild Onion"),
  35. inventory_image = "wild_onion.png",
  36. on_use = minetest.item_eat(2),
  37. groups = {foodrot=1},
  38. flowerpot_insert = {
  39. "onions:allium_sprouts_1", "onions:allium_sprouts_2", "onions:allium_sprouts_3", "onions:allium_sprouts_4",},
  40. })
  41. -- sauteed onions
  42. minetest.register_craftitem("onions:sauteed_onions", {
  43. description = S("Sauteed Onions"),
  44. inventory_image = "sauteed_onions.png",
  45. on_use = minetest.item_eat(4),
  46. groups = {foodrot=1},
  47. })
  48. minetest.register_craft({
  49. type = "cooking",
  50. cooktime = 10,
  51. output = "onions:sauteed_onions",
  52. recipe = "onions:onion"
  53. })
  54. -- onion_potato salad recipe
  55. local eat_function = minetest.item_eat(10, "xdecor:bowl")
  56. minetest.register_craftitem("onions:onion_potato_salad", {
  57. description = "Potato And Wild Onion Salad\n\nBoosts current and max HP beyond normal for a short time.",
  58. inventory_image = "onion_potato_salad.png",
  59. on_use = function(itemstack, user, pointed_thing)
  60. if not user or not user:is_player() then return end
  61. hunger.apply_health_boost(user:get_player_name(), "onions", {health=30*500, time=30})
  62. return eat_function(itemstack, user, pointed_thing)
  63. end,
  64. })
  65. minetest.register_craft({
  66. output = "onions:onion_potato_salad",
  67. recipe = {
  68. {"onions:onion"},
  69. {"potatoes:baked_potato"},
  70. {"xdecor:bowl"},
  71. }
  72. })
  73. -- onion definition
  74. local crop_def = {
  75. drawtype = "plantlike",
  76. tiles = {"allium_sprouts1.png"},
  77. paramtype = "light",
  78. sunlight_propagates = true,
  79. waving = 1,
  80. walkable = false,
  81. buildable_to = true,
  82. drop = "",
  83. selection_box = {
  84. type = "fixed",
  85. fixed = {-0.5, -0.5, -0.5, 0.5, -5/16, 0.5}
  86. },
  87. groups = utility.dig_groups("crop", {
  88. flammable = 2, plant = 1, attached_node = 1,
  89. not_in_creative_inventory = 1, growing = 1, notify_destruct = 1,
  90. }),
  91. sounds = default.node_sound_leaves_defaults(),
  92. on_timer = farming.grow_plant,
  93. minlight = 13,
  94. maxlight = default.LIGHT_MAX,
  95. movement_speed_multiplier = default.SLOW_SPEED_PLANTS,
  96. flowerpot_drop = "onions:onion",
  97. }
  98. -- stage 1
  99. crop_def._farming_next_plant = "onions:allium_sprouts_2"
  100. crop_def._farming_prev_seed = "onions:seed"
  101. minetest.register_node("onions:allium_sprouts_1", table.copy(crop_def))
  102. -- stage 2
  103. crop_def._farming_next_plant = "onions:allium_sprouts_3"
  104. crop_def._farming_prev_plant = "onions:allium_sprouts_1"
  105. crop_def.tiles = {"allium_sprouts2.png"}
  106. minetest.register_node("onions:allium_sprouts_2", table.copy(crop_def))
  107. -- stage 3
  108. crop_def._farming_next_plant = "onions:allium_sprouts_4"
  109. crop_def._farming_prev_plant = "onions:allium_sprouts_2"
  110. crop_def.tiles = {"allium_sprouts3.png"}
  111. crop_def.drop = {
  112. items = {
  113. {items = {'onions:onion'}, rarity = 1},
  114. {items = {'onions:onion'}, rarity = 3},
  115. }
  116. }
  117. minetest.register_node("onions:allium_sprouts_3", table.copy(crop_def))
  118. -- stage 4
  119. crop_def._farming_next_plant = nil
  120. crop_def._farming_prev_plant = "onions:allium_sprouts_3"
  121. crop_def.tiles = {"allium_sprouts4.png"}
  122. crop_def.groups.growing = 0
  123. crop_def.drop = {
  124. items = {
  125. {items = {'onions:onion'}, rarity = 1},
  126. {items = {'onions:onion 3'}, rarity = 3},
  127. {items = {'onions:seed'}, rarity = 1},
  128. {items = {'onions:seed'}, rarity = 2},
  129. }
  130. }
  131. minetest.register_node("onions:allium_sprouts_4", table.copy(crop_def))
  132. -- Some aliases for old item names.
  133. minetest.register_alias("farming:onion_potato_salad", "onions:onion_potato_salad")
  134. minetest.register_alias("onions:suateed_onions", "onions:sauteed_onions")