init.lua 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  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, 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. 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. minetest.register_craftitem("onions:onion_potato_salad", {
  56. description = "Potato And Wild Onion Salad",
  57. inventory_image = "onion_potato_salad.png",
  58. on_use = minetest.item_eat(10, "xdecor:bowl"),
  59. })
  60. minetest.register_craft({
  61. output = "onions:onion_potato_salad",
  62. recipe = {
  63. {"onions:onion"},
  64. {"potatoes:baked_potato"},
  65. {"xdecor:bowl"},
  66. }
  67. })
  68. -- onion definition
  69. local crop_def = {
  70. drawtype = "plantlike",
  71. tiles = {"allium_sprouts1.png"},
  72. paramtype = "light",
  73. sunlight_propagates = true,
  74. waving = 1,
  75. walkable = false,
  76. buildable_to = true,
  77. drop = "",
  78. selection_box = {
  79. type = "fixed",
  80. fixed = {-0.5, -0.5, -0.5, 0.5, -5/16, 0.5}
  81. },
  82. groups = utility.dig_groups("crop", {
  83. flammable = 2, plant = 1, attached_node = 1,
  84. not_in_creative_inventory = 1, growing = 1, notify_destruct = 1,
  85. }),
  86. sounds = default.node_sound_leaves_defaults(),
  87. on_timer = farming.grow_plant,
  88. minlight = 13,
  89. maxlight = default.LIGHT_MAX,
  90. movement_speed_multiplier = default.SLOW_SPEED_PLANTS,
  91. flowerpot_drop = "onions:onion",
  92. }
  93. -- stage 1
  94. crop_def.next_plant = "onions:allium_sprouts_2"
  95. minetest.register_node("onions:allium_sprouts_1", table.copy(crop_def))
  96. -- stage 2
  97. crop_def.next_plant = "onions:allium_sprouts_3"
  98. crop_def.tiles = {"allium_sprouts2.png"}
  99. minetest.register_node("onions:allium_sprouts_2", table.copy(crop_def))
  100. -- stage 3
  101. crop_def.next_plant = "onions:allium_sprouts_4"
  102. crop_def.tiles = {"allium_sprouts3.png"}
  103. crop_def.drop = {
  104. items = {
  105. {items = {'onions:onion'}, rarity = 1},
  106. {items = {'onions:onion'}, rarity = 3},
  107. }
  108. }
  109. minetest.register_node("onions:allium_sprouts_3", table.copy(crop_def))
  110. -- stage 4
  111. crop_def.next_plant = nil
  112. crop_def.tiles = {"allium_sprouts4.png"}
  113. crop_def.groups.growing = 0
  114. crop_def.drop = {
  115. items = {
  116. {items = {'onions:onion'}, rarity = 1},
  117. {items = {'onions:onion 3'}, rarity = 3},
  118. {items = {'onions:seed'}, rarity = 1},
  119. {items = {'onions:seed'}, rarity = 2},
  120. }
  121. }
  122. minetest.register_node("onions:allium_sprouts_4", table.copy(crop_def))
  123. -- Some aliases for old item names.
  124. minetest.register_alias("farming:onion_potato_salad", "onions:onion_potato_salad")
  125. minetest.register_alias("onions:suateed_onions", "onions:sauteed_onions")