View Single Post
03-13-18, 05:44 PM   #8
Eungavi
A Theradrim Guardian
Join Date: Nov 2017
Posts: 64
Originally Posted by WhirlyTV View Post
Thank you so much for the help, I really appreciate it. I'm not a competent programmer unfortunately so I have no idea where to begin to make this happen. Is there also a way to tell when your character opens up a vendor? I'm currently watching youtube tutorials to try and learn how to create this.
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.
  Reply With Quote