onion.lua 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. --[[
  2. Original textures from Crops Plus mod
  3. Copyright (C) 2018 Grizzly Adam
  4. https://forum.minetest.net/viewtopic.php?f=9&t=19488
  5. ]]
  6. local S = farming.translate
  7. -- onion
  8. minetest.register_craftitem("farming:onion", {
  9. description = S("Onion"),
  10. inventory_image = "crops_onion.png",
  11. groups = {compostability = 48, seed = 2, food_onion = 1, flammable = 3},
  12. on_place = function(itemstack, placer, pointed_thing)
  13. return farming.place_seed(itemstack, placer, pointed_thing, "farming:onion_1")
  14. end,
  15. on_use = minetest.item_eat(1)
  16. })
  17. -- onion soup
  18. minetest.register_craftitem("farming:onion_soup", {
  19. description = S("Onion Soup"),
  20. inventory_image = "farming_onion_soup.png",
  21. groups = {flammable = 2},
  22. on_use = minetest.item_eat(6, "farming:bowl")
  23. })
  24. local tmp = farming.use_utensils and "farming:pot" or ""
  25. minetest.register_craft({
  26. output = "farming:onion_soup",
  27. recipe = {
  28. {"group:food_onion", "group:food_onion", "group:food_onion"},
  29. {"group:food_onion", "group:food_bowl", "group:food_onion"},
  30. {"", tmp, ""}
  31. },
  32. replacements = {{"farming:pot", "farming:pot"}}
  33. })
  34. -- yellow dye
  35. minetest.register_craft({
  36. output = farming.mcl and "mcl_dye:yellow" or "dye:yellow",
  37. recipe = {{"group:food_onion"}}
  38. })
  39. -- crop definition
  40. local def = {
  41. drawtype = "plantlike",
  42. tiles = {"crops_onion_plant_1.png"},
  43. paramtype = "light",
  44. paramtype2 = "meshoptions",
  45. place_param2 = 3,
  46. sunlight_propagates = true,
  47. waving = 1,
  48. walkable = false,
  49. buildable_to = true,
  50. drop = "",
  51. waving = 1,
  52. selection_box = farming.select,
  53. groups = {
  54. handy = 1, snappy = 3, flammable = 3, plant = 1, attached_node = 1,
  55. not_in_creative_inventory = 1, growing = 1
  56. },
  57. sounds = farming.sounds.node_sound_leaves_defaults()
  58. }
  59. -- stage 1
  60. minetest.register_node("farming:onion_1", table.copy(def))
  61. -- stage 2
  62. def.tiles = {"crops_onion_plant_2.png"}
  63. minetest.register_node("farming:onion_2", table.copy(def))
  64. -- stage 3
  65. def.tiles = {"crops_onion_plant_3.png"}
  66. minetest.register_node("farming:onion_3", table.copy(def))
  67. -- stage 4
  68. def.tiles = {"crops_onion_plant_4.png"}
  69. minetest.register_node("farming:onion_4", table.copy(def))
  70. -- stage 5
  71. def.tiles = {"crops_onion_plant_5.png"}
  72. def.groups.growing = nil
  73. def.selection_box = farming.select_final
  74. def.drop = {
  75. max_items = 5, items = {
  76. {items = {"farming:onion"}, rarity = 1},
  77. {items = {"farming:onion"}, rarity = 1},
  78. {items = {"farming:onion"}, rarity = 2},
  79. {items = {"farming:onion"}, rarity = 2},
  80. {items = {"farming:onion"}, rarity = 5}
  81. }
  82. }
  83. minetest.register_node("farming:onion_5", table.copy(def))
  84. -- add to registered_plants
  85. farming.registered_plants["farming:onion"] = {
  86. crop = "farming:onion",
  87. seed = "farming:onion",
  88. minlight = farming.min_light,
  89. maxlight = farming.max_light,
  90. steps = 5
  91. }
  92. -- mapgen
  93. minetest.register_decoration({
  94. deco_type = "simple",
  95. place_on = {"mcl_core:dirt_with_grass, default:dirt_with_grass"},
  96. sidelen = 16,
  97. noise_params = {
  98. offset = 0,
  99. scale = farming.onion,
  100. spread = {x = 100, y = 100, z = 100},
  101. seed = 912,
  102. octaves = 3,
  103. persist = 0.6
  104. },
  105. y_min = 5,
  106. y_max = 28,
  107. decoration = "farming:onion_5"
  108. })