cotton.lua 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  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. -- can be used as fuel
  31. minetest.register_craft({
  32. type = "fuel",
  33. recipe = "farming:string",
  34. burntime = 1,
  35. })
  36. minetest.register_craft({
  37. type = "fuel",
  38. recipe = "farming:cotton",
  39. burntime = 1,
  40. })
  41. -- cotton definition
  42. local crop_def = {
  43. drawtype = "plantlike",
  44. tiles = {"farming_cotton_1.png"},
  45. paramtype = "light",
  46. sunlight_propagates = true,
  47. walkable = false,
  48. buildable_to = true,
  49. drop = "",
  50. selection_box = farming.select,
  51. groups = {
  52. snappy = 3, flammable = 4, plant = 1, attached_node = 1,
  53. not_in_creative_inventory = 1, growing = 1
  54. },
  55. sounds = default.node_sound_leaves_defaults()
  56. }
  57. -- stage 1
  58. minetest.register_node("farming:cotton_1", table.copy(crop_def))
  59. -- stage 2
  60. crop_def.tiles = {"farming_cotton_2.png"}
  61. minetest.register_node("farming:cotton_2", table.copy(crop_def))
  62. -- stage 3
  63. crop_def.tiles = {"farming_cotton_3.png"}
  64. minetest.register_node("farming:cotton_3", table.copy(crop_def))
  65. -- stage 4
  66. crop_def.tiles = {"farming_cotton_4.png"}
  67. minetest.register_node("farming:cotton_4", table.copy(crop_def))
  68. -- stage 5
  69. crop_def.tiles = {"farming_cotton_5.png"}
  70. crop_def.drop = {
  71. items = {
  72. {items = {"farming:seed_cotton"}, rarity = 1},
  73. }
  74. }
  75. minetest.register_node("farming:cotton_5", table.copy(crop_def))
  76. -- stage 6
  77. crop_def.tiles = {"farming_cotton_6.png"}
  78. crop_def.drop = {
  79. items = {
  80. {items = {"farming:cotton"}, rarity = 1},
  81. {items = {"farming:cotton"}, rarity = 2},
  82. }
  83. }
  84. minetest.register_node("farming:cotton_6", table.copy(crop_def))
  85. -- stage 7
  86. crop_def.tiles = {"farming_cotton_7.png"}
  87. crop_def.drop = {
  88. items = {
  89. {items = {"farming:cotton"}, rarity = 1},
  90. {items = {"farming:cotton"}, rarity = 2},
  91. {items = {"farming:seed_cotton"}, rarity = 1},
  92. {items = {"farming:seed_cotton"}, rarity = 2},
  93. }
  94. }
  95. minetest.register_node("farming:cotton_7", table.copy(crop_def))
  96. -- stage 8 (final)
  97. crop_def.tiles = {"farming_cotton_8.png"}
  98. crop_def.groups.growing = 0
  99. crop_def.drop = {
  100. items = {
  101. {items = {"farming:cotton"}, rarity = 1},
  102. {items = {"farming:cotton"}, rarity = 2},
  103. {items = {"farming:cotton"}, rarity = 3},
  104. {items = {"farming:seed_cotton"}, rarity = 1},
  105. {items = {"farming:seed_cotton"}, rarity = 2},
  106. {items = {"farming:seed_cotton"}, rarity = 3},
  107. }
  108. }
  109. minetest.register_node("farming:cotton_8", table.copy(crop_def))
  110. -- add to registered_plants
  111. farming.registered_plants["farming:cotton"] = {
  112. crop = "farming:cotton",
  113. seed = "farming:seed_cotton",
  114. minlight = 13,
  115. maxlight = 15,
  116. steps = 8
  117. }
  118. --[[ Cotton (example, is already registered in cotton.lua)
  119. farming.register_plant("farming:cotton", {
  120. description = "Cotton seed",
  121. inventory_image = "farming_cotton_seed.png",
  122. groups = {flammable = 2},
  123. steps = 8,
  124. })]]