soundsets.lua 8.5 KB

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