init.lua 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. minetest.register_node("carrot:seed", {
  2. description = "Carrot Seed",
  3. tiles = {"carrot_seed.png"},
  4. wield_image = "carrot_seed.png",
  5. inventory_image = "carrot_seed.png",
  6. drawtype = "signlike",
  7. paramtype = "light",
  8. paramtype2 = "wallmounted",
  9. walkable = false,
  10. sunlight_propagates = true,
  11. selection_box = {
  12. type = "fixed",
  13. fixed = {-0.5, -0.5, -0.5, 0.5, -5/16, 0.5}
  14. },
  15. groups = utility.dig_groups("seeds", {seed = 1, seed_oil = 1, attached_node = 1, flammable = 2, notify_destruct = 1}),
  16. on_place = function(itemstack, placer, pointed_thing)
  17. return farming.place_seed(itemstack, placer, pointed_thing, "carrot:seed")
  18. end,
  19. on_timer = farming.grow_plant,
  20. minlight = 13,
  21. maxlight = 15,
  22. next_plant = "carrot:plant_1",
  23. fertility = {"grassland"},
  24. sounds = default.node_sound_dirt_defaults({
  25. dug = {name = "default_grass_footstep", gain = 0.2},
  26. place = {name = "default_place_node", gain = 0.25},
  27. }),
  28. })
  29. -- Edible!
  30. minetest.register_craftitem("carrot:regular", {
  31. description = "Carrot",
  32. inventory_image = "carrot_regular.png",
  33. on_use = minetest.item_eat(1),
  34. flowerpot_insert = {"carrot:plant_1", "carrot:plant_2", "carrot:plant_3", "carrot:plant_4", "carrot:plant_5", "carrot:plant_6", "carrot:plant_7", "carrot:plant_8"},
  35. })
  36. -- Edible!
  37. local eat_function = minetest.item_eat(6)
  38. minetest.register_craftitem("carrot:gold", {
  39. description = "Golden Carrot",
  40. inventory_image = "carrot_gold.png",
  41. on_use = function(itemstack, user, pointed_thing)
  42. if not user or not user:is_player() then return end
  43. --ambiance.sound_play("hunger_eat", user:getpos(), 0.7, 10)
  44. user:set_hp(user:get_properties().hp_max)
  45. sprint.set_stamina(user, SPRINT_STAMINA)
  46. return eat_function(itemstack, user, pointed_thing)
  47. end,
  48. })
  49. minetest.register_craft({
  50. output = "carrot:gold",
  51. recipe = {
  52. {"", "default:gold_lump", ""},
  53. {"default:gold_lump", "carrot:regular", "default:gold_lump"},
  54. {"", "default:gold_lump", ""},
  55. },
  56. })
  57. local crop_def = {
  58. drawtype = "plantlike",
  59. tiles = {"carrot_plant_1.png"},
  60. paramtype = "light",
  61. sunlight_propagates = true,
  62. waving = 1,
  63. walkable = false,
  64. buildable_to = true,
  65. drop = "",
  66. selection_box = {
  67. type = "fixed",
  68. fixed = {-0.5, -0.5, -0.5, 0.5, -5/16, 0.5}
  69. },
  70. groups = utility.dig_groups("crop", {
  71. flammable = 2, plant = 1, attached_node = 1,
  72. not_in_creative_inventory = 1, notify_destruct = 1,
  73. }),
  74. sounds = default.node_sound_leaves_defaults(),
  75. on_timer = farming.grow_plant,
  76. minlight = 13,
  77. maxlight = default.LIGHT_MAX,
  78. movement_speed_multiplier = default.SLOW_SPEED_PLANTS,
  79. flowerpot_drop = "carrot:regular",
  80. }
  81. crop_def.next_plant = "carrot:plant_2"
  82. minetest.register_node("carrot:plant_1", table.copy(crop_def))
  83. crop_def.next_plant = "carrot:plant_3"
  84. crop_def.tiles = {"carrot_plant_2.png"}
  85. minetest.register_node("carrot:plant_2", table.copy(crop_def))
  86. crop_def.next_plant = "carrot:plant_4"
  87. crop_def.tiles = {"carrot_plant_3.png"}
  88. minetest.register_node("carrot:plant_3", table.copy(crop_def))
  89. crop_def.next_plant = "carrot:plant_5"
  90. crop_def.tiles = {"carrot_plant_4.png"}
  91. minetest.register_node("carrot:plant_4", table.copy(crop_def))
  92. crop_def.next_plant = "carrot:plant_6"
  93. crop_def.tiles = {"carrot_plant_5.png"}
  94. minetest.register_node("carrot:plant_5", table.copy(crop_def))
  95. crop_def.next_plant = "carrot:plant_7"
  96. crop_def.tiles = {"carrot_plant_6.png"}
  97. minetest.register_node("carrot:plant_6", table.copy(crop_def))
  98. crop_def.next_plant = "carrot:plant_8"
  99. crop_def.tiles = {"carrot_plant_7.png"}
  100. minetest.register_node("carrot:plant_7", table.copy(crop_def))
  101. crop_def.tiles = {"carrot_plant_8.png"}
  102. crop_def.drop = {
  103. items = {
  104. {items = {"carrot:regular"}, rarity = 1},
  105. {items = {"carrot:gold"}, rarity = 100},
  106. {items = {"carrot:seed"}, rarity = 1},
  107. {items = {"carrot:seed"}, rarity = 2},
  108. {items = {"carrot:seed 2"}, rarity = 3},
  109. }
  110. }
  111. crop_def.next_plant = nil
  112. minetest.register_node("carrot:plant_8", table.copy(crop_def))