cotton.lua 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. local S = farming.translate
  2. -- wild cotton as a source of cotton seed and a chance of cotton itself
  3. minetest.register_node("farming:cotton_wild", {
  4. description = S("Wild Cotton"),
  5. drawtype = "plantlike",
  6. waving = 1,
  7. tiles = {"farming_cotton_wild.png"},
  8. inventory_image = "farming_cotton_wild.png",
  9. wield_image = "farming_cotton_wild.png",
  10. paramtype = "light",
  11. sunlight_propagates = true,
  12. walkable = false,
  13. buildable_to = true,
  14. groups = {handy = 1, snappy = 3, attached_node = 1, flammable = 4, compostability = 60},
  15. drop = {
  16. items = {
  17. {items = {"farming:cotton"}, rarity = 2},
  18. {items = {"farming:seed_cotton"}, rarity = 1}
  19. }
  20. },
  21. sounds = farming.sounds.node_sound_leaves_defaults(),
  22. selection_box = {
  23. type = "fixed",
  24. fixed = {-6 / 16, -8 / 16, -6 / 16, 6 / 16, 5 / 16, 6 / 16}
  25. }
  26. })
  27. -- cotton seeds
  28. minetest.register_node("farming:seed_cotton", {
  29. description = S("Cotton Seed"),
  30. tiles = {"farming_cotton_seed.png"},
  31. inventory_image = "farming_cotton_seed.png",
  32. wield_image = "farming_cotton_seed.png",
  33. drawtype = "signlike",
  34. groups = {
  35. compostability = 48, seed = 1, snappy = 3, attached_node = 1,
  36. flammable = 4, growing = 1
  37. },
  38. paramtype = "light",
  39. paramtype2 = "wallmounted",
  40. walkable = false,
  41. sunlight_propagates = true,
  42. selection_box = farming.select,
  43. next_plant = "farming:cotton_1",
  44. on_place = function(itemstack, placer, pointed_thing)
  45. return farming.place_seed(itemstack, placer, pointed_thing, "farming:seed_cotton")
  46. end
  47. })
  48. -- cotton
  49. minetest.register_craftitem("farming:cotton", {
  50. description = S("Cotton"),
  51. inventory_image = "farming_cotton.png",
  52. groups = {flammable = 4, compostability = 50}
  53. })
  54. -- string
  55. if farming.mtg then
  56. minetest.register_craftitem("farming:string", {
  57. description = S("String"),
  58. inventory_image = "farming_string.png",
  59. groups = {flammable = 2}
  60. })
  61. end
  62. if farming.mcl then
  63. minetest.register_alias("farming:string", "mcl_mobitems:string")
  64. end
  65. -- cotton to wool
  66. minetest.register_craft({
  67. output = "wool:white",
  68. recipe = {
  69. {"farming:cotton", "farming:cotton"},
  70. {"farming:cotton", "farming:cotton"}
  71. }
  72. })
  73. -- cotton to string
  74. minetest.register_craft({
  75. output = "farming:string 2",
  76. recipe = {
  77. {"farming:cotton"},
  78. {"farming:cotton"}
  79. }
  80. })
  81. -- can be used as fuel
  82. minetest.register_craft({
  83. type = "fuel",
  84. recipe = "farming:string",
  85. burntime = 1
  86. })
  87. minetest.register_craft({
  88. type = "fuel",
  89. recipe = "farming:cotton",
  90. burntime = 1
  91. })
  92. -- cotton definition
  93. local def = {
  94. drawtype = "plantlike",
  95. tiles = {"farming_cotton_1.png"},
  96. paramtype = "light",
  97. sunlight_propagates = true,
  98. walkable = false,
  99. buildable_to = true,
  100. drop = "",
  101. waving = 1,
  102. selection_box = farming.select,
  103. groups = {
  104. handy = 1, snappy = 3, flammable = 4, plant = 1, attached_node = 1,
  105. not_in_creative_inventory = 1, growing = 1
  106. },
  107. sounds = farming.sounds.node_sound_leaves_defaults()
  108. }
  109. -- stage 1
  110. minetest.register_node("farming:cotton_1", table.copy(def))
  111. -- stage 2
  112. def.tiles = {"farming_cotton_2.png"}
  113. minetest.register_node("farming:cotton_2", table.copy(def))
  114. -- stage 3
  115. def.tiles = {"farming_cotton_3.png"}
  116. minetest.register_node("farming:cotton_3", table.copy(def))
  117. -- stage 4
  118. def.tiles = {"farming_cotton_4.png"}
  119. minetest.register_node("farming:cotton_4", table.copy(def))
  120. -- stage 5
  121. def.tiles = {"farming_cotton_5.png"}
  122. def.drop = {
  123. items = {
  124. {items = {"farming:seed_cotton"}, rarity = 1}
  125. }
  126. }
  127. minetest.register_node("farming:cotton_5", table.copy(def))
  128. -- stage 6
  129. def.tiles = {"farming_cotton_6.png"}
  130. def.drop = {
  131. items = {
  132. {items = {"farming:cotton"}, rarity = 1},
  133. {items = {"farming:cotton"}, rarity = 2}
  134. }
  135. }
  136. minetest.register_node("farming:cotton_6", table.copy(def))
  137. -- stage 7
  138. def.tiles = {"farming_cotton_7.png"}
  139. def.drop = {
  140. items = {
  141. {items = {"farming:cotton"}, rarity = 1},
  142. {items = {"farming:cotton"}, rarity = 2},
  143. {items = {"farming:seed_cotton"}, rarity = 1},
  144. {items = {"farming:seed_cotton"}, rarity = 2}
  145. }
  146. }
  147. minetest.register_node("farming:cotton_7", table.copy(def))
  148. -- stage 8 (final)
  149. def.tiles = {"farming_cotton_8.png"}
  150. def.groups.growing = nil
  151. def.selection_box = farming.select_final
  152. def.drop = {
  153. items = {
  154. {items = {"farming:cotton"}, rarity = 1},
  155. {items = {"farming:cotton"}, rarity = 2},
  156. {items = {"farming:cotton"}, rarity = 3},
  157. {items = {"farming:seed_cotton"}, rarity = 1},
  158. {items = {"farming:seed_cotton"}, rarity = 2},
  159. {items = {"farming:seed_cotton"}, rarity = 3}
  160. }
  161. }
  162. minetest.register_node("farming:cotton_8", table.copy(def))
  163. -- add to registered_plants
  164. farming.registered_plants["farming:cotton"] = {
  165. crop = "farming:cotton",
  166. seed = "farming:seed_cotton",
  167. minlight = farming.min_light,
  168. maxlight = farming.max_light,
  169. steps = 8
  170. }
  171. --[[ Cotton using api
  172. farming.register_plant("farming:cotton", {
  173. description = "Cotton seed",
  174. inventory_image = "farming_cotton_seed.png",
  175. groups = {flammable = 2},
  176. steps = 8,
  177. })]]
  178. -- mapgen
  179. local mg = farming.mapgen == "v6"
  180. def = {
  181. grow_on = mg and {"default:dirt_with_grass"} or {"default:dry_dirt_with_dry_grass"},
  182. biome = mg and {"jungle"} or {"savanna"}
  183. }
  184. minetest.register_decoration({
  185. name = "farming:cotton_wild",
  186. deco_type = "simple",
  187. place_on = def.grow_on,
  188. sidelen = 16,
  189. noise_params = {
  190. offset = -0.1,
  191. scale = 0.1,
  192. spread = {x = 50, y = 50, z = 50},
  193. seed = 4242,
  194. octaves = 3,
  195. persist = 0.7
  196. },
  197. biomes = def.biome,
  198. y_max = 31000,
  199. y_min = 1,
  200. decoration = "farming:cotton_wild"
  201. })