onion.lua 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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.intllib
  7. -- onion
  8. minetest.register_craftitem("farming:onion", {
  9. description = S("Onion"),
  10. inventory_image = "crops_onion.png",
  11. groups = {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. minetest.register_craft({
  25. output = "farming:onion_soup",
  26. recipe = {
  27. {"group:food_onion", "group:food_onion", "group:food_onion"},
  28. {"group:food_onion", "group:food_pot", "group:food_onion"},
  29. {"", "group:food_bowl", ""}
  30. },
  31. replacements = {{"farming:pot", "farming:pot"}}
  32. })
  33. -- crop definition
  34. local def = {
  35. drawtype = "plantlike",
  36. tiles = {"crops_onion_plant_1.png"},
  37. paramtype = "light",
  38. paramtype2 = "meshoptions",
  39. place_param2 = 3,
  40. sunlight_propagates = true,
  41. waving = 1,
  42. walkable = false,
  43. buildable_to = true,
  44. drop = "",
  45. selection_box = farming.select,
  46. groups = {
  47. snappy = 3, flammable = 3, plant = 1, attached_node = 1,
  48. not_in_creative_inventory = 1, growing = 1
  49. },
  50. sounds = default.node_sound_leaves_defaults()
  51. }
  52. -- stage 1
  53. minetest.register_node("farming:onion_1", table.copy(def))
  54. -- stage 2
  55. def.tiles = {"crops_onion_plant_2.png"}
  56. minetest.register_node("farming:onion_2", table.copy(def))
  57. -- stage 3
  58. def.tiles = {"crops_onion_plant_3.png"}
  59. minetest.register_node("farming:onion_3", table.copy(def))
  60. -- stage 4
  61. def.tiles = {"crops_onion_plant_4.png"}
  62. minetest.register_node("farming:onion_4", table.copy(def))
  63. -- stage 5
  64. def.tiles = {"crops_onion_plant_5.png"}
  65. def.groups.growing = nil
  66. def.drop = {
  67. max_items = 5, items = {
  68. {items = {"farming:onion"}, rarity = 1},
  69. {items = {"farming:onion"}, rarity = 1},
  70. {items = {"farming:onion"}, rarity = 2},
  71. {items = {"farming:onion"}, rarity = 2},
  72. {items = {"farming:onion"}, rarity = 5}
  73. }
  74. }
  75. minetest.register_node("farming:onion_5", table.copy(def))
  76. -- add to registered_plants
  77. farming.registered_plants["farming:onion"] = {
  78. crop = "farming:onion",
  79. seed = "farming:onion",
  80. minlight = farming.min_light,
  81. maxlight = farming.max_light,
  82. steps = 5
  83. }