Hi!
You can make it like this:
-- the file that will call your files:
MyAddon.toc
-- add the next code line
MyAddon.lua
-- the file that will contain the code:
MyAddon.lua
-- add the following code:
-- create your addon's name space
MyAddon = {}
-- create a simple frame
local frame = CreateFrame("Frame");
-- register event, might be another better to make this but this one was the nicest I've found
frame:RegisterEvent("PLAYER_AURAS_CHANGED");
-- set the trigger to catch the event and call your function
frame:SetScript("OnEvent", function(this, event, ...)
MyAddon[event](MyAddon, ...) end; );
-- your function
function MyAddon:PLAYER_AURAS_CHANGED()
if(IsMounted()) then
-- since this event triggers so many times, we better declare anything inside the case we want
local soundFile = "path";
-- path is where your music will be
-- Ex:Interface\\AddOns\\YourAddon\\YourMusic.mp3
PlayMusic(soundFile);
else
StopMusic();
end;
end;
I didnt test this, so no clue if is working. One drawback is that else clause, it will trigger the stopmusic() everytime.
There might be a way to get from chat msgs the right place to put the ismount and the else clause.
Anyway, I hope it helps.
Cheers
Last edited by ProfOak : 02-01-08 at 09:02 AM.
|