melon.lua 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. local S = farming.translate
  2. -- melon
  3. minetest.register_craftitem("farming:melon_slice", {
  4. description = S("Melon Slice"),
  5. inventory_image = "farming_melon_slice.png",
  6. groups = {compostability = 48, seed = 2, food_melon_slice = 1, flammable = 3},
  7. on_place = function(itemstack, placer, pointed_thing)
  8. return farming.place_seed(itemstack, placer, pointed_thing, "farming:melon_1")
  9. end,
  10. on_use = minetest.item_eat(2)
  11. })
  12. minetest.register_craft({
  13. output = "farming:melon_8",
  14. recipe = {
  15. {"farming:melon_slice", "farming:melon_slice"},
  16. {"farming:melon_slice", "farming:melon_slice"}
  17. }
  18. })
  19. local tmp = farming.use_utensils and "farming:cutting_board" or ""
  20. minetest.register_craft({
  21. output = "farming:melon_slice 4",
  22. recipe = {{"farming:melon_8", tmp}},
  23. replacements = {{"farming:cutting_board", "farming:cutting_board"}}
  24. })
  25. -- melon definition
  26. local def = {
  27. drawtype = "plantlike",
  28. tiles = {"farming_melon_1.png"},
  29. paramtype = "light",
  30. sunlight_propagates = true,
  31. walkable = false,
  32. buildable_to = true,
  33. drop = "",
  34. selection_box = farming.select,
  35. groups = {
  36. handy = 1, snappy = 3, flammable = 2, plant = 1, attached_node = 1,
  37. not_in_creative_inventory = 1, growing = 1
  38. },
  39. sounds = farming.sounds.node_sound_leaves_defaults()
  40. }
  41. -- stage 1
  42. minetest.register_node("farming:melon_1", table.copy(def))
  43. -- stage 2
  44. def.tiles = {"farming_melon_2.png"}
  45. minetest.register_node("farming:melon_2", table.copy(def))
  46. -- stage 3
  47. def.tiles = {"farming_melon_3.png"}
  48. minetest.register_node("farming:melon_3", table.copy(def))
  49. -- stage 4
  50. def.tiles = {"farming_melon_4.png"}
  51. minetest.register_node("farming:melon_4", table.copy(def))
  52. -- stage 5
  53. def.tiles = {"farming_melon_5.png"}
  54. minetest.register_node("farming:melon_5", table.copy(def))
  55. -- stage 6
  56. def.tiles = {"farming_melon_6.png"}
  57. minetest.register_node("farming:melon_6", table.copy(def))
  58. -- stage 7
  59. def.tiles = {"farming_melon_7.png"}
  60. minetest.register_node("farming:melon_7", table.copy(def))
  61. -- stage 8 (final)
  62. minetest.register_node("farming:melon_8", {
  63. description = S("Melon"),
  64. tiles = {
  65. "farming_melon_top.png",
  66. "farming_melon_bottom.png",
  67. "farming_melon_side.png"
  68. },
  69. groups = {
  70. compostability = 65, food_melon = 1, handy = 1, snappy = 3, choppy = 3, oddly_breakable_by_hand = 2,
  71. flammable = 2, plant = 1
  72. },
  73. drop = "farming:melon_8",
  74. sounds = farming.sounds.node_sound_wood_defaults(),
  75. paramtype2 = "facedir",
  76. on_place = minetest.rotate_node
  77. })
  78. -- add to registered_plants
  79. farming.registered_plants["farming:melon"] = {
  80. crop = "farming:melon",
  81. seed = "farming:melon_slice",
  82. minlight = farming.min_light,
  83. maxlight = farming.max_light,
  84. steps = 8
  85. }
  86. -- mapgen
  87. local mg = farming.mapgen == "v6"
  88. def = {
  89. y_max = mg and 20 or 6,
  90. spawn_on = mg and {"default:dirt_with_grass"} or {"default:dirt_with_dry_grass",
  91. "default:dirt_with_rainforest_litter"},
  92. near = mg and "group:water" or nil,
  93. num = mg and 1 or -1,
  94. }
  95. minetest.register_decoration({
  96. deco_type = "simple",
  97. place_on = def.spawn_on,
  98. sidelen = 16,
  99. noise_params = {
  100. offset = 0,
  101. scale = farming.melon,
  102. spread = {x = 100, y = 100, z = 100},
  103. seed = 790,
  104. octaves = 3,
  105. persist = 0.6
  106. },
  107. y_min = 1,
  108. y_max = def.y_max,
  109. decoration = "farming:melon_8",
  110. spawn_by = def.near,
  111. num_spawn_by = def.num
  112. })