api.txt 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. Ambience Lite API
  2. =================
  3. This short guide will show you how to add sound sets into ambience mod for the
  4. api to use and play sounds accordingly. Please note that the order they are
  5. added will affect sound checks, so high priority sets first.
  6. Function Usage
  7. ==============
  8. Adding Sound Set
  9. ----------------
  10. ambience.add_set(set_name, def)
  11. 'set_name' contains the name of the sound set to add
  12. 'def' contains the following:
  13. 'frequency' how often the sound set is played (1 to 1000) higher is more
  14. 'nodes' contains a table of nodes needed for checks
  15. 'sound_check(def)' function to check if sounds can be played, def contains:
  16. 'player' player userdata
  17. 'pos' position of player
  18. 'tod' time of day
  19. 'totals' totals for each node e.g. def.totals["default:sand"]
  20. 'positions' position data for every node found
  21. 'head_node' name of node at player head level
  22. 'feet_node' nameof node at player foot level
  23. This will let you add a set or sounds with the frequency it's used and check
  24. function for it to play.
  25. e.g.
  26. ambience.add_set("windy", {
  27. frequency = 500,
  28. nodes = {"default:sand"},
  29. sounds = {
  30. {name = "wind", length = 9, gain = 0.3},
  31. {name = "desertwind", length = 8, gain = 0.3},
  32. },
  33. sound_check = function(def)
  34. local number = totals["default:sand"] or 0 -- yep, can also be nil
  35. if number > 20 then
  36. return "windy", 0.2 -- return set to play and optional gain volume
  37. end
  38. end,
  39. })
  40. Getting Sound Set
  41. -----------------
  42. ambience.get_set(set_name)
  43. This returns a table containing all of the set information like example above.
  44. e.g.
  45. local myset = ambience.get_set("windy") -- returns everything inside {} above.
  46. Deleting Sound Set
  47. ------------------
  48. ambience.del_set(set_name)
  49. This will remove a sound set from the list.
  50. e.g.
  51. ambience.del_set("windy")
  52. Additional Commands
  53. ===================
  54. Two volume commands have been added to set sound and music volume:
  55. /svol (0.1 to 1.0)
  56. /mvol (0.1 to 1.0) -- 0 can be used to stop music from playing when it begins
  57. Music
  58. =====
  59. Music can be stored in the sounds folder either on server or locally and so long
  60. as it is named 'ambience_music.1', 'ambience_music.2' etc. then it will select
  61. a song randomly at midnight and play player.