2
0

nodes.lua 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282
  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 = S("Savanna 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 = S("Wet Savanna 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. -- Registered before the stairs so the stairs get fuel recipes.
  141. minetest.register_craft({
  142. type = "fuel",
  143. recipe = "farming:straw",
  144. burntime = 3,
  145. })
  146. do
  147. local recipe = "farming:straw"
  148. local groups = {snappy = 3, flammable = 4}
  149. local images = {"farming_straw.png"}
  150. local sounds = default.node_sound_leaves_defaults()
  151. stairs.register_stair("straw", recipe, groups, images, S("Straw Stair"),
  152. sounds, true)
  153. stairs.register_stair_inner("straw", recipe, groups, images, "",
  154. sounds, true, S("Inner Straw Stair"))
  155. stairs.register_stair_outer("straw", recipe, groups, images, "",
  156. sounds, true, S("Outer Straw Stair"))
  157. stairs.register_slab("straw", recipe, groups, images, S("Straw Slab"),
  158. sounds, true)
  159. end
  160. minetest.register_abm({
  161. label = "Farming soil",
  162. nodenames = {"group:field"},
  163. interval = 15,
  164. chance = 4,
  165. action = function(pos, node)
  166. local n_def = minetest.registered_nodes[node.name] or nil
  167. local wet = n_def.soil.wet or nil
  168. local base = n_def.soil.base or nil
  169. local dry = n_def.soil.dry or nil
  170. if not n_def or not n_def.soil or not wet or not base or not dry then
  171. return
  172. end
  173. pos.y = pos.y + 1
  174. local nn = minetest.get_node_or_nil(pos)
  175. if not nn or not nn.name then
  176. return
  177. end
  178. local nn_def = minetest.registered_nodes[nn.name] or nil
  179. pos.y = pos.y - 1
  180. if nn_def and nn_def.walkable and minetest.get_item_group(nn.name, "plant") == 0 then
  181. minetest.set_node(pos, {name = base})
  182. return
  183. end
  184. -- check if there is water nearby
  185. local wet_lvl = minetest.get_item_group(node.name, "wet")
  186. if minetest.find_node_near(pos, 3, {"group:water"}) then
  187. -- if it is dry soil and not base node, turn it into wet soil
  188. if wet_lvl == 0 then
  189. minetest.set_node(pos, {name = wet})
  190. end
  191. else
  192. -- only turn back if there are no unloaded blocks (and therefore
  193. -- possible water sources) nearby
  194. if not minetest.find_node_near(pos, 3, {"ignore"}) then
  195. -- turn it back into base if it is already dry
  196. if wet_lvl == 0 then
  197. -- only turn it back if there is no plant/seed on top of it
  198. if minetest.get_item_group(nn.name, "plant") == 0 and minetest.get_item_group(nn.name, "seed") == 0 then
  199. minetest.set_node(pos, {name = base})
  200. end
  201. -- if its wet turn it back into dry soil
  202. elseif wet_lvl == 1 then
  203. minetest.set_node(pos, {name = dry})
  204. end
  205. end
  206. end
  207. end,
  208. })
  209. -- Make default:grass_* occasionally drop wheat seed
  210. for i = 1, 5 do
  211. minetest.override_item("default:grass_"..i, {drop = {
  212. max_items = 1,
  213. items = {
  214. {items = {"farming:seed_wheat"}, rarity = 5},
  215. {items = {"default:grass_1"}},
  216. }
  217. }})
  218. end
  219. -- Make default:junglegrass occasionally drop cotton seed.
  220. -- This is the old source of cotton seeds that makes no sense. It is a leftover
  221. -- from Mapgen V6 where junglegrass was the only plant available to be a source.
  222. -- This source is kept for now to avoid disruption but should probably be
  223. -- removed in future as players get used to the new source.
  224. minetest.override_item("default:junglegrass", {drop = {
  225. max_items = 1,
  226. items = {
  227. {items = {"farming:seed_cotton"}, rarity = 8},
  228. {items = {"default:junglegrass"}},
  229. }
  230. }})
  231. -- Wild cotton as a source of cotton seed
  232. minetest.register_node("farming:cotton_wild", {
  233. description = S("Wild Cotton"),
  234. drawtype = "plantlike",
  235. waving = 1,
  236. tiles = {"farming_cotton_wild.png"},
  237. inventory_image = "farming_cotton_wild.png",
  238. wield_image = "farming_cotton_wild.png",
  239. paramtype = "light",
  240. sunlight_propagates = true,
  241. walkable = false,
  242. buildable_to = true,
  243. groups = {snappy = 3, attached_node = 1, flammable = 4},
  244. drop = "farming:seed_cotton",
  245. sounds = default.node_sound_leaves_defaults(),
  246. selection_box = {
  247. type = "fixed",
  248. fixed = {-6 / 16, -8 / 16, -6 / 16, 6 / 16, 5 / 16, 6 / 16},
  249. },
  250. })