View Single Post
04/18/19, 08:16 AM   #5
Supportic
Join Date: Mar 2019
Posts: 24
So basically I found this big Sound list on the wiki https://wiki.esoui.com/Sounds, so I decided to go through it and maybe find some sounds for my next addon. Entering everything by myself in chat with "/script PlaySound(SOUNDS.ABILITY_CASTER_DEAD)" wasn't the right solution for me so I decided to write a little script which iterates through the list and play each sound one by one after a certain amount of delay.

My list structure was this:

Lua Code:
  1. UAN.Sounds = {
  2.   ["ABILITY_CASTER_BUSY"] = SOUNDS.ABILITY_CASTER_BUSY,
  3.   ["ABILITY_CASTER_DEAD"] = SOUNDS.ABILITY_CASTER_DEAD,
  4.   ["ABILITY_CASTER_DISORIENTED"] = SOUNDS.ABILITY_CASTER_DISORIENTED,
  5.   ["ABILITY_CASTER_FEARED"] = SOUNDS.ABILITY_CASTER_FEARED,
  6.   ["ABILITY_CASTER_LEVITATED"] = SOUNDS.ABILITY_CASTER_LEVITATED,
  7.   ["ABILITY_CASTER_PACIFIED"] = SOUNDS.ABILITY_CASTER_PACIFIED,
  8. }

After my game freezed, everytime I wanted to make a pause between the sounds, some kindly devs suggested me to use LibAsync for my purpose.
LibAsync: https://www.esoui.com/downloads/info2125-LibAsync.html
How to LibAsync: https://wiki.esoui.com/Running_LUA-Code_asynchroneously

The solution for my problem which worked at the end was the following code:

Lua Code:
  1. local async = LibStub("LibAsync")
  2. local task = async:Create("wait")
  3. local count = 1;
  4.  
  5. local function someFunction(key, value)
  6.   PlaySound(value)
  7.   d(strfmt("[%d]: %s", count, key))
  8.   count = count + 1
  9.   -- delay my own task by doing nothing for 3s
  10.   task:Delay(3000, function() end)
  11. end
  12.  
  13. local function testSounds()
  14.   -- go through the list asynchronous and execute someFunction() in each step
  15.   task:For(pairs(UAN.Sounds)):Do(someFunction)
  16.   count = 0
  17. end
  18.  
  19. SLASH_COMMANDS["/test"] = testSounds

Last edited by Supportic : 04/18/19 at 08:25 AM.
  Reply With Quote