soundsets.lua 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443
  1. --[[
  2. Default Sound Sets
  3. ------------------
  4. Order is very important when adding a sound set so it will play a certain
  5. set of sounds before any another.
  6. --]]
  7. -- Underwater sounds play when player head is submerged
  8. ambience.add_set("underwater", {
  9. frequency = 1000,
  10. sounds = {
  11. {name = "scuba", length = 8}
  12. },
  13. sound_check = function(def)
  14. if minetest.registered_nodes[def.head_node]
  15. and minetest.registered_nodes[def.head_node].groups.water then
  16. return "underwater"
  17. end
  18. end
  19. })
  20. -- Splashing sound plays when player walks inside water nodes (if enabled)
  21. if minetest.settings:get_bool("ambience_water_move") ~= false then
  22. -- override default water sounds
  23. minetest.override_item("default:water_source", { sounds = {} })
  24. minetest.override_item("default:water_flowing", { sounds = {} })
  25. minetest.override_item("default:river_water_source", { sounds = {} })
  26. minetest.override_item("default:river_water_flowing", { sounds = {} })
  27. ambience.add_set("splash", {
  28. frequency = 1000,
  29. sounds = {
  30. {name = "default_water_footstep", length = 2}
  31. },
  32. sound_check = function(def)
  33. if minetest.registered_nodes[def.feet_node]
  34. and minetest.registered_nodes[def.feet_node].groups.water then
  35. local control = def.player:get_player_control()
  36. if control.up or control.down or control.left or control.right then
  37. return "splash"
  38. end
  39. end
  40. end
  41. })
  42. end
  43. -- check for env_sounds mod, if not found enable water flowing and lava sounds
  44. if not minetest.get_modpath("env_sounds") then
  45. -- Water sound plays when near flowing water
  46. ambience.add_set("flowing_water", {
  47. frequency = 1000,
  48. sounds = {
  49. {name = "waterfall", length = 6}
  50. },
  51. nodes = {"default:water_flowing"},
  52. sound_check = function(def)
  53. local c = (def.totals["default:water_flowing"] or 0)
  54. if c > 40 then
  55. return "flowing_water", 0.5
  56. elseif c > 5 then
  57. return "flowing_water"
  58. end
  59. end
  60. })
  61. -- River sound plays when near flowing river
  62. ambience.add_set("river", {
  63. frequency = 1000,
  64. sounds = {
  65. {name = "river", length = 4, gain = 0.1}
  66. },
  67. nodes = {"default:river_water_flowing"},
  68. sound_check = function(def)
  69. local c = (def.totals["default:river_water_flowing"] or 0)
  70. if c > 20 then
  71. return "river", 0.5
  72. elseif c > 5 then
  73. return "river"
  74. end
  75. end
  76. })
  77. -- Lava sound plays when near lava
  78. ambience.add_set("lava", {
  79. frequency = 1000,
  80. sounds = {
  81. {name = "lava", length = 7}
  82. },
  83. nodes = {"default:lava_source", "default:lava_flowing"},
  84. sound_check = function(def)
  85. local c = (def.totals["default:lava_source"] or 0)
  86. + (def.totals["default:lava_flowing"] or 0)
  87. if c > 20 then
  88. return "lava", 0.5
  89. elseif c > 5 then
  90. return "lava"
  91. end
  92. end
  93. })
  94. else
  95. print ("[Ambience] found env_sounds, flowing water and lava sounds disabled.")
  96. end
  97. -- Only add fire sounds set if flame_sound is disabled or fire redo active
  98. local flame_sound = minetest.settings:get_bool("flame_sound", true)
  99. local fire_redo = minetest.get_modpath("fire") and fire.mod and fire.mod == "redo"
  100. if flame_sound and not fire_redo then
  101. print ("[Ambience] fire sounds not enabled, already active in fire mod.")
  102. else
  103. -- Small fire sound plays when near lower than 9 flames
  104. ambience.add_set("smallfire", {
  105. frequency = 1000,
  106. sounds = {
  107. {name = "fire_small", length = 6, gain = 0.1}
  108. },
  109. nodes = {"fire:basic_flame", "fire:permanent_flame"},
  110. sound_check = function(def)
  111. local c = (def.totals["fire:basic_flame"] or 0)
  112. + (def.totals["fire:permanent_flame"] or 0)
  113. if c > 5 and c < 9 then
  114. return "smallfire", 0.5
  115. elseif c > 0 and c < 9 then
  116. return "smallfire"
  117. end
  118. end
  119. })
  120. -- Large fire sound plays when near more than 9 flames
  121. ambience.add_set("largefire", {
  122. frequency = 1000,
  123. sounds = {
  124. {name = "fire_large", length = 8, gain = 0.4}
  125. },
  126. sound_check = function(def)
  127. -- fire nodes were added in last set, so don't need to be added in this one
  128. local c = (def.totals["fire:basic_flame"] or 0)
  129. + (def.totals["fire:permanent_flame"] or 0)
  130. if c > 20 then
  131. return "largefire", 0.5
  132. elseif c > 8 then
  133. return "largefire"
  134. end
  135. end
  136. })
  137. end
  138. -- Beach sounds play when below y-pos 6 and 150+ water source found
  139. ambience.add_set("beach", {
  140. frequency = 40,
  141. sounds = {
  142. {name = "seagull", length = 4.5, ephemeral = true},
  143. {name = "beach", length = 13},
  144. {name = "gull", length = 1, ephemeral = true},
  145. {name = "beach_2", length = 6}
  146. },
  147. nodes = {"default:water_source"},
  148. sound_check = function(def)
  149. local c = (def.totals["default:water_source"] or 0)
  150. if def.pos.y < 6 and def.pos.y > 0 and c > 150 then
  151. return "beach"
  152. end
  153. end
  154. })
  155. -- Ice sounds play when 100 or more ice are nearby
  156. ambience.add_set("ice", {
  157. frequency = 250,
  158. sounds = {
  159. {name = "icecrack", length = 5, gain = 0.7},
  160. {name = "desertwind", length = 8},
  161. {name = "wind", length = 9}
  162. },
  163. nodes = {"default:ice"},
  164. sound_check = function(def)
  165. local c = (def.totals["default:ice"] or 0)
  166. if c > 100 then
  167. return "ice"
  168. end
  169. end
  170. })
  171. -- Desert sounds play when near 150+ desert or normal sand
  172. ambience.add_set("desert", {
  173. frequency = 20,
  174. sounds = {
  175. {name = "coyote", length = 2.5, ephemeral = true},
  176. {name = "wind", length = 9},
  177. {name = "desertwind", length = 8}
  178. },
  179. nodes = {"default:desert_sand", "default:sand"},
  180. sound_check = function(def)
  181. local c = (def.totals["default:desert_sand"] or 0)
  182. + (def.totals["default:sand"] or 0)
  183. if c > 150 and def.pos.y > 10 then
  184. return "desert"
  185. end
  186. end
  187. })
  188. -- Cave sounds play when below player position Y -25 and water nearby
  189. ambience.add_set("cave", {
  190. frequency = 60,
  191. sounds = {
  192. {name = "drippingwater1", length = 1.5, ephemeral = true},
  193. {name = "drippingwater2", length = 1.5, ephemeral = true},
  194. {name = "bats", length = 5, ephemeral = true}
  195. },
  196. sound_check = function(def)
  197. local c = (def.totals["default:water_source"] or 0)
  198. if c > 0 and def.pos.y < -25 then
  199. return "cave"
  200. end
  201. end
  202. })
  203. -- Jungle sounds play during day and when around 90 jungletree trunks
  204. ambience.add_set("jungle", {
  205. frequency = 200,
  206. sounds = {
  207. {name = "jungle_day_1", length = 7},
  208. {name = "deer", length = 7, ephemeral = true},
  209. {name = "canadianloon2", length = 14},
  210. {name = "bird1", length = 11},
  211. {name = "peacock", length = 2, ephemeral = true}
  212. },
  213. nodes = {"default:jungletree"},
  214. sound_check = function(def)
  215. local c = (def.totals["default:jungletree"] or 0)
  216. if def.tod > 0.2 and def.tod < 0.8 and c > 90 then
  217. return "jungle"
  218. end
  219. end
  220. })
  221. -- Jungle sounds play during night and when around 90 jungletree trunks
  222. ambience.add_set("jungle_night", {
  223. frequency = 200,
  224. sounds = {
  225. {name = "jungle_night_1", length = 4, ephemeral = true},
  226. {name = "jungle_night_2", length = 4, ephemeral = true},
  227. {name = "deer", length = 7, ephemeral = true},
  228. {name = "frog", length = 1, ephemeral = true}
  229. },
  230. sound_check = function(def)
  231. -- jungle tree was added in last set, so doesnt need to be added in this one
  232. local c = (def.totals["default:jungletree"] or 0)
  233. if (def.tod < 0.2 or def.tod > 0.8) and c > 90 then
  234. return "jungle_night"
  235. end
  236. end
  237. })
  238. -- Daytime sounds play during day when around leaves and above ground
  239. ambience.add_set("day", {
  240. frequency = 40,
  241. sounds = {
  242. {name = "cardinal", length = 3, ephemeral = true},
  243. {name = "craw", length = 3, ephemeral = true},
  244. {name = "bluejay", length = 6, ephemeral = true},
  245. {name = "robin", length = 4, ephemeral = true},
  246. {name = "bird1", length = 11},
  247. {name = "bird2", length = 6, ephemeral = true},
  248. {name = "crestedlark", length = 6, ephemeral = true},
  249. {name = "peacock", length = 2, ephemeral = true},
  250. {name = "wind", length = 9}
  251. },
  252. nodes = {"group:leaves"},
  253. sound_check = function(def)
  254. -- we used group:leaves but still need to specify actual nodes for total
  255. local c = (def.totals["default:leaves"] or 0)
  256. + (def.totals["default:bush_leaves"] or 0)
  257. + (def.totals["default:pine_needles"] or 0)
  258. + (def.totals["default:aspen_leaves"] or 0)
  259. if (def.tod > 0.2 and def.tod < 0.8)
  260. and def.pos.y > -10
  261. and c > 5 then
  262. return "day"
  263. end
  264. end
  265. })
  266. -- Nighttime sounds play at night when above ground near leaves
  267. ambience.add_set("night", {
  268. frequency = 40,
  269. sounds = {
  270. {name = "hornedowl", length = 2, ephemeral = true},
  271. {name = "wolves", length = 4, gain = 0.4, ephemeral = true},
  272. {name = "cricket", length = 6, ephemeral = true},
  273. {name = "deer", length = 7, ephemeral = true},
  274. {name = "frog", length = 1, ephemeral = true}
  275. },
  276. sound_check = function(def)
  277. -- leaves were added in last set, so don't need to be added to this one
  278. local c = (def.totals["default:leaves"] or 0)
  279. + (def.totals["default:bush_leaves"] or 0)
  280. + (def.totals["default:pine_needles"] or 0)
  281. + (def.totals["default:aspen_leaves"] or 0)
  282. if (def.tod < 0.2 or def.tod > 0.8)
  283. and def.pos.y > -10
  284. and c > 5 then
  285. return "night"
  286. end
  287. end
  288. })
  289. -- Winds play when player is above 50 y-pos or near 150+ snow blocks
  290. ambience.add_set("high_up", {
  291. frequency = 40,
  292. sounds = {
  293. {name = "desertwind", length = 8},
  294. {name = "wind", length = 9}
  295. },
  296. nodes = {"default:snowblock"},
  297. sound_check = function(def)
  298. local c = (def.totals["default:snowblock"] or 0)
  299. if def.pos.y > 50 or c > 150 then
  300. return "high_up"
  301. end
  302. end
  303. })