1. #1

    Help with a addon

    Hey,
    I have a problem. I want to make a addon that plays random sounds if the player dies. In my opinion it should just work fine, but it doesn't. I copied some code from other addons, but I made the relevant changes.
    This is the progress i've made so far:

    function RDS_OnLoad()
    this:RegisterEvent("PLAYER_DEAD");
    this:RegisterEvent("PLAYER_ALIVE");
    this:RegisterEvent("PLAYER_UNGHOST");
    end

    function RDS_OnEvent(event, arg1, arg2, arg3)
    if event == "PLAYER_DEAD" then
    PlaySoundFile("Interface\\AddOns\\Sheesh\\Sounds\\Sheesh"..math.random(45)..".wav");
    else
    StopMusic();
    end
    end

    local f = CreateFrame("Frame")
    f:RegisterEvent("PLAYER_DEAD")
    f:SetScript("OnEvent", function(self, event)
    msg = CreateFrame("MessageFrame", "DeadPeopleMessageFrame", UIParent)
    msg:SetWidth(512);
    msg:SetHeight(200);
    msg:SetPoint("TOP", 0, -200, "CENTER", 0, 200);
    msg:SetHeight(44)
    msg:SetInsertMode("TOP")
    msg:SetFrameStrata("HIGH")
    msg:SetTimeVisible(8)
    msg:SetFadeDuration(4)
    msg:SetScale(1.3)
    msg:SetFont(STANDARD_TEXT_FONT, 30, "OUTLINE")
    msg:AddMessage("Sheesh du Lappen", 1, 0, 0)
    end)
    There are 45 soundfiles all numbered properly and I really dont know what mistake I could have made. The Message also doesn't show up so...at the moment nothing really works how it should.
    I hope some of you out there can help me, I would really appreciate it.

    Greetings
    Kirame

  2. #2
    At work, so I can't test, but, some ideas...

    - Put your functions inside another simple, working, addon to test if your issue is with the skeleton/meta-info of the addon, or the function itself.

    - And instead of doing this whole message frame, if you just want to do diagnostic testing, just write out to the default chat box (cause frames can be such a @!#$ing pain to get right sometimes, they'll fail, and you'll have no idea why until you finally find the little issue and you hate yourself for missing something so obvious).

    If I have time tonight, I'll hook it into an addon skeleton I have for testing stuff like this, but no promises, since I have to pack for vacation (YAY VACATION!!!)

  3. #3
    You didn't show us your xml file. Either way, it's not needed since everything can be done in Lua instead
    Code:
    local msg = CreateFrame("MessageFrame")
    msg:SetSize(512, 44)
    msg:SetPoint("TOP", 0, -200)
    msg:SetInsertMode("TOP")
    msg:SetFrameStrata("HIGH")
    msg:SetTimeVisible(8)
    msg:SetFadeDuration(4)
    msg:SetScale(1.3)
    msg:SetFont(STANDARD_TEXT_FONT, 30, "OUTLINE")
    
    local rds = CreateFrame("Frame")
    
    function rds:OnEvent(event)
    	if event == "PLAYER_DEAD" then
    		PlaySoundFile("Interface\\AddOns\\Sheesh\\Sounds\\Sheesh"..random(45)..".wav")
    		msg:AddMessage("Sheesh du Lappen", 1, 0, 0)
    	else
    		StopMusic()
    	end
    end
    
    rds:RegisterEvent("PLAYER_DEAD")
    rds:RegisterEvent("PLAYER_ALIVE")
    rds:RegisterEvent("PLAYER_UNGHOST")
    rds:SetScript("OnEvent", rds.OnEvent)

Posting Permissions

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