api.txt 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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. If ephemeral is true then no handler will be used and sound will be played in background alongside other sounds.
  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. {name = "crow", length = 3, ephemeral = true},
  33. },
  34. sound_check = function(def)
  35. local number = totals["default:sand"] or 0 -- yep, can also be nil
  36. if number > 20 then
  37. return "windy", 0.2 -- return set to play and optional gain volume
  38. end
  39. end,
  40. })
  41. Getting Sound Set
  42. -----------------
  43. ambience.get_set(set_name)
  44. This returns a table containing all of the set information like example above.
  45. e.g.
  46. local myset = ambience.get_set("windy") -- returns everything inside {} above.
  47. Deleting Sound Set
  48. ------------------
  49. ambience.del_set(set_name)
  50. This will remove a sound set from the list.
  51. e.g.
  52. ambience.del_set("windy")
  53. Additional Commands
  54. ===================
  55. Two volume commands have been added to set sound and music volume:
  56. /svol (0.1 to 1.0)
  57. /mvol (0.1 to 1.0) -- 0 can be used to stop music from playing when it begins
  58. Music
  59. =====
  60. Music can be stored in the sounds folder either on server or locally and so long
  61. as it is named 'ambience_music.1', 'ambience_music.2' etc. then it will select
  62. a song randomly at midnight and play player.