View Single Post
03-13-18, 06:06 PM   #9
WhirlyTV
A Murloc Raider
Join Date: Mar 2018
Posts: 6
Originally Posted by Eungavi View Post
https://addon.bool.no/

This site would help you creating an addon.

Type in your addon's name into AddOn folder name field.
(Let's say PlayZeldaMusic)

Copy and paste the following code into lua file field
(This version will also play/stop music on vendor)
Lua Code:
  1. local f = CreateFrame("Frame")
  2. f:RegisterEvent("PLAYER_UPDATE_RESTING")
  3. f:RegisterEvent("MERCHANT_SHOW")
  4. f:RegisterEvent("MERCHANT_CLOSED")
  5. f:SetScript("OnEvent", function(self, event, ...)
  6.     if event == "PLAYER_UPDATE_RESTING" then
  7.         if IsResting() then
  8.             PlayMusic("path to your music")
  9.         else
  10.             StopMusic()
  11.         end
  12.     elseif event == "MERCHANT_SHOW" then
  13.         PlayMusic("path to your music")
  14.     elseif event == "MERCHANT_CLOSED" then
  15.         StopMusic()
  16.     end
  17. end)

Press Create my AddOn and give me my files! button.

You will get a zip file which contains two files called PlayZeldaMusic.toc and code.lua

Un-zip it, place your sound file into that folder then open code.lua and change "path to your music" to your own.
Thanks so much for the prompt replies I really do appreciate you taking the time to try and help me. I've tried exactly what you said and it doesn't seem to be working. This is currently what I have written in cod.lua


-- This file is loaded from "ZeldaShop.toc"

local f = CreateFrame("Frame")
f:RegisterEvent("PLAYER_UPDATE_RESTING")
f:RegisterEvent("MERCHANT_SHOW")
f:RegisterEvent("MERCHANT_CLOSED")
f:SetScript("OnEvent", function(self, event, ...)
if event == "PLAYER_UPDATE_RESTING" then
if IsResting() then
PlayMusic("C:\Program Files (x86)\World of Warcraft\Interface\AddOns\ZeldaShop")
else
StopMusic()
end
elseif event == "MERCHANT_SHOW" then
PlayMusic(C:\Program Files (x86)\World of Warcraft\Interface\AddOns\ZeldaShop)
elseif event == "MERCHANT_CLOSED" then
StopMusic()
end
end)

I placed the Zeldashop.mp3 into the Addon folder and set the path to it.
  Reply With Quote