• 0

    posted a message on play random sound file from array
    wohoo; that worked! Thank you very much!
    I'll upload version 1.1 of Servant of the Lich King now. :)

    The next step will involve making a gui with WoW UI Designer; can anyone reccomend a good guide or database for them?
    Posted in: Need Help?
  • 0

    posted a message on play random sound file from array
    I'm sorry for annoying you guys. I am trying your functions. I did completely convert to Adrielle's method before, but it produced the same result as my method did, so I changed it back to mine. I thought it would be best to try to learn by incorporating other code into mine rather than just using someone elses code that they give me.

    Anyway, I have switched over to Adrielle's method, and I found out after intense scrutiny of my code that the immediate problem was that I forgot to put the .wav extensions for the names in the killsounds and deathsounds lists.

    Now, another problem that I had noticed before and is made even more apparent now is that leveling by killing a monster plays the level voice and kill voice, while death plays the kill and death voice. This is undoubtedly because of a flaw in my Voice_OnEvent function. Adrielle's method only added the (self, Event) arguments to my function name, so that is why it is still mostly there.

    Like I said before, I already tried using elseif statements to block multiple sounds being played, but they do nto seem to work. And break statements just stop anything from being played.

    Tekkub's old function that he gave me was something like f:setscript(Event, function() ....)
    Now that works fine for a single list of sounds that I want to play, and I tried really hard to figure out how to get it to play a certain list based on a certain event, but I just cannot figure it out.

    If there is a way to get tekkub's function to work for my current case (death event fires, so play only death list, not death and kill) can someone please explain how to do so, or to explain how to make my current function play multiple sounds?

    local function voice_OnEvent(self, event)
        --Level Up
        if event == "PLAYER_LEVEL_UP" then
            print ("lvl")
            PlaySoundFile("Sound\\Creature\\LichKing\\"..lvlsounds[math.random(#lvlsounds)])
        --Quest Complete
        elseif event == "QUEST_COMPLETE" then
            print ("quest")
            PlaySoundFile("Sound\\Creature\\LichKing\\"..questsounds[math.random(#questsounds)])
        --Death
        elseif event == "PLAYER_DEAD" then
            print ("death")
            PlaySoundFile("Sound\\Creature\\LichKing\\"..deathsounds[math.random(#deathsounds)])
        --Kill
        elseif event == "PLAYER_REGEN_ENABLED" then --and (math.random(2)) == 1 then
            print ("kill")
            PlaySoundFile("Sound\\Creature\\LichKing\\"..killsounds[math.random(#killsounds)])
        end
    end


    Sorry for annoying you guys with this.
    Posted in: Need Help?
  • 0

    posted a message on play random sound file from array
    I added the (self, event) to the function name, and I found out that I needed to add it to the function call in the xml for it to work properly.

    Your print statement code had an error in it, so I changed it to:
    print (Voice_OnEvent(self, event))


    It however, does not print anything.

    So, I instead put an individual print statement after each if statement investigating what events happened.

    -If I level from killing a monster I get a level and kill message and a level voice
    -If I get a kill without a level, I get a kill message but no voice
    -quest message and voice work
    -If I die, then I get a death and kill message but no voice

    I tried turning my several if statements into elseif statements to try to make it only pick one event. This changed nothing, so i tried adding break statements after each playsoundfile statement to make it choose only one. This stopped all sounds and messages.

    This is my new code

    function voice_OnEvent(self, event)
        --Level Up
        if event == "PLAYER_LEVEL_UP" then
            print ("lvl")
            PlaySoundFile("Sound\\Creature\\LichKing\\"..lvlsounds[math.random(#lvlsounds)])  
        --Quest Complete
        elseif event == "QUEST_COMPLETE" then
            print ("quest")
            PlaySoundFile("Sound\\Creature\\LichKing\\"..questsounds[math.random(#questsounds)])
        --Death
        elseif event == "PLAYER_DEAD" then
            print ("death")
            PlaySoundFile("Sound\\Creature\\LichKing\\"..deathsounds[math.random(#deathsounds)])
        --Kill
        elseif event == "PLAYER_REGEN_ENABLED" then --and (math.random(2)) == 1 then
            print ("kill")
            PlaySoundFile("Sound\\Creature\\LichKing\\"..killsounds[math.random(#killsounds)])
        end
    end
    


    I've gone over my lists and I don't know why they aren't working. All four of my lists appear above the function; it is just killsounds and deathsounds that do not work.

    ----------------------------
    -- Sounds to play on kill --
    ----------------------------
    local killsounds = {
        "EH_LichKing_Chapter1Whisper13",
        "EH_LichKing_Chapter1Whisper01",
        "EH_LichKing_Chapter1Whisper04",
        "EH_LichKing_Chapter3Shout03",
        "EH_LichKing_Chapter1Whisper03",
        "EH_LichKing_Chapter1Whisper05",
        "EH_LichKing_Chapter1Whisper12",
        "EH_LichKing_Chapter1Whisper13",
        }
    
    -----------------------------
    -- Sounds to play on death --
    -----------------------------
    local deathsounds = {
        "EH_LichKing_Chapter1Whisper08",
        "EH_LichKing_Chapter1Whisper07",
        "EH_LichKing_Chapter1Whisper09",
        "EH_LichKing_Chapter1Whisper15",
        "EH_LichKing_Chapter1Whisper16",
        }
    Posted in: Need Help?
  • 0

    posted a message on play random sound file from array
    I'd rather keep my xml file for now, it makes things simpler for me. So, the lvlup and quest sounds still work when I change my event listeners to self: but the whole thing stops working the moment I add local or (frame, event) to my voice_OnEvent function.

    Changing PLAYER_LEAVE_COMBAT to PLAYER_REGEN_ENABLED doesn't do anything. That and PLAYER_DEAD still do not work.
    Posted in: Need Help?
  • 0

    posted a message on play random sound file from array
    Hi there,

    I'm having another problem with an addon I am developing. I have very little addon experience but I do have some general programming experience.

    I am making an addon that plays sound files from the mpqs and two of the situations are working, but the last two aren't.

    This is a portion of my lua.

    ----------------------------
    -- Sounds to play on kill --
    ----------------------------
    local killsounds = {"EH_LichKing_Chapter1Whisper08",}
    
    -----------------------------
    -- Sounds to play on death --
    -----------------------------
    local deathsounds = {"EH_LichKing_Chapter1Whisper07",}
        
    -------------------------
    -- Play Sound on event --
    -------------------------
    function voice_OnEvent()
        --Level Up
        if event == "PLAYER_LEVEL_UP" then
            PlaySoundFile("Sound\\Creature\\LichKing\\"..lvlsounds[math.random(#lvlsounds)])  
        end
        --Quest Complete
        if event == "QUEST_COMPLETE" then
            PlaySoundFile("Sound\\Creature\\LichKing\\"..questsounds[math.random(#questsounds)])
        end
        --Death
        if event == "PLAYER_DEAD" then
            PlaySoundFile("Sound\\Creature\\LichKing\\"..deathsounds[math.random(#deathsounds)])
        end
        --Kill
        if event == "PLAYER_LEAVE_COMBAT" and event ~= "PLAYER_DEAD" then
            PlaySoundFile("Sound\\Creature\\LichKing\\"..killsounds[math.random(#killsounds)])    
        end
    end


    Do not worry about the sound lists; I omitted the lvlsounds and questsounds lists because they work, and I only left part of killsounds and deathsounds to save space. The first two if event == statements are only there to show how I succesfully implemented them previously.

    The purpose of the last two if event == statements is to have them fire immediately when the player dies, and immediately after a monster dies. Neither of them seem to work.

    This is my xml:

    <Ui xmlns="http://www.blizzard.com/wow/ui/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.blizzard.com/wow/ui/ ..\FrameXML\UI.xsd">
    	<!-- INCLUDE BEGIN -->
    	<!-- Script files -->
    	<Script file="Servant.lua"/>
    	<!-- INCLUDE END -->
    	<Frame name="Servant_Frame" hidden="false">
    		<Scripts>
    	      		<OnLoad>                    
                        this:RegisterEvent("PLAYER_LEVEL_UP")
                        this:RegisterEvent("QUEST_COMPLETE")
                        this:RegisterEvent("PLAYER_LEAVE_COMBAT")
                        this:RegisterEvent("PLAYER_DEAD")
    	      		</OnLoad>
                    <OnEvent>
                        voice_OnEvent();
                    </OnEvent>
    		</Scripts>
      	</Frame>
    </Ui>


    As you can see, I register all four of the events that I use in the lua, and run the function.

    I once again stress that since my level up and quest completion statements do work, it is just the kill and death statements that don't work.
    Posted in: Need Help?
  • 0

    posted a message on play random sound file from array
    Hey, it works!! Thank you so much!! Guess Tekkub made an itty bitty mistake that Phanx didn't catch.

    I also figured out the answer to my question about the files from the mpq. It must havee just been a typo in the path.
    Posted in: Need Help?
  • 0

    posted a message on play random sound file from array
    EDIT: Thanks for the info egingell. I only added the second line after I found that the first wasn't working.

    Thank you very much for that detailed explanation, Phanx. It was very helpful.

    However, no matter what I do, i just can't get it to work. I know that since I changed the toc, I have to exit wow and load again.

    here is my toc.
    ## Interface: 30200
    ## Title: Servant of the Lich King
    ## Author: oharaandrewlp
    ## Version: 0.5
    ## Notes: The Lich King congratulates you on your feats
    ## DefaultState: Enabled
    ## LoadOnDemand: 0
    servant.lua


    and my lua

    local sounds = {"lvlup.wav", "voice2.wav"}
    local f = CreateFrame("Frame")
    f:RegisterEvent("PLAYER_LEVEL_UP")
    f:SetScript("OnEvent", function() PlaySoundFile("Interface\\Addons\\Servant\\Sounds"..sounds[math.random(#sounds)]) end)


    It just doesn't work!
    Posted in: Need Help?
  • 0

    posted a message on play random sound file from array
    your function does not seem to work. I had already registered the level up event in the OnLoad section of my xml and the event already triggers my existing function properly, so I do not want to change it unless absolutely necessary.

    but I gave your method a try and commented out my existing function, and commented it from the xml, then made a new function and pasted your code into it. however, it does not seem to work. I added a second PlaySoundFile below your playsound, and had it play a fixed sound file, which did work.

    function weird_OnEvent()    
        local sounds = {"lvlup.wav", "voice2.wav"}
        local f = CreateFrame("Frame")
        f:RegisterEvent("PLAYER_LEVEL_UP")
        f:SetScript("OnEvent", function() PlaySoundFile("Interface\\Addons\\Servant\\Sounds"..sounds[math.random(#sounds)]) end)
        f:SetScript("OnEvent", function() PlaySoundFile("Interface\\Addons\\Servant\\Sounds\\lvlup.wav")end)
    end


    So, your OnEvent script works, it is just not finding the file name from the array.
    Posted in: Need Help?
  • 0

    posted a message on play random sound file from array
    Hi there,

    I only just began learning how to make wow addons, but I do have general programming experience.

    I am trying to Play a random sound file on an event from an array called lvlsound. (is array the right term?)

    function sounds_OnLoad()
        lvlsound = {
    		[1] = {
                    PlaySoundFile ("Interface\\Addons\\Servant\\Sounds\\lvlup.wav"),
    		},
    		[2] = {
    	        PlaySoundFile ("Interface\\Addons\\Servant\\Sounds\\voice2.wav"),
    		},
        }        
    end


    My function that is supposed to call upon a value from the array is this:

    function lvlup_OnEvent()
        if event == "PLAYER_LEVEL_UP" then
            i = math.random(1, #lvlsound)
            lvlsound[i]
        end
    end  


    These functions are both in the main servant.lua file.

    My WOW UI Editor says that it is expecting an equals sign on lvlsound[i] and I don't know what to do. I learnt this code from the Necrosis Ldc speech-en.lua and message.lua but they are too complicated to find out what is wrong with mine.

    Also, these sound files are from lichking-spech.mpq which does not seem to load in vanilla and bc areas. I could have my addon play the files from the mpq but I don't know how to load the correct mpq. I tested my code on a vanilla sound and it did work.
    Posted in: Need Help?
  • To post a comment, please or register a new account.