init.lua 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. minetest.register_node("tomato:seed", {
  2. description = "Tomato Seed",
  3. tiles = {"tomato_seed.png"},
  4. wield_image = "tomato_seed.png",
  5. inventory_image = "tomato_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, "tomato:seed")
  18. end,
  19. on_timer = farming.grow_plant,
  20. minlight = 13,
  21. maxlight = 15,
  22. _farming_next_plant = "tomato: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("tomato:tomato", {
  31. description = "Ripe Tomato",
  32. inventory_image = "tomato_tomato.png",
  33. on_use = minetest.item_eat(2),
  34. groups = {foodrot=1},
  35. flowerpot_insert = {"tomato:plant_1", "tomato:plant_2", "tomato:plant_3", "tomato:plant_4", "tomato:plant_5", "tomato:plant_6", "tomato:plant_7", "tomato:plant_8"},
  36. })
  37. local crop_def = {
  38. drawtype = "plantlike",
  39. tiles = {"tomato_plant_1.png"},
  40. paramtype = "light",
  41. sunlight_propagates = true,
  42. waving = 1,
  43. walkable = false,
  44. buildable_to = true,
  45. drop = "",
  46. selection_box = {
  47. type = "fixed",
  48. fixed = {-0.5, -0.5, -0.5, 0.5, -5/16, 0.5}
  49. },
  50. groups = utility.dig_groups("crop", {
  51. flammable = 2, plant = 1, attached_node = 1,
  52. not_in_creative_inventory = 1, notify_destruct = 1,
  53. }),
  54. sounds = default.node_sound_leaves_defaults(),
  55. on_timer = farming.grow_plant,
  56. minlight = 13,
  57. maxlight = default.LIGHT_MAX,
  58. movement_speed_multiplier = default.SLOW_SPEED_PLANTS,
  59. flowerpot_drop = "tomato:tomato",
  60. }
  61. crop_def._farming_next_plant = "tomato:plant_2"
  62. crop_def._farming_prev_seed = "tomato:seed"
  63. minetest.register_node("tomato:plant_1", table.copy(crop_def))
  64. crop_def._farming_next_plant = "tomato:plant_3"
  65. crop_def._farming_prev_plant = "tomato:plant_1"
  66. crop_def.tiles = {"tomato_plant_2.png"}
  67. minetest.register_node("tomato:plant_2", table.copy(crop_def))
  68. crop_def._farming_next_plant = "tomato:plant_4"
  69. crop_def._farming_prev_plant = "tomato:plant_2"
  70. crop_def.tiles = {"tomato_plant_3.png"}
  71. minetest.register_node("tomato:plant_3", table.copy(crop_def))
  72. crop_def._farming_next_plant = "tomato:plant_5"
  73. crop_def._farming_prev_plant = "tomato:plant_3"
  74. crop_def.tiles = {"tomato_plant_4.png"}
  75. minetest.register_node("tomato:plant_4", table.copy(crop_def))
  76. crop_def._farming_next_plant = "tomato:plant_6"
  77. crop_def._farming_prev_plant = "tomato:plant_4"
  78. crop_def.tiles = {"tomato_plant_5.png"}
  79. minetest.register_node("tomato:plant_5", table.copy(crop_def))
  80. crop_def._farming_next_plant = "tomato:plant_7"
  81. crop_def._farming_prev_plant = "tomato:plant_5"
  82. crop_def.tiles = {"tomato_plant_6.png"}
  83. minetest.register_node("tomato:plant_6", table.copy(crop_def))
  84. crop_def._farming_next_plant = "tomato:plant_8"
  85. crop_def._farming_prev_plant = "tomato:plant_6"
  86. crop_def.tiles = {"tomato_plant_7.png"}
  87. -- Not ready yet. Wait longer for best harvest.
  88. -- Note: this is the plant level placed by the mapgen.
  89. -- So we need to give seeds sometimes.
  90. crop_def.drop = {
  91. items = {
  92. {items = {"tomato:tomato"}, rarity = 1},
  93. {items = {"tomato:seed"}, rarity = 2},
  94. {items = {"tomato:seed"}, rarity = 2},
  95. }
  96. }
  97. minetest.register_node("tomato:plant_7", table.copy(crop_def))
  98. crop_def.tiles = {"tomato_plant_8.png"}
  99. crop_def.drop = {
  100. items = {
  101. {items = {"tomato:tomato"}, rarity = 1},
  102. {items = {"tomato:tomato"}, rarity = 2},
  103. {items = {"tomato:tomato"}, rarity = 2},
  104. {items = {"tomato:tomato"}, rarity = 2},
  105. {items = {"tomato:seed"}, rarity = 1},
  106. {items = {"tomato:seed"}, rarity = 2},
  107. {items = {"tomato:seed"}, rarity = 2},
  108. {items = {"tomato:seed"}, rarity = 3},
  109. }
  110. }
  111. crop_def._farming_next_plant = nil
  112. crop_def._farming_prev_plant = "tomato:plant_7"
  113. minetest.register_node("tomato:plant_8", table.copy(crop_def))