nodes.lua 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. minetest.override_item("default:dirt", {
  2. soil = {
  3. base = "default:dirt",
  4. dry = "farming:soil",
  5. wet = "farming:soil_wet"
  6. }
  7. })
  8. minetest.override_item("default:dirt_with_grass", {
  9. soil = {
  10. base = "default:dirt_with_grass",
  11. dry = "farming:soil",
  12. wet = "farming:soil_wet"
  13. }
  14. })
  15. minetest.override_item("default:dirt_with_dry_grass", {
  16. soil = {
  17. base = "default:dirt_with_dry_grass",
  18. dry = "farming:soil",
  19. wet = "farming:soil_wet"
  20. }
  21. })
  22. minetest.override_item("default:dirt_with_rainforest_litter", {
  23. soil = {
  24. base = "default:dirt_with_rainforest_litter",
  25. dry = "farming:soil",
  26. wet = "farming:soil_wet"
  27. }
  28. })
  29. minetest.register_node("farming:soil", {
  30. description = "Soil",
  31. tiles = {"default_dirt.png^farming_soil.png", "default_dirt.png"},
  32. drop = "default:dirt",
  33. groups = {crumbly=3, not_in_creative_inventory=1, soil=2, grassland = 1, field = 1},
  34. sounds = default.node_sound_dirt_defaults(),
  35. soil = {
  36. base = "default:dirt",
  37. dry = "farming:soil",
  38. wet = "farming:soil_wet"
  39. }
  40. })
  41. minetest.register_node("farming:soil_wet", {
  42. description = "Wet Soil",
  43. tiles = {"default_dirt.png^farming_soil_wet.png", "default_dirt.png^farming_soil_wet_side.png"},
  44. drop = "default:dirt",
  45. groups = {crumbly=3, not_in_creative_inventory=1, soil=3, wet = 1, grassland = 1, field = 1},
  46. sounds = default.node_sound_dirt_defaults(),
  47. soil = {
  48. base = "default:dirt",
  49. dry = "farming:soil",
  50. wet = "farming:soil_wet"
  51. }
  52. })
  53. minetest.override_item("default:desert_sand", {
  54. groups = {crumbly=3, falling_node=1, sand=1, soil = 1},
  55. soil = {
  56. base = "default:desert_sand",
  57. dry = "farming:desert_sand_soil",
  58. wet = "farming:desert_sand_soil_wet"
  59. }
  60. })
  61. minetest.register_node("farming:desert_sand_soil", {
  62. description = "Desert Sand Soil",
  63. drop = "default:desert_sand",
  64. tiles = {"farming_desert_sand_soil.png", "default_desert_sand.png"},
  65. groups = {crumbly=3, not_in_creative_inventory = 1, falling_node=1, sand=1, soil = 2, desert = 1, field = 1},
  66. sounds = default.node_sound_sand_defaults(),
  67. soil = {
  68. base = "default:desert_sand",
  69. dry = "farming:desert_sand_soil",
  70. wet = "farming:desert_sand_soil_wet"
  71. }
  72. })
  73. minetest.register_node("farming:desert_sand_soil_wet", {
  74. description = "Wet Desert Sand Soil",
  75. drop = "default:desert_sand",
  76. tiles = {"farming_desert_sand_soil_wet.png", "farming_desert_sand_soil_wet_side.png"},
  77. groups = {crumbly=3, falling_node=1, sand=1, not_in_creative_inventory=1, soil=3, wet = 1, desert = 1, field = 1},
  78. sounds = default.node_sound_sand_defaults(),
  79. soil = {
  80. base = "default:desert_sand",
  81. dry = "farming:desert_sand_soil",
  82. wet = "farming:desert_sand_soil_wet"
  83. }
  84. })
  85. minetest.register_node("farming:straw", {
  86. description = "Straw",
  87. tiles = {"farming_straw.png"},
  88. is_ground_content = false,
  89. groups = {snappy=3, flammable=4, fall_damage_add_percent=-30},
  90. sounds = default.node_sound_leaves_defaults(),
  91. })
  92. minetest.register_abm({
  93. label = "Farming soil",
  94. nodenames = {"group:field"},
  95. interval = 15,
  96. chance = 4,
  97. action = function(pos, node)
  98. local n_def = minetest.registered_nodes[node.name] or nil
  99. local wet = n_def.soil.wet or nil
  100. local base = n_def.soil.base or nil
  101. local dry = n_def.soil.dry or nil
  102. if not n_def or not n_def.soil or not wet or not base or not dry then
  103. return
  104. end
  105. pos.y = pos.y + 1
  106. local nn = minetest.get_node_or_nil(pos)
  107. if not nn or not nn.name then
  108. return
  109. end
  110. local nn_def = minetest.registered_nodes[nn.name] or nil
  111. pos.y = pos.y - 1
  112. if nn_def and nn_def.walkable and minetest.get_item_group(nn.name, "plant") == 0 then
  113. minetest.set_node(pos, {name = base})
  114. return
  115. end
  116. -- check if there is water nearby
  117. local wet_lvl = minetest.get_item_group(node.name, "wet")
  118. if minetest.find_node_near(pos, 3, {"group:water"}) then
  119. -- if it is dry soil and not base node, turn it into wet soil
  120. if wet_lvl == 0 then
  121. minetest.set_node(pos, {name = wet})
  122. end
  123. else
  124. -- only turn back if there are no unloaded blocks (and therefore
  125. -- possible water sources) nearby
  126. if not minetest.find_node_near(pos, 3, {"ignore"}) then
  127. -- turn it back into base if it is already dry
  128. if wet_lvl == 0 then
  129. -- only turn it back if there is no plant/seed on top of it
  130. if minetest.get_item_group(nn.name, "plant") == 0 and minetest.get_item_group(nn.name, "seed") == 0 then
  131. minetest.set_node(pos, {name = base})
  132. end
  133. -- if its wet turn it back into dry soil
  134. elseif wet_lvl == 1 then
  135. minetest.set_node(pos, {name = dry})
  136. end
  137. end
  138. end
  139. end,
  140. })
  141. for i = 1, 5 do
  142. minetest.override_item("default:grass_"..i, {drop = {
  143. max_items = 1,
  144. items = {
  145. {items = {'farming:seed_wheat'},rarity = 5},
  146. {items = {'default:grass_1'}},
  147. }
  148. }})
  149. end
  150. minetest.override_item("default:junglegrass", {drop = {
  151. max_items = 1,
  152. items = {
  153. {items = {'farming:seed_cotton'},rarity = 8},
  154. {items = {'default:junglegrass'}},
  155. }
  156. }})