onion.lua 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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. -- potato
  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. -- crop definition
  18. local crop_def = {
  19. drawtype = "plantlike",
  20. tiles = {"crops_onion_plant_1.png"},
  21. paramtype = "light",
  22. paramtype2 = "meshoptions",
  23. place_param2 = 3,
  24. sunlight_propagates = true,
  25. waving = 1,
  26. walkable = false,
  27. buildable_to = true,
  28. drop = "",
  29. selection_box = farming.select,
  30. groups = {
  31. snappy = 3, flammable = 3, plant = 1, attached_node = 1,
  32. not_in_creative_inventory = 1, growing = 1
  33. },
  34. sounds = default.node_sound_leaves_defaults()
  35. }
  36. -- stage 1
  37. minetest.register_node("farming:onion_1", table.copy(crop_def))
  38. -- stage 2
  39. crop_def.tiles = {"crops_onion_plant_2.png"}
  40. minetest.register_node("farming:onion_2", table.copy(crop_def))
  41. -- stage 3
  42. crop_def.tiles = {"crops_onion_plant_3.png"}
  43. minetest.register_node("farming:onion_3", table.copy(crop_def))
  44. -- stage 4
  45. crop_def.tiles = {"crops_onion_plant_4.png"}
  46. minetest.register_node("farming:onion_4", table.copy(crop_def))
  47. -- stage 5
  48. crop_def.tiles = {"crops_onion_plant_5.png"}
  49. crop_def.groups.growing = 0
  50. crop_def.drop = {
  51. max_items = 5, items = {
  52. {items = {"farming:onion"}, rarity = 1},
  53. {items = {"farming:onion"}, rarity = 1},
  54. {items = {"farming:onion"}, rarity = 2},
  55. {items = {"farming:onion"}, rarity = 2},
  56. {items = {"farming:onion"}, rarity = 5},
  57. }
  58. }
  59. minetest.register_node("farming:onion_5", table.copy(crop_def))
  60. -- add to registered_plants
  61. farming.registered_plants["farming:onion"] = {
  62. crop = "farming:onion",
  63. seed = "farming:onion",
  64. minlight = 13,
  65. maxlight = 15,
  66. steps = 5
  67. }