init.lua 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  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, 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. 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.next_plant = "tomato:plant_2"
  62. minetest.register_node("tomato:plant_1", table.copy(crop_def))
  63. crop_def.next_plant = "tomato:plant_3"
  64. crop_def.tiles = {"tomato_plant_2.png"}
  65. minetest.register_node("tomato:plant_2", table.copy(crop_def))
  66. crop_def.next_plant = "tomato:plant_4"
  67. crop_def.tiles = {"tomato_plant_3.png"}
  68. minetest.register_node("tomato:plant_3", table.copy(crop_def))
  69. crop_def.next_plant = "tomato:plant_5"
  70. crop_def.tiles = {"tomato_plant_4.png"}
  71. minetest.register_node("tomato:plant_4", table.copy(crop_def))
  72. crop_def.next_plant = "tomato:plant_6"
  73. crop_def.tiles = {"tomato_plant_5.png"}
  74. minetest.register_node("tomato:plant_5", table.copy(crop_def))
  75. crop_def.next_plant = "tomato:plant_7"
  76. crop_def.tiles = {"tomato_plant_6.png"}
  77. minetest.register_node("tomato:plant_6", table.copy(crop_def))
  78. crop_def.next_plant = "tomato:plant_8"
  79. crop_def.tiles = {"tomato_plant_7.png"}
  80. -- Not ready yet. Wait longer for best harvest.
  81. -- Note: this is the plant level placed by the mapgen.
  82. -- So we need to give seeds sometimes.
  83. crop_def.drop = {
  84. items = {
  85. {items = {"tomato:tomato"}, rarity = 1},
  86. {items = {"tomato:seed"}, rarity = 2},
  87. {items = {"tomato:seed"}, rarity = 2},
  88. }
  89. }
  90. minetest.register_node("tomato:plant_7", table.copy(crop_def))
  91. crop_def.tiles = {"tomato_plant_8.png"}
  92. crop_def.drop = {
  93. items = {
  94. {items = {"tomato:tomato"}, rarity = 1},
  95. {items = {"tomato:tomato"}, rarity = 2},
  96. {items = {"tomato:tomato"}, rarity = 2},
  97. {items = {"tomato:tomato"}, rarity = 2},
  98. {items = {"tomato:seed"}, rarity = 1},
  99. {items = {"tomato:seed"}, rarity = 2},
  100. {items = {"tomato:seed"}, rarity = 2},
  101. {items = {"tomato:seed"}, rarity = 3},
  102. }
  103. }
  104. crop_def.next_plant = nil
  105. minetest.register_node("tomato:plant_8", table.copy(crop_def))