carrot.lua 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. --[[
  2. Original textures from PixelBox texture pack
  3. https://forum.minetest.net/viewtopic.php?id=4990
  4. ]]
  5. local S = farming.intllib
  6. -- carrot
  7. minetest.register_craftitem("farming:carrot", {
  8. description = S("Carrot"),
  9. inventory_image = "farming_carrot.png",
  10. groups = {seed = 2, food_carrot = 1, flammable = 2},
  11. on_place = function(itemstack, placer, pointed_thing)
  12. return farming.place_seed(itemstack, placer, pointed_thing, "farming:carrot_1")
  13. end,
  14. on_use = minetest.item_eat(4),
  15. })
  16. -- golden carrot
  17. minetest.register_craftitem("farming:carrot_gold", {
  18. description = S("Golden Carrot"),
  19. inventory_image = "farming_carrot_gold.png",
  20. on_use = minetest.item_eat(6),
  21. })
  22. minetest.register_craft({
  23. output = "farming:carrot_gold",
  24. recipe = {
  25. {"", "default:gold_lump", ""},
  26. {"default:gold_lump", "group:food_carrot", "default:gold_lump"},
  27. {"", "default:gold_lump", ""},
  28. }
  29. })
  30. -- carrot definition
  31. local crop_def = {
  32. drawtype = "plantlike",
  33. tiles = {"farming_carrot_1.png"},
  34. paramtype = "light",
  35. sunlight_propagates = true,
  36. walkable = false,
  37. buildable_to = true,
  38. drop = "",
  39. selection_box = farming.select,
  40. groups = {
  41. snappy = 3, flammable = 2, plant = 1, attached_node = 1,
  42. not_in_creative_inventory = 1, growing = 1
  43. },
  44. sounds = default.node_sound_leaves_defaults()
  45. }
  46. -- stage 1
  47. minetest.register_node("farming:carrot_1", table.copy(crop_def))
  48. -- stage 2
  49. crop_def.tiles = {"farming_carrot_2.png"}
  50. minetest.register_node("farming:carrot_2", table.copy(crop_def))
  51. -- stage 3
  52. crop_def.tiles = {"farming_carrot_3.png"}
  53. minetest.register_node("farming:carrot_3", table.copy(crop_def))
  54. -- stage 4
  55. crop_def.tiles = {"farming_carrot_4.png"}
  56. minetest.register_node("farming:carrot_4", table.copy(crop_def))
  57. -- stage 5
  58. crop_def.tiles = {"farming_carrot_5.png"}
  59. minetest.register_node("farming:carrot_5", table.copy(crop_def))
  60. -- stage 6
  61. crop_def.tiles = {"farming_carrot_6.png"}
  62. minetest.register_node("farming:carrot_6", table.copy(crop_def))
  63. -- stage 7
  64. crop_def.tiles = {"farming_carrot_7.png"}
  65. crop_def.drop = {
  66. items = {
  67. {items = {"farming:carrot"}, rarity = 1},
  68. {items = {"farming:carrot 2"}, rarity = 3},
  69. }
  70. }
  71. minetest.register_node("farming:carrot_7", table.copy(crop_def))
  72. -- stage 8 (final)
  73. crop_def.tiles = {"farming_carrot_8.png"}
  74. crop_def.groups.growing = 0
  75. crop_def.drop = {
  76. items = {
  77. {items = {"farming:carrot 2"}, rarity = 1},
  78. {items = {"farming:carrot 3"}, rarity = 2},
  79. }
  80. }
  81. minetest.register_node("farming:carrot_8", table.copy(crop_def))
  82. -- add to registered_plants
  83. farming.registered_plants["farming:carrot"] = {
  84. crop = "farming:carrot",
  85. seed = "farming:carrot",
  86. minlight = 13,
  87. maxlight = 15,
  88. steps = 8
  89. }