2
0

nodes.lua 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. -- farming/nodes.lua
  2. -- support for MT game translation.
  3. local S = farming.get_translator
  4. minetest.override_item("default:dirt", {
  5. soil = {
  6. base = "default:dirt",
  7. dry = "farming:soil",
  8. wet = "farming:soil_wet"
  9. }
  10. })
  11. minetest.override_item("default:dirt_with_grass", {
  12. soil = {
  13. base = "default:dirt_with_grass",
  14. dry = "farming:soil",
  15. wet = "farming:soil_wet"
  16. }
  17. })
  18. minetest.override_item("default:dirt_with_dry_grass", {
  19. soil = {
  20. base = "default:dirt_with_dry_grass",
  21. dry = "farming:soil",
  22. wet = "farming:soil_wet"
  23. }
  24. })
  25. minetest.override_item("default:dirt_with_rainforest_litter", {
  26. soil = {
  27. base = "default:dirt_with_rainforest_litter",
  28. dry = "farming:soil",
  29. wet = "farming:soil_wet"
  30. }
  31. })
  32. minetest.override_item("default:dirt_with_coniferous_litter", {
  33. soil = {
  34. base = "default:dirt_with_coniferous_litter",
  35. dry = "farming:soil",
  36. wet = "farming:soil_wet"
  37. }
  38. })
  39. minetest.override_item("default:dry_dirt", {
  40. soil = {
  41. base = "default:dry_dirt",
  42. dry = "farming:dry_soil",
  43. wet = "farming:dry_soil_wet"
  44. }
  45. })
  46. minetest.override_item("default:dry_dirt_with_dry_grass", {
  47. soil = {
  48. base = "default:dry_dirt_with_dry_grass",
  49. dry = "farming:dry_soil",
  50. wet = "farming:dry_soil_wet"
  51. }
  52. })
  53. minetest.register_node("farming:soil", {
  54. description = S("Soil"),
  55. tiles = {"default_dirt.png^farming_soil.png", "default_dirt.png"},
  56. drop = "default:dirt",
  57. groups = {crumbly=3, not_in_creative_inventory=1, soil=2, grassland = 1, field = 1},
  58. sounds = default.node_sound_dirt_defaults(),
  59. soil = {
  60. base = "default:dirt",
  61. dry = "farming:soil",
  62. wet = "farming:soil_wet"
  63. }
  64. })
  65. minetest.register_node("farming:soil_wet", {
  66. description = S("Wet Soil"),
  67. tiles = {"default_dirt.png^farming_soil_wet.png", "default_dirt.png^farming_soil_wet_side.png"},
  68. drop = "default:dirt",
  69. groups = {crumbly=3, not_in_creative_inventory=1, soil=3, wet = 1, grassland = 1, field = 1},
  70. sounds = default.node_sound_dirt_defaults(),
  71. soil = {
  72. base = "default:dirt",
  73. dry = "farming:soil",
  74. wet = "farming:soil_wet"
  75. }
  76. })
  77. minetest.register_node("farming:dry_soil", {
  78. description = "Dry Soil",
  79. tiles = {"default_dry_dirt.png^farming_soil.png", "default_dry_dirt.png"},
  80. drop = "default:dry_dirt",
  81. groups = {crumbly=3, not_in_creative_inventory=1, soil=2, grassland = 1, field = 1},
  82. sounds = default.node_sound_dirt_defaults(),
  83. soil = {
  84. base = "default:dry_dirt",
  85. dry = "farming:dry_soil",
  86. wet = "farming:dry_soil_wet"
  87. }
  88. })
  89. minetest.register_node("farming:dry_soil_wet", {
  90. description = "Wet Dry Soil",
  91. tiles = {"default_dry_dirt.png^farming_soil_wet.png", "default_dry_dirt.png^farming_soil_wet_side.png"},
  92. drop = "default:dry_dirt",
  93. groups = {crumbly=3, not_in_creative_inventory=1, soil=3, wet = 1, grassland = 1, field = 1},
  94. sounds = default.node_sound_dirt_defaults(),
  95. soil = {
  96. base = "default:dry_dirt",
  97. dry = "farming:dry_soil",
  98. wet = "farming:dry_soil_wet"
  99. }
  100. })
  101. minetest.override_item("default:desert_sand", {
  102. groups = {crumbly=3, falling_node=1, sand=1, soil = 1},
  103. soil = {
  104. base = "default:desert_sand",
  105. dry = "farming:desert_sand_soil",
  106. wet = "farming:desert_sand_soil_wet"
  107. }
  108. })
  109. minetest.register_node("farming:desert_sand_soil", {
  110. description = S("Desert Sand Soil"),
  111. drop = "default:desert_sand",
  112. tiles = {"farming_desert_sand_soil.png", "default_desert_sand.png"},
  113. groups = {crumbly=3, not_in_creative_inventory = 1, falling_node=1, sand=1, soil = 2, desert = 1, field = 1},
  114. sounds = default.node_sound_sand_defaults(),
  115. soil = {
  116. base = "default:desert_sand",
  117. dry = "farming:desert_sand_soil",
  118. wet = "farming:desert_sand_soil_wet"
  119. }
  120. })
  121. minetest.register_node("farming:desert_sand_soil_wet", {
  122. description = S("Wet Desert Sand Soil"),
  123. drop = "default:desert_sand",
  124. tiles = {"farming_desert_sand_soil_wet.png", "farming_desert_sand_soil_wet_side.png"},
  125. groups = {crumbly=3, falling_node=1, sand=1, not_in_creative_inventory=1, soil=3, wet = 1, desert = 1, field = 1},
  126. sounds = default.node_sound_sand_defaults(),
  127. soil = {
  128. base = "default:desert_sand",
  129. dry = "farming:desert_sand_soil",
  130. wet = "farming:desert_sand_soil_wet"
  131. }
  132. })
  133. minetest.register_node("farming:straw", {
  134. description = S("Straw"),
  135. tiles = {"farming_straw.png"},
  136. is_ground_content = false,
  137. groups = {snappy=3, flammable=4, fall_damage_add_percent=-30},
  138. sounds = default.node_sound_leaves_defaults(),
  139. })
  140. stairs.register_stair_and_slab(
  141. "straw",
  142. "farming:straw",
  143. {snappy = 3, flammable = 4},
  144. {"farming_straw.png"},
  145. S("Straw Stair"),
  146. S("Straw Slab"),
  147. default.node_sound_leaves_defaults(),
  148. true
  149. )
  150. minetest.register_abm({
  151. label = "Farming soil",
  152. nodenames = {"group:field"},
  153. interval = 15,
  154. chance = 4,
  155. action = function(pos, node)
  156. local n_def = minetest.registered_nodes[node.name] or nil
  157. local wet = n_def.soil.wet or nil
  158. local base = n_def.soil.base or nil
  159. local dry = n_def.soil.dry or nil
  160. if not n_def or not n_def.soil or not wet or not base or not dry then
  161. return
  162. end
  163. pos.y = pos.y + 1
  164. local nn = minetest.get_node_or_nil(pos)
  165. if not nn or not nn.name then
  166. return
  167. end
  168. local nn_def = minetest.registered_nodes[nn.name] or nil
  169. pos.y = pos.y - 1
  170. if nn_def and nn_def.walkable and minetest.get_item_group(nn.name, "plant") == 0 then
  171. minetest.set_node(pos, {name = base})
  172. return
  173. end
  174. -- check if there is water nearby
  175. local wet_lvl = minetest.get_item_group(node.name, "wet")
  176. if minetest.find_node_near(pos, 3, {"group:water"}) then
  177. -- if it is dry soil and not base node, turn it into wet soil
  178. if wet_lvl == 0 then
  179. minetest.set_node(pos, {name = wet})
  180. end
  181. else
  182. -- only turn back if there are no unloaded blocks (and therefore
  183. -- possible water sources) nearby
  184. if not minetest.find_node_near(pos, 3, {"ignore"}) then
  185. -- turn it back into base if it is already dry
  186. if wet_lvl == 0 then
  187. -- only turn it back if there is no plant/seed on top of it
  188. if minetest.get_item_group(nn.name, "plant") == 0 and minetest.get_item_group(nn.name, "seed") == 0 then
  189. minetest.set_node(pos, {name = base})
  190. end
  191. -- if its wet turn it back into dry soil
  192. elseif wet_lvl == 1 then
  193. minetest.set_node(pos, {name = dry})
  194. end
  195. end
  196. end
  197. end,
  198. })
  199. for i = 1, 5 do
  200. minetest.override_item("default:grass_"..i, {drop = {
  201. max_items = 1,
  202. items = {
  203. {items = {"farming:seed_wheat"},rarity = 5},
  204. {items = {"default:grass_1"}},
  205. }
  206. }})
  207. end
  208. minetest.override_item("default:junglegrass", {drop = {
  209. max_items = 1,
  210. items = {
  211. {items = {"farming:seed_cotton"},rarity = 8},
  212. {items = {"default:junglegrass"}},
  213. }
  214. }})