Page 108 of 111 FirstFirst ... 85898106107108109110 ... LastLast
Results 1,071 to 1,080 of 1109

Thread: WeakAuras Tutoring Thread

  1. #1071

    Default

    This is mostly for Kulldam, but if anyone wants to help me with this, I'd appreciate it.



    So I was trying to use the PG helper on the weakaura_creations page, and this happened. I found some anecdotal literature that a nil value will be returned for IsInProvingGround if you're not actually in the combat portion of it, but I am, however the aura itself doesn't seem to work; I put all the data in the table for my class/spec, but it just throws this error at me instead of displaying anything. Perhaps this is a WeakAuras (the addon) thing and not a custom code thing?

    Ideas? Many thanks in-advance.

  2. #1072

    Default

    Quote Originally Posted by bew View Post
    This is mostly for Kulldam, but if anyone wants to help me with this, I'd appreciate it.



    So I was trying to use the PG helper on the weakaura_creations page, and this happened. I found some anecdotal literature that a nil value will be returned for IsInProvingGround if you're not actually in the combat portion of it, but I am, however the aura itself doesn't seem to work; I put all the data in the table for my class/spec, but it just throws this error at me instead of displaying anything. Perhaps this is a WeakAuras (the addon) thing and not a custom code thing?

    Ideas? Many thanks in-advance.
    Hmm, it looks like Blizzard removed the IsInProvingGround API function in 6.0/WoD. =/

    A simple fix for now would be to look in "Proving Grounds Helper Data Group > Provind Groups Helper - Data > Trigger > Custom Trigger" and change the second to last line from:

    Code:
    if IsInProvingGround() then SetValue(DATA, 'ProvingGroundsData') end


    to

    Code:
    SetValue(DATA, 'ProvingGroundsData')


    Then to make sure the groups only load when you want, for both the "Proving Grounds Helper Data Group" and "Proving Grounds Helper Wave Group" open "Load" and check "Zone" and enter the zone name you see when you're inside the proving ground (I can't test it atm).

    Hope that helps, good luck!

  3. #1073

    Default

    Quote Originally Posted by Kulldam View Post
    Hmm, it looks like Blizzard removed the IsInProvingGround API function in 6.0/WoD. =/

    A simple fix for now would be to look in "Proving Grounds Helper Data Group > Provind Groups Helper - Data > Trigger > Custom Trigger" and change the second to last line from:

    Code:
    if IsInProvingGround() then SetValue(DATA, 'ProvingGroundsData') end


    to

    Code:
    SetValue(DATA, 'ProvingGroundsData')


    Then to make sure the groups only load when you want, for both the "Proving Grounds Helper Data Group" and "Proving Grounds Helper Wave Group" open "Load" and check "Zone" and enter the zone name you see when you're inside the proving ground (I can't test it atm).

    Hope that helps, good luck!
    Works now; thank you!

  4. #1074

    Default

    Pardon for the constant barrage of questions, but I really am getting stuck in some places with learning lua and implementing it into WeakAuras. Currently I'm trying to make a single sound file loop when an aura is triggered, but I can't seem to figure out how to make it loop and then stop as soon as the aura is untriggered. Of course I could make a simple ~10s sound file for this, but I'd rather do a loop with code (10 seconds being arbitrary).

    Help again please? Pretty please?
    Last edited by bew; 10-01-2015 at 12:51 PM.

  5. #1075

    Default

    Quote Originally Posted by bew View Post
    Pardon for the constant barrage of questions, but I really am getting stuck in some places with learning lua and implementing it into WeakAuras. Currently I'm trying to make a single sound file loop when an aura is triggered, but I can't seem to figure out how to make it loop and then stop as soon as the aura is untriggered. Of course I could make a simple ~10s sound file for this, but I'd rather do a loop with code (10 seconds being arbitrary).

    Help again please? Pretty please?
    I'm not sure I've seen a request to loop sounds before and it was intriguing enough to give it a whirl.

    The main issue is that the game API doesn't offer a means to stop the playback of a sound once it has begun. Therefore, any looped sounds you're utilizing will need to be short enough that you don't mind a full playback of the most recent cycle to take place. This behavior can be faked somewhat by using the PlayMusic and StopMusic methods, but I don't think these are viable options for most users because it uses the music sound channel. This means for users (like myself) that don't often have in-game music enabled, nothing will occur. Moreover, if you DO play with music enabled, when a new music is played by the game itself, it overwrites the playback of a custom sound.

    This leaves us with the aforementioned problem. We can play sounds easily with PlaySoundFile but just be aware a full playback must take place each time.

    Anyway, the solution I came up with should be fairly robust without too much complexity. At first I had a closed system whereby we'd specify a single sound file to play only, but realized that was a silly way to go about it. What if the user wants multiple sounds files to be loopable based on differing triggers/events?

    Therefore, instead I made a simple Sound Looper display (seen below) that acts as a sort of plugin.

    Sound Looper


    Since you stated you're trying to learn Lua Bew I'll detail the workings of a code a bit.

    Firstly, I knew in order to create a "loop" we effectively have to execute some code every frame and upon each pass, check whether it is appropriate to playback the sound at that time. I also knew I needed a way to specify when to start and stop the looping from other Displays, so I opted to use a pair of custom events via the WeakAuras.ScanEvents method that can be called elsewhere.

    So the Sound Looper - Trigger looks like this:

    Code:
    function(event, path, duration) -- SOUND LOOPER TRIGGER
      if event == 'LOOP_SOUND_ON' then
        aura_env.sounds = aura_env.sounds or {}    
        -- Check exists
        for i,sound in pairs(aura_env.sounds) do
          if sound.path == path then
            sound.active = true
            sound.duration = duration
            return true
          end
        end
        tinsert(aura_env.sounds, {active = true, duration = duration, path = path})
        return true
      end
    end


    First, I'm expecting three parameters: event for the standard event name, path is the path to our sound file, and duration is the approximate duration of the sound file (more on this later). We then verify the triggering event is our custom LOOP_SOUND_ON event and from there, start processing.

    Using the aura_env table is a simple way to store localized data, so we're using the .sounds table to store a unique table for each sound file we want to loop. This separation allows the playback of multiple different sounds based on unique events/triggers without fear of contamination.

    So the first loop code chunk there just checks through the .sounds table and verifies whether the passed in sound from our LOOP_SOUND_ON triggering event is actually already in the database. If so, we make sure to set the .active = true since we know this LOOP_SOUND_ON triggering event wants that sound to be active and looping, then return true so the Display itself is active and functional.

    In the event that this is a new sound we haven't seen before, we insert it into the database table and again return true to show our Display.

    The Untrigger is very similar but in reverse:

    Code:
    function(event, path) -- SOUND LOOPER UNTRIGGER
      if event == 'LOOP_SOUND_OFF' then
        aura_env.sounds = aura_env.sounds or {}
        -- Deactivate passed sound
        local deactivate = true
        for i,sound in pairs(aura_env.sounds) do
          if sound.path == path then
            -- Inactive
            sound.active = false
          end
          if sound.active then
            deactivate = false
          end
        end
        return deactivate
      end
    end


    Again we start by looping through our .sounds database and try to find an existing match to the path sound file being passed in as an argument with the LOOP_SOUND_OFF event. If a match is found, we know that we're meant to halt looping of that particular sound, so we set .active = false.

    For efficiency while we're looping through all the sounds to find a match for the passed in path, we're also checking the .active flag for each. This is to determine if any sounds in the database are currently .active at all. If an .active sound is in the database, we ensure that deactivate = false, then at the end we return deactivate, ensuring that if no sounds are active, we deactivate the Display entirely, but if at least one sound is active, then we don't disable it just yet.



    So we have our overall handlers for enabling/disabling a particular sound file within the loop system using the LOOP_SOUND_ON/_OFF events, but we also need the Every Frame functionality to determine when to actually trigger a sound playback. That's best performed in the Custom Text section of this Display:

    Code:
    function() -- SOUND LOOPER TEXT
      local timestamp = GetTime()
      if not aura_env.sounds then return end
      for i, sound in pairs(aura_env.sounds) do
        if sound.active then
          if sound.lastPlayback then
            if (sound.lastPlayback + sound.duration) < timestamp then
              sound.lastPlayback = timestamp
              PlaySoundFile(sound.path, 'Master')
            end
          else
            sound.lastPlayback = timestamp
            PlaySoundFile(sound.path, 'Master')
          end
        end
      end
    end


    First we grab the current timestamp for use throughout and also verify our .sounds database has something in it.

    Now it's just a matter of looping through each sound and checking the appropriate flags. First we make sure .active is true. Next we check for a .lastPlayback timestamp if one exists; if so, add the .lastPlayback timestamp to the .duration of the sound and compare it to the current timestamp. If the current timestamp is greater than the .lastPlayback + .duration, then we know the previous playback of this particular sound has already ended and we can therefore trigger another playback.

    Doing so, we update the .lastPlayback to the current timestamp and PlaySoundFile using the 'Master' sound channel (the same channel most bossmods use and thus the most likely to be beneficial). And of course if no .lastPlayback entry existed in the first place, we do the same and play the file (in this case for the first time).



    With the Sound Looper Display all ready to go, we need to ensure we actually trigger it by passing along the appropriate LOOP_SOUND_ON/LOOP_SOUND_OFF events with appropriate arguments. To test this, I created two simply Icon Displays (on my Monk, so using Soothing Mist and Renewing Mist as my test triggers, but anything will work of course):

    Loop Sound Test Group


    Since any Display can be hooked into causing sound looping, all the critical code is under the Actions tab.

    First the On Init just specifies a few basic values (though we need not specify them here, they can be set in the event calls later if needed):

    Code:
    aura_env.soundPath = "Sound/SPELLS/Bonk3.ogg"
    aura_env.soundDuration = 0.5


    The .soundDuration is an important value because it determines how frequently the playback will occur during looping. It should be your best approximation of the duration of playback for that particular sound file, or slightly longer.

    Lastly, we need to cause our looping to start and stop based on the trigger/untrigger of whatever Display we're tied to, so we use the custom On Show code to trigger the LOOP_SOUND_ON event:

    Code:
    WeakAuras.ScanEvents('LOOP_SOUND_ON', aura_env.soundPath, aura_env.soundDuration)


    By passing the appropriate path and duration arguments, our SOUND LOOPER Display will be able to add this new sound to the system and deal with it as necessary without issue with other sounds.

    On Hide is similar but _OFF event:

    Code:
    WeakAuras.ScanEvents('LOOP_SOUND_OFF', aura_env.soundPath, aura_env.soundDuration)




    Hope that answers your question sufficiently and if nothing else, should provide a good starting point for doing sound looping based on miscellaneous triggers.

  6. #1076

    Default

    Quote Originally Posted by Kulldam View Post
    I'm not sure I've seen a request to loop sounds before and it was intriguing enough to give it a whirl.

    I love you. I was gonna try do something similar, I had some of the same ideas in mind, but I probably wouldn't have gotten it this clean in any reasonable amount of time. Thanks for being awesome.

  7. #1077

    Default

    Quote Originally Posted by Kulldam View Post
    I'm not sure I've seen a request to loop sounds before and it was intriguing enough to give it a whirl.
    Thank you so much Kulldam. That's some impressive work, and the time you spent to explain each part... exceptional. Krazyito and I had a good conversation about this WA in mumble and how you went about doing it; it's very insightful stuff for someone both new to lua and somewhat new to integrating lua into WeakAuras. It would have taken me hours to figure out how to do this, but once again, you go above and beyond.

    Thanks yet again for the help.

  8. #1078

    Default

    Draenic Philosopher's Stone automatic seller

    Draenic Philosopher's Stones are sold to merchant 25g each, and most annoying part when grinding money from this is selling large amount of stones.
    So I'm using auto selling WA code for this. You need to open both trade skill frame and a merchant frame then click 'Create All' button. Stones will be sold when inventory is full or out of reagents, then notifying sound will be played.

    Spoiler


  9. #1079

    Default

    Hi new to the forums and just learning lua and getting into building custom auras. I have a question about the texture info field with custom triggers. Basically what arguments is texture info expecting to have returned? I have searched fairly extensively and have found little information on the topic. What I would like to do is have the alpha of an existing progress texture change based on range, I have a set of custom range functions already written in my own addon so this isn't the problem. I am just hoping that I can set the alpha of the progress texture (hopefully both foreground and background textures separately) based on the return from my range function. If its not possible to do this in a single aura then I could use multiple auras with differing alpha value and just include the range check in the trigger for those auras but I am hoping I can just do this in one aura to save bloat. Thanks for any help you are able to provide.

  10. #1080

    Default Draenic Philosopher's Stone weakaura

    Quote Originally Posted by Sceone View Post
    Draenic Philosopher's Stone automatic seller

    Draenic Philosopher's Stones are sold to merchant 25g each, and most annoying part when grinding money from this is selling large amount of stones.
    So I'm using auto selling WA code for this. You need to open both trade skill frame and a merchant frame then click 'Create All' button. Stones will be sold when inventory is full or out of reagents, then notifying sound will be played.
    This is pure awesomeness.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •