init.lua 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. -- farming/init.lua
  2. -- Load support for MT game translation.
  3. local S = minetest.get_translator("farming")
  4. -- Global farming namespace
  5. farming = {}
  6. farming.path = minetest.get_modpath("farming")
  7. farming.get_translator = S
  8. -- Load files
  9. dofile(farming.path .. "/api.lua")
  10. dofile(farming.path .. "/nodes.lua")
  11. dofile(farming.path .. "/hoes.lua")
  12. -- Wheat
  13. farming.register_plant("farming:wheat", {
  14. description = S("Wheat Seed"),
  15. harvest_description = S("Wheat"),
  16. paramtype2 = "meshoptions",
  17. inventory_image = "farming_wheat_seed.png",
  18. steps = 8,
  19. minlight = 13,
  20. maxlight = default.LIGHT_MAX,
  21. fertility = {"grassland"},
  22. groups = {food_wheat = 1, flammable = 4},
  23. place_param2 = 3,
  24. })
  25. minetest.register_craftitem("farming:flour", {
  26. description = S("Flour"),
  27. inventory_image = "farming_flour.png",
  28. groups = {food_flour = 1, flammable = 1},
  29. })
  30. minetest.register_craftitem("farming:bread", {
  31. description = S("Bread"),
  32. inventory_image = "farming_bread.png",
  33. on_use = minetest.item_eat(5),
  34. groups = {food_bread = 1, flammable = 2},
  35. })
  36. minetest.register_craft({
  37. type = "shapeless",
  38. output = "farming:flour",
  39. recipe = {"farming:wheat", "farming:wheat", "farming:wheat", "farming:wheat"}
  40. })
  41. minetest.register_craft({
  42. type = "cooking",
  43. cooktime = 15,
  44. output = "farming:bread",
  45. recipe = "farming:flour"
  46. })
  47. -- Cotton
  48. farming.register_plant("farming:cotton", {
  49. description = S("Cotton Seed"),
  50. harvest_description = S("Cotton"),
  51. inventory_image = "farming_cotton_seed.png",
  52. steps = 8,
  53. minlight = 13,
  54. maxlight = default.LIGHT_MAX,
  55. fertility = {"grassland", "desert"},
  56. groups = {flammable = 4},
  57. })
  58. minetest.register_decoration({
  59. name = "farming:cotton_wild",
  60. deco_type = "simple",
  61. place_on = {"default:dry_dirt_with_dry_grass"},
  62. sidelen = 16,
  63. noise_params = {
  64. offset = -0.1,
  65. scale = 0.1,
  66. spread = {x = 50, y = 50, z = 50},
  67. seed = 4242,
  68. octaves = 3,
  69. persist = 0.7
  70. },
  71. biomes = {"savanna"},
  72. y_max = 31000,
  73. y_min = 1,
  74. decoration = "farming:cotton_wild",
  75. })
  76. minetest.register_craftitem("farming:string", {
  77. description = S("String"),
  78. inventory_image = "farming_string.png",
  79. groups = {flammable = 2},
  80. })
  81. minetest.register_craft({
  82. output = "wool:white",
  83. recipe = {
  84. {"farming:cotton", "farming:cotton"},
  85. {"farming:cotton", "farming:cotton"},
  86. }
  87. })
  88. minetest.register_craft({
  89. output = "farming:string 2",
  90. recipe = {
  91. {"farming:cotton"},
  92. {"farming:cotton"},
  93. }
  94. })
  95. -- Straw
  96. minetest.register_craft({
  97. output = "farming:straw 3",
  98. recipe = {
  99. {"farming:wheat", "farming:wheat", "farming:wheat"},
  100. {"farming:wheat", "farming:wheat", "farming:wheat"},
  101. {"farming:wheat", "farming:wheat", "farming:wheat"},
  102. }
  103. })
  104. minetest.register_craft({
  105. output = "farming:wheat 3",
  106. recipe = {
  107. {"farming:straw"},
  108. }
  109. })
  110. -- Fuels
  111. minetest.register_craft({
  112. type = "fuel",
  113. recipe = "farming:wheat",
  114. burntime = 1,
  115. })
  116. minetest.register_craft({
  117. type = "fuel",
  118. recipe = "farming:cotton",
  119. burntime = 1,
  120. })
  121. minetest.register_craft({
  122. type = "fuel",
  123. recipe = "farming:string",
  124. burntime = 1,
  125. })
  126. minetest.register_craft({
  127. type = "fuel",
  128. recipe = "farming:hoe_wood",
  129. burntime = 5,
  130. })
  131. -- Register farming items as dungeon loot
  132. if minetest.global_exists("dungeon_loot") then
  133. dungeon_loot.register({
  134. {name = "farming:string", chance = 0.5, count = {1, 8}},
  135. {name = "farming:wheat", chance = 0.5, count = {2, 5}},
  136. {name = "farming:seed_cotton", chance = 0.4, count = {1, 4},
  137. types = {"normal"}},
  138. })
  139. end