Saturday, April 14, 2012

Why won't my sound mod work?

[:1]I took the ComeHere mod and edited the sounds for a Killing Spree/Ambush mod. Kill Frenzy and Falcon Punch are the sounds. For whatever reason it still doesn't want to work. If anyone could help me out I'd really appreciate it.

Here's my LUA:

function Killing_Spree_OnEvent(event, sp1, sp2)

local spellName = GetSpellInfo(51690)

if strfind(sp2, spellName) and sp1 == "player" then



local RanNum = math.random(3);



if RanNum == 1 then

PlaySoundFile("Interface\\AddOns\\FalconPunch\\Sounds\\KillFrenzy.mp3");

elseif RanNum == 2 then

PlaySoundFile("Interface\\AddOns\\FalconPunch\\Sounds\\KillFrenzy.mp3");

else

PlaySoundFile("Interface\\AddOns\\FalconPunch\\Sounds\\KillFrenzy.mp3");

end

end

end

function Ambush_OnEvent(event, sp3, sp4)

local spellName = GetSpellInfo(11269)

if strfind(sp4, spellName) and sp3 == "player" then



local RanNum = math.random(3);



if RanNum == 1 then

PlaySoundFile("Interface\\AddOns\\FalconPunch\\Sounds\\FalconPunch.mp3");

elseif RanNum == 2 then

PlaySoundFile("Interface\\AddOns\\FalconPunch\\Sounds\\FalconPunch.mp3");

else

PlaySoundFile("Interface\\AddOns\\FalconPunch\\Sounds\\FalconPunch.mp3");

end

end

end

XML:

<Ui xsi:schemaLocation="http://www.blizzard.com/wow/ui/">

<Script file="FalconPunch.lua"/>

<Frame name="FalconPunch_Core">

<Scripts>

<OnLoad>

this:RegisterEvent("UNIT_SPELLCAST_SUCCEEDED");

</OnLoad>

<OnEvent>

Kill_Frenzy_OnEvent(event, sp1, sp2);

Ambush_OnEvent(event, sp3, sp4);

</OnEvent>

</Scripts>

</Frame>

</Ui>

What am I doing wrong? :(|||Come on guys, I need you're help. D:|||You should just change the spell ID and nothing else :P

I assume you changed the .toc file to point to the correct folders and directories also... yes?

Why are you randomising something that plays the same file in all 3 cases?


Code:
self:RegisterEvent("UNIT_SPELLCAST_SUCCEEDED");

Dont use 'this:RegisterEvent'.


Code:
Death_Grip_OnEvent(event, arg1, arg2);

this is sending global arguments, call them arg1 and arg2, dont call them something else


Code:
sp1 == "player"

This is arg1 in the original mod. I generally use events local to the function but when using globals you must use arg1.


Code:
Kill_Frenzy_OnEvent(event, sp1, sp2);
Ambush_OnEvent(event, sp3, sp4);

Aside from changing the argument to arg1 and arg2, you should also change this to a single event handler. i.e. 1 function that does both, or another function which then calls one of the two.


Code:
strfind

Try 'string.find' or a simple '=='|||lol another Death Grip mod, and from the looks if it your editing my mod [/url=http://wowui.worldofwar.net/?p=mod&m=6523]ComeHerep[/url].|||Yeah, the first thing I said was that I was trying to edit the ComeHere mod so I could quickly and efficiently create my own- I didn't know I was going to butcher everything in the process! Like I said, I'm very new to LUA/XML. I have experience with HTML and I did VB years and years ago.

I left the sounds randomized because I didn't want to break anything.

Thanks for looking over this for me. I'll go back and fix it up. I'll be sure to post the final product, too.|||I tried combining everything like you suggested to no avail. I have a feeling that if I hopped on my Death Knight all the sound effects would play when I Death Gripped. :P

So, am idoinitrite?! I appreciate the challenge modding brings but I'm pretty sure I covered everything you suggested. It's probably just some stupid format issue that I messed up. x) The spells should be okay- I went ahead and had to do Ambush by rank because there isn't away to order the program to cover Ambush in general?

LUA:

function Falcon_Frenzy_OnEvent(event, arg1, arg2)



if local spellName = GetSpellInfo(51690) then

if string.find(arg2, spellName) and arg1 == "player" then



PlaySoundFile("Interface\\AddOns\\FalconPunch\\Sounds\\KillFrenzy.mp3");

end

end

elseif local spellName = GetSpellInfo(11269) then

if string.find(arg2, spellName) and arg1 == "player" then



PlaySoundFile("Interface\\AddOns\\FalconPunch\\Sounds\\FalconPunch.mp3");

end

end

XML:

<Ui xsi:schemaLocation="http://www.blizzard.com/wow/ui/">

<Script file="FalconFrenzy.lua"/>

<Frame name="FalconFrenzy_Core">

<Scripts>

<OnEvent>

Falcon_Frenzy_OnEvent(event, arg1, arg2);

</OnEvent>

</Scripts>

</Frame>

</Ui>|||There are a few formatting and syntax errors in that, I suggest you get a program like LuaEDIT which will syntax check for you.

The correct formatting looks like this, however it will not function currently.


Code:
function Falcon_Frenzy_OnEvent(event, arg1, arg2)
if spellName == GetSpellInfo(51690) then
if string.find(arg2, spellName) and arg1 == "player" then
PlaySoundFile("Interface\\AddOns\\FalconPunch\\Sounds\\KillFrenzy.mp3");
end
elseif spellName == GetSpellInfo(11269) then
if string.find(arg2, spellName) and arg1 == "player" then
PlaySoundFile("Interface\\AddOns\\FalconPunch\\Sounds\\FalconPunch.mp3");
end
end
end

If you want to ask if something is equal to something else, use '=='.

If you define something as being equal to something else, use '='.

The problem with the above code is that you are asking if 'spellName' is equal to the first returned argument of GetSpellInfo, but you havent defined what spellName actually is.


Code:
function Falcon_Frenzy_OnEvent(event, arg1, arg2)
local spellName = arg1
if spellName == GetSpellInfo(51690) then

At the start of the function should give you what you want.

If it is still not working after this, then you need to work out if the mod is actually being loaded, to do this you can just add a loading message to the very start:


Code:
DEFAULT_CHAT_FRAME:AddMessage("My test mod loaded")

As for the spell ranks, as you are querying the spell name from the server then comparing it to the servers event spell name, the mod should work for all ranks and localizations.|||Nice! I'll grab that editor and see what I can do about fixing it up some more. I'll be honest, I'm a little confused. But I'm pretty rusty at code in general. :)

Thanks for taking the time to help me out. I figure if I can get this sound mod going I can easily put together my own in the future whenever the mood strikes!

Unfortunately it didn't work. I tried using your functionality test and it didn't show up anywhere either.


Code:
function Falcon_Frenzy_OnEvent(event, arg1, arg2)
local spellName = arg1
if spellName == GetSpellInfo(51690) then
if string.find(arg2, spellName) and arg1 == "player" then
PlaySoundFile("Interface\\AddOns\\FalconPunch\\Sounds\\KillFrenzy.mp3");
end
elseif spellName == GetSpellInfo(11269) then
if string.find(arg2, spellName) and arg1 == "player" then
PlaySoundFile("Interface\\AddOns\\FalconPunch\\Sounds\\FalconPunch.mp3");
end
end
end

Is this something beyond my control or did I mess up your suggestion? I think I see something.

Don't
Code:
 local spellName = arg1

and
Code:
if string.find(arg2, spellName) and arg1 == "player" then

contradict? The first defines arg1 as the spellName but the second clearly only works if arg1 is defined as "player".|||Sorry I just meant that's how you do it in general, rather than what will work specifically. In this case:

http://www.wowwiki.com/Events_(API)

UNIT_SPELLCAST_SUCCEEDED

arg1

Unit casting the spell

arg2

Spell name

arg3

Spell rank



If you cant see the chat message then it means you have a bigger problem and the addon isnt loading.

Check that the .toc file and the addon folder have the same name, then check that the .toc file points to the correct lua and xml files.

I also see that you arent registering the event anymore, which you will need to do in an OnLoad function, or in the xml as you had previously.|||I'm a little overwhelmed by all of this. I guess I was more rusty than I thought! I kept the XML, I just didn't post it because I didn't change it (at first). I thought you said to take out this:register event? See? I'm so new to this. xD So here's what I've come up with:

XML:


Code:
<Ui xsi:schemaLocation="http://www.blizzard.com/wow/ui/">
<Script file="FalconFrenzy.lua"/>
<Frame name="FalconFrenzy_Core">
<Scripts>
<OnLoad>
this:RegisterEvent("UNIT_SPELLCAST_SUCCEEDED");
</OnLoad>
<OnEvent>
Falcon_Frenzy_OnEvent(event, arg1, arg2);
</OnEvent>
</Scripts>
</Frame>
</Ui>

LUA:


Code:
function Falcon_Frenzy_OnEvent(event, arg1, arg2)
local spellName = arg1
if spellName == GetSpellInfo(51690) then
if string.find(arg1, spellName) and arg2 == "player" then
PlaySoundFile("Interface\\AddOns\\FalconFrenzy\\Sounds\\KillFrenzy.mp3");
end
elseif spellName == GetSpellInfo(11269) then
if string.find(arg1, spellName) and arg2 == "player" then
PlaySoundFile("Interface\\AddOns\\FalconFrenzy\\Sounds\\FalconPunch.mp3");
end
end
end

TOC:


Code:

## Interface: 30000
## Title: FalconFrenzy
## Notes: Plays Falcon Punch (SSBB) and Kill Frenzy (GTA2) sound effects when you trigger Ambush or Killing Spree.
## Version: 1.0
## Author: Jaime

FalconFrenzy.lua
FalconFrenzy.xml

I guess I just had to switch arg1 and arg2 to match what you were suggesting. This defines arg1 and the spell name then proceeds to say if arg1 is the spell you're using and arg2 is your character I will play this sound. I think so, anyway.

But it still doesn't work. You guys may have to dumb it down for me a little bit. :/

No comments:

Post a Comment