init.lua 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. --[[
  2. Original textures from DocFarming mod
  3. https://forum.minetest.net/viewtopic.php?id=3948
  4. ]]
  5. local S = function(s)
  6. return s
  7. end
  8. minetest.register_node("onions:seed", {
  9. description = "Allium Seeds",
  10. tiles = {"allium_seeds.png"},
  11. wield_image = "allium_seeds.png",
  12. inventory_image = "allium_seeds.png",
  13. drawtype = "signlike",
  14. paramtype = "light",
  15. paramtype2 = "wallmounted",
  16. walkable = false,
  17. sunlight_propagates = true,
  18. selection_box = {
  19. type = "fixed",
  20. fixed = {-0.5, -0.5, -0.5, 0.5, -5/16, 0.5}
  21. },
  22. groups = utility.dig_groups("seeds", {seed = 1, attached_node = 1, flammable = 2, notify_destruct = 1}),
  23. on_place = function(itemstack, placer, pointed_thing)
  24. return farming.place_seed(itemstack, placer, pointed_thing, "onions:seed")
  25. end,
  26. on_timer = farming.grow_plant,
  27. minlight = 13,
  28. maxlight = 15,
  29. next_plant = "onions:allium_sprouts_1",
  30. fertility = {"grassland"},
  31. sounds = default.node_sound_dirt_defaults({
  32. dug = {name = "default_grass_footstep", gain = 0.2},
  33. place = {name = "default_place_node", gain = 0.25},
  34. }),
  35. })
  36. -- onion
  37. minetest.register_craftitem("onions:onion", {
  38. description = S("Wild Onion"),
  39. inventory_image = "wild_onion.png",
  40. on_use = minetest.item_eat(1),
  41. groups = {foodrot=1},
  42. flowerpot_insert = {
  43. "onions:allium_sprouts_1",
  44. "onions:allium_sprouts_2",
  45. "onions:allium_sprouts_3",
  46. "onions:allium_sprouts_4",
  47. },
  48. })
  49. -- onion definition
  50. local crop_def = {
  51. drawtype = "plantlike",
  52. tiles = {"allium_sprouts1.png"},
  53. paramtype = "light",
  54. sunlight_propagates = true,
  55. waving = 1,
  56. walkable = false,
  57. buildable_to = true,
  58. drop = "",
  59. selection_box = {
  60. type = "fixed",
  61. fixed = {-0.5, -0.5, -0.5, 0.5, -5/16, 0.5}
  62. },
  63. groups = utility.dig_groups("crop", {
  64. flammable = 2, plant = 1, attached_node = 1,
  65. not_in_creative_inventory = 1, growing = 1, notify_destruct = 1,
  66. }),
  67. sounds = default.node_sound_leaves_defaults(),
  68. on_timer = farming.grow_plant,
  69. minlight = 13,
  70. maxlight = default.LIGHT_MAX,
  71. movement_speed_multiplier = default.SLOW_SPEED_PLANTS,
  72. flowerpot_drop = "onions:onion",
  73. }
  74. -- stage 1
  75. crop_def.next_plant = "onions:allium_sprouts_2"
  76. minetest.register_node("onions:allium_sprouts_1", table.copy(crop_def))
  77. -- stage 2
  78. crop_def.next_plant = "onions:allium_sprouts_3"
  79. crop_def.tiles = {"allium_sprouts2.png"}
  80. minetest.register_node("onions:allium_sprouts_2", table.copy(crop_def))
  81. -- stage 3
  82. crop_def.next_plant = "onions:allium_sprouts_4"
  83. crop_def.tiles = {"allium_sprouts3.png"}
  84. crop_def.drop = {
  85. items = {
  86. {items = {'onions:onion'}, rarity = 1},
  87. {items = {'onions:onion'}, rarity = 3},
  88. }
  89. }
  90. minetest.register_node("onions:allium_sprouts_3", table.copy(crop_def))
  91. -- stage 4
  92. crop_def.next_plant = nil
  93. crop_def.tiles = {"allium_sprouts4.png"}
  94. crop_def.groups.growing = 0
  95. crop_def.drop = {
  96. items = {
  97. {items = {'onions:onion'}, rarity = 1},
  98. {items = {'onions:onion 3'}, rarity = 3},
  99. {items = {'onions:seed'}, rarity = 1},
  100. {items = {'onions:seed'}, rarity = 2},
  101. }
  102. }
  103. minetest.register_node("onions:allium_sprouts_4", table.copy(crop_def))