cotton.lua 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. local S = farming.intllib
  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 = {snappy = 3, attached_node = 1, flammable = 4},
  15. drop = {
  16. items = {
  17. {items = {"farming:cotton"}, rarity = 2},
  18. {items = {"farming:seed_cotton"}, rarity = 1}
  19. }
  20. },
  21. sounds = default.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 = {seed = 1, snappy = 3, attached_node = 1, flammable = 4},
  35. paramtype = "light",
  36. paramtype2 = "wallmounted",
  37. walkable = false,
  38. sunlight_propagates = true,
  39. selection_box = farming.select,
  40. on_place = function(itemstack, placer, pointed_thing)
  41. return farming.place_seed(itemstack, placer, pointed_thing, "farming:cotton_1")
  42. end
  43. })
  44. -- cotton
  45. minetest.register_craftitem("farming:cotton", {
  46. description = S("Cotton"),
  47. inventory_image = "farming_cotton.png",
  48. groups = {flammable = 4}
  49. })
  50. -- string
  51. minetest.register_craftitem("farming:string", {
  52. description = S("String"),
  53. inventory_image = "farming_string.png",
  54. groups = {flammable = 2}
  55. })
  56. -- cotton to wool
  57. minetest.register_craft({
  58. output = "wool:white",
  59. recipe = {
  60. {"farming:cotton", "farming:cotton"},
  61. {"farming:cotton", "farming:cotton"}
  62. }
  63. })
  64. -- cotton to string
  65. minetest.register_craft({
  66. output = "farming:string 2",
  67. recipe = {
  68. {"farming:cotton"},
  69. {"farming:cotton"}
  70. }
  71. })
  72. -- can be used as fuel
  73. minetest.register_craft({
  74. type = "fuel",
  75. recipe = "farming:string",
  76. burntime = 1
  77. })
  78. minetest.register_craft({
  79. type = "fuel",
  80. recipe = "farming:cotton",
  81. burntime = 1
  82. })
  83. -- cotton definition
  84. local def = {
  85. drawtype = "plantlike",
  86. tiles = {"farming_cotton_1.png"},
  87. paramtype = "light",
  88. sunlight_propagates = true,
  89. walkable = false,
  90. buildable_to = true,
  91. drop = "",
  92. selection_box = farming.select,
  93. groups = {
  94. snappy = 3, flammable = 4, plant = 1, attached_node = 1,
  95. not_in_creative_inventory = 1, growing = 1
  96. },
  97. sounds = default.node_sound_leaves_defaults()
  98. }
  99. -- stage 1
  100. minetest.register_node("farming:cotton_1", table.copy(def))
  101. -- stage 2
  102. def.tiles = {"farming_cotton_2.png"}
  103. minetest.register_node("farming:cotton_2", table.copy(def))
  104. -- stage 3
  105. def.tiles = {"farming_cotton_3.png"}
  106. minetest.register_node("farming:cotton_3", table.copy(def))
  107. -- stage 4
  108. def.tiles = {"farming_cotton_4.png"}
  109. minetest.register_node("farming:cotton_4", table.copy(def))
  110. -- stage 5
  111. def.tiles = {"farming_cotton_5.png"}
  112. def.drop = {
  113. items = {
  114. {items = {"farming:seed_cotton"}, rarity = 1}
  115. }
  116. }
  117. minetest.register_node("farming:cotton_5", table.copy(def))
  118. -- stage 6
  119. def.tiles = {"farming_cotton_6.png"}
  120. def.drop = {
  121. items = {
  122. {items = {"farming:cotton"}, rarity = 1},
  123. {items = {"farming:cotton"}, rarity = 2}
  124. }
  125. }
  126. minetest.register_node("farming:cotton_6", table.copy(def))
  127. -- stage 7
  128. def.tiles = {"farming_cotton_7.png"}
  129. def.drop = {
  130. items = {
  131. {items = {"farming:cotton"}, rarity = 1},
  132. {items = {"farming:cotton"}, rarity = 2},
  133. {items = {"farming:seed_cotton"}, rarity = 1},
  134. {items = {"farming:seed_cotton"}, rarity = 2}
  135. }
  136. }
  137. minetest.register_node("farming:cotton_7", table.copy(def))
  138. -- stage 8 (final)
  139. def.tiles = {"farming_cotton_8.png"}
  140. def.groups.growing = nil
  141. def.drop = {
  142. items = {
  143. {items = {"farming:cotton"}, rarity = 1},
  144. {items = {"farming:cotton"}, rarity = 2},
  145. {items = {"farming:cotton"}, rarity = 3},
  146. {items = {"farming:seed_cotton"}, rarity = 1},
  147. {items = {"farming:seed_cotton"}, rarity = 2},
  148. {items = {"farming:seed_cotton"}, rarity = 3}
  149. }
  150. }
  151. minetest.register_node("farming:cotton_8", table.copy(def))
  152. -- add to registered_plants
  153. farming.registered_plants["farming:cotton"] = {
  154. crop = "farming:cotton",
  155. seed = "farming:seed_cotton",
  156. minlight = farming.min_light,
  157. maxlight = farming.max_light,
  158. steps = 8
  159. }
  160. --[[ Cotton using api
  161. farming.register_plant("farming:cotton", {
  162. description = "Cotton seed",
  163. inventory_image = "farming_cotton_seed.png",
  164. groups = {flammable = 2},
  165. steps = 8,
  166. })]]