init.lua 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  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. _farming_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. -- Definitely not something you wanna eat.
  37. -- Gives back a bunch of health, but takes some of that away again over time via poison.
  38. -- Use with care!
  39. local eat_func2 = hunger.item_eat(0, nil, 10)
  40. minetest.register_craftitem("carrot:gold", {
  41. description = "Golden Carrot",
  42. inventory_image = "carrot_gold.png",
  43. -- Give user 1/4 energy, health back.
  44. on_use = function(itemstack, user, pointed_thing)
  45. if not user or not user:is_player() then return end
  46. local hp_max = pova.get_active_modifier(user, "properties").hp_max
  47. user:set_hp(user:get_hp() + (hp_max / 2))
  48. sprint.add_stamina(user, (SPRINT_STAMINA / 4))
  49. return eat_func2(itemstack, user, pointed_thing)
  50. end,
  51. })
  52. minetest.register_craft({
  53. output = "carrot:gold",
  54. type = "shapeless",
  55. recipe = {"default:gold_lump", "carrot:regular"},
  56. })
  57. local eat_function = minetest.item_eat(6, "vessels:drinking_glass")
  58. minetest.register_craftitem("carrot:health_boost_drink", {
  59. description = "Apple Carrot Juice\n\nBoosts current and max HP beyond normal for a short time.",
  60. inventory_image = "farming_carrot_juice_boost.png",
  61. on_use = function(itemstack, user, pointed_thing)
  62. if not user or not user:is_player() then return end
  63. -- Health boost drink.
  64. hunger.apply_health_boost(user:get_player_name(), "drink", {health=30*500, time=30})
  65. return eat_function(itemstack, user, pointed_thing)
  66. end,
  67. })
  68. minetest.register_craft({
  69. output = "carrot:health_boost_drink",
  70. type = "shapeless",
  71. recipe = {
  72. "vessels:drinking_glass", "carrot:regular", "farming:juicer",
  73. "basictrees:tree_apple",
  74. },
  75. replacements = {
  76. {"farming:juicer", "farming:juicer"},
  77. },
  78. })
  79. local crop_def = {
  80. drawtype = "plantlike",
  81. tiles = {"carrot_plant_1.png"},
  82. paramtype = "light",
  83. sunlight_propagates = true,
  84. waving = 1,
  85. walkable = false,
  86. buildable_to = true,
  87. drop = "",
  88. selection_box = {
  89. type = "fixed",
  90. fixed = {-0.5, -0.5, -0.5, 0.5, -5/16, 0.5}
  91. },
  92. groups = utility.dig_groups("crop", {
  93. flammable = 2, plant = 1, attached_node = 1,
  94. not_in_creative_inventory = 1, notify_destruct = 1,
  95. }),
  96. sounds = default.node_sound_leaves_defaults(),
  97. on_timer = farming.grow_plant,
  98. minlight = 13,
  99. maxlight = default.LIGHT_MAX,
  100. movement_speed_multiplier = default.SLOW_SPEED_PLANTS,
  101. flowerpot_drop = "carrot:regular",
  102. }
  103. crop_def._farming_next_plant = "carrot:plant_2"
  104. crop_def._farming_prev_seed = "carrot:seed"
  105. minetest.register_node("carrot:plant_1", table.copy(crop_def))
  106. crop_def._farming_next_plant = "carrot:plant_3"
  107. crop_def._farming_prev_plant = "carrot:plant_1"
  108. crop_def.tiles = {"carrot_plant_2.png"}
  109. minetest.register_node("carrot:plant_2", table.copy(crop_def))
  110. crop_def._farming_next_plant = "carrot:plant_4"
  111. crop_def._farming_prev_plant = "carrot:plant_2"
  112. crop_def.tiles = {"carrot_plant_3.png"}
  113. minetest.register_node("carrot:plant_3", table.copy(crop_def))
  114. crop_def._farming_next_plant = "carrot:plant_5"
  115. crop_def._farming_prev_plant = "carrot:plant_3"
  116. crop_def.tiles = {"carrot_plant_4.png"}
  117. minetest.register_node("carrot:plant_4", table.copy(crop_def))
  118. crop_def._farming_next_plant = "carrot:plant_6"
  119. crop_def._farming_prev_plant = "carrot:plant_4"
  120. crop_def.tiles = {"carrot_plant_5.png"}
  121. minetest.register_node("carrot:plant_5", table.copy(crop_def))
  122. crop_def._farming_next_plant = "carrot:plant_7"
  123. crop_def._farming_prev_plant = "carrot:plant_5"
  124. crop_def.tiles = {"carrot_plant_6.png"}
  125. minetest.register_node("carrot:plant_6", table.copy(crop_def))
  126. crop_def._farming_next_plant = "carrot:plant_8"
  127. crop_def._farming_prev_plant = "carrot:plant_6"
  128. crop_def.tiles = {"carrot_plant_7.png"}
  129. minetest.register_node("carrot:plant_7", table.copy(crop_def))
  130. crop_def.tiles = {"carrot_plant_8.png"}
  131. crop_def.drop = {
  132. items = {
  133. {items = {"carrot:regular"}, rarity = 1},
  134. {items = {"carrot:gold"}, rarity = 100},
  135. {items = {"carrot:seed"}, rarity = 1},
  136. {items = {"carrot:seed"}, rarity = 2},
  137. {items = {"carrot:seed 2"}, rarity = 3},
  138. }
  139. }
  140. crop_def._farming_next_plant = nil
  141. crop_def._farming_prev_plant = "carrot:plant_7"
  142. minetest.register_node("carrot:plant_8", table.copy(crop_def))