cotton.lua 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. local S = farming.intllib
  2. -- cotton seeds
  3. minetest.register_node("farming:seed_cotton", {
  4. description = S("Cotton Seed"),
  5. tiles = {"farming_cotton_seed.png"},
  6. inventory_image = "farming_cotton_seed.png",
  7. wield_image = "farming_cotton_seed.png",
  8. drawtype = "signlike",
  9. groups = {seed = 1, snappy = 3, attached_node = 1, flammable = 4},
  10. paramtype = "light",
  11. paramtype2 = "wallmounted",
  12. walkable = false,
  13. sunlight_propagates = true,
  14. selection_box = farming.select,
  15. on_place = function(itemstack, placer, pointed_thing)
  16. return farming.place_seed(itemstack, placer, pointed_thing, "farming:cotton_1")
  17. end,
  18. })
  19. -- cotton / string
  20. minetest.register_craftitem("farming:cotton", {
  21. description = S("Cotton"),
  22. inventory_image = "farming_cotton.png",
  23. groups = {flammable = 4},
  24. })
  25. minetest.register_craftitem("farming:string", {
  26. description = S("String"),
  27. inventory_image = "farming_string.png",
  28. groups = {flammable = 2},
  29. })
  30. -- cotton to wool
  31. minetest.register_craft({
  32. output = "wool:white",
  33. recipe = {
  34. {"farming:cotton", "farming:cotton"},
  35. {"farming:cotton", "farming:cotton"},
  36. }
  37. })
  38. -- cotton to string
  39. minetest.register_craft({
  40. output = "farming:string 2",
  41. recipe = {
  42. {"farming:cotton"},
  43. {"farming:cotton"},
  44. }
  45. })
  46. -- can be used as fuel
  47. minetest.register_craft({
  48. type = "fuel",
  49. recipe = "farming:string",
  50. burntime = 1,
  51. })
  52. minetest.register_craft({
  53. type = "fuel",
  54. recipe = "farming:cotton",
  55. burntime = 1,
  56. })
  57. -- cotton definition
  58. local crop_def = {
  59. drawtype = "plantlike",
  60. tiles = {"farming_cotton_1.png"},
  61. paramtype = "light",
  62. sunlight_propagates = true,
  63. walkable = false,
  64. buildable_to = true,
  65. drop = "",
  66. selection_box = farming.select,
  67. groups = {
  68. snappy = 3, flammable = 4, plant = 1, attached_node = 1,
  69. not_in_creative_inventory = 1, growing = 1
  70. },
  71. sounds = default.node_sound_leaves_defaults()
  72. }
  73. -- stage 1
  74. minetest.register_node("farming:cotton_1", table.copy(crop_def))
  75. -- stage 2
  76. crop_def.tiles = {"farming_cotton_2.png"}
  77. minetest.register_node("farming:cotton_2", table.copy(crop_def))
  78. -- stage 3
  79. crop_def.tiles = {"farming_cotton_3.png"}
  80. minetest.register_node("farming:cotton_3", table.copy(crop_def))
  81. -- stage 4
  82. crop_def.tiles = {"farming_cotton_4.png"}
  83. minetest.register_node("farming:cotton_4", table.copy(crop_def))
  84. -- stage 5
  85. crop_def.tiles = {"farming_cotton_5.png"}
  86. crop_def.drop = {
  87. items = {
  88. {items = {"farming:seed_cotton"}, rarity = 1},
  89. }
  90. }
  91. minetest.register_node("farming:cotton_5", table.copy(crop_def))
  92. -- stage 6
  93. crop_def.tiles = {"farming_cotton_6.png"}
  94. crop_def.drop = {
  95. items = {
  96. {items = {"farming:cotton"}, rarity = 1},
  97. {items = {"farming:cotton"}, rarity = 2},
  98. }
  99. }
  100. minetest.register_node("farming:cotton_6", table.copy(crop_def))
  101. -- stage 7
  102. crop_def.tiles = {"farming_cotton_7.png"}
  103. crop_def.drop = {
  104. items = {
  105. {items = {"farming:cotton"}, rarity = 1},
  106. {items = {"farming:cotton"}, rarity = 2},
  107. {items = {"farming:seed_cotton"}, rarity = 1},
  108. {items = {"farming:seed_cotton"}, rarity = 2},
  109. }
  110. }
  111. minetest.register_node("farming:cotton_7", table.copy(crop_def))
  112. -- stage 8 (final)
  113. crop_def.tiles = {"farming_cotton_8.png"}
  114. crop_def.groups.growing = 0
  115. crop_def.drop = {
  116. items = {
  117. {items = {"farming:cotton"}, rarity = 1},
  118. {items = {"farming:cotton"}, rarity = 2},
  119. {items = {"farming:cotton"}, rarity = 3},
  120. {items = {"farming:seed_cotton"}, rarity = 1},
  121. {items = {"farming:seed_cotton"}, rarity = 2},
  122. {items = {"farming:seed_cotton"}, rarity = 3},
  123. }
  124. }
  125. minetest.register_node("farming:cotton_8", table.copy(crop_def))
  126. -- add to registered_plants
  127. farming.registered_plants["farming:cotton"] = {
  128. crop = "farming:cotton",
  129. seed = "farming:seed_cotton",
  130. minlight = 13,
  131. maxlight = 15,
  132. steps = 8
  133. }
  134. --[[ Cotton (example, is already registered in cotton.lua)
  135. farming.register_plant("farming:cotton", {
  136. description = "Cotton seed",
  137. inventory_image = "farming_cotton_seed.png",
  138. groups = {flammable = 2},
  139. steps = 8,
  140. })]]