onion.lua 2.4 KB

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