I am pretty new to addon coding. I am a Computer Science Major particularly in the application development side of things I have two questions: 1. Is there a way to have an addon detect if the player has come in/out of stealth?
2. Is there any really good tutorials on WoW addon Development?
Thanks
Rearadmiral (Black Dragonflight, US)|||Do you mean yourself or someone else? If you mean yourself then you might be able to check using UnitBuff(unit, buffIndex)
http://www.wowwiki.com/API_UnitBuff
Code:
name, rank, iconTexture, count, duration, timeLeft = UnitBuff(unit, buffIndex)
Where the name or the icontexture matches what you are looking for. If you mean someone else then I don't think you can unless you are targeting them.|||Thanks Jumpy I am trying to detect when I myself go stealth. Let me explain what I am trying to do. I want to detect when I go stealth as my druid so that I can automatically switch the bar pages, kinda like a rouges bars change but for some reason bliz just didn't do for a druid stealth.
Here is what I have so far:
Code:
function CatBar_OnLoad()
DEFAULT_CHAT_FRAME:AddMessage("CatProwlBar Loaded");
end
function CatBar_OnEvent()
if IsStealthed() == 1 then
ChangeActionBarPage(2);
end
if IsStealthed() == nil then
ChangeActionBarPage(1);
end
end
My function works. If I am in game and I type "/script CatBar_OnEvent();" it will switch the page accordingly. I need it to run that function when I go stealth or come out of stealth.|||If there is no event to trigger a function then you sometimes have to use OnUpdate in your xml to drive the function.
At the top of your Lua program you need to have
Code:
local CatBar_LastTime = 0
Then this function is pointed to by your xml.
Code:
function CatBar_Timer(elapsed)
CatBar_LastTime = CatBar_LastTime + elapsed
if CatBar_LastTime >= .5) then -- for half second intervals
CatBar_LastTime = 0
if IsStealthed() == 1 then
ChangeActionBarPage(2);
end
if IsStealthed() == nil then
ChangeActionBarPage(1);
end
end
end
In your frame xml, in the Scripts section you have
Code:
<Scripts>|||You may also be able to use events such as "CHAT_MSG_SPELL_PERIODIC_SELF_BUFFS", "CHAT_MSG_SPELL_PERIODIC_FRIENDLYPLAYER_BUFFS" and "CHAT_MSG_SPELL_PERIODIC_HOSTILEPLAYER_BUFFS". I'm guessing the first one will work for self buffs thought I haven't personally tested it. Arg1 will return the combat text chat, so if you know what effect to look for, you should be able to trigger a function when the event is fired without necessarily having to resort to a timed OnUpdate check (which should work as well).|||Thanks BTW guys for all of your input but I still cannot get it working, and it may just be me at this point but this is what I got:
<OnUpdate>
CatBar_Timer(arg1)
</OnUpdate>
**** other scripts ***
</Scripts>
CatProwlBar.lua
Code:
local CatBar_LastTime = 0
function CatBar_OnLoad()
DEFAULT_CHAT_FRAME:AddMessage("CatProwlBar Loaded");
end
function CatBar_Timer(elapsed)
CatBar_LastTime = CatBar_LastTime + elapsed
if CatBar_LastTime >= .5 then -- for half second intervals
CatBar_LastTime = 0
if IsStealthed() == 1 then
ChangeActionBarPage(2);
end
if IsStealthed() == nil then
ChangeActionBarPage(1);
end
end
end
CatProwlBar.xml
Code:
<Ui xmlns="http://www.blizzard.com/wow/ui/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.blizzard.com/wow/ui/ ..\FrameXML\UI.xsd">
<Script file="CatProwlBar.lua" />
<Frame name="CatFrame" hidden="true">
<Scripts>
<OnLoad>
CatBar_OnLoad();
</OnLoad>
<OnUpdate>
CatBar_Timer(arg1);
</OnUpdate>
</Scripts>
</Frame>
</Ui>
Thats what I got and still nothing, the only sign I have that the addon is actually working is the fact that I can call the the functions and the Message "CatProwlBar Loaded" shows up when I load in. I am hopeless|||OnUpdate wont run if the frame is hidden. Change the hidden value of the frame to false.|||You may also try :
CatProwlBar.lua
Quote:
function CatBar_OnLoad()
DEFAULT_CHAT_FRAME:AddMessage("CatProwlBar Loaded");
this:RegisterEvent("CHAT_MSG_SPELL_PERIODIC_SELF_BUFFS");
this:RegisterEvent("CHAT_MSG_SPELL_AURA_GONE_SELF");
end
function CatBar_OnEvent()
if (event == "CHAT_MSG_SPELL_PERIODIC_SELF_BUFFS") and arg1 == "You gain Prowl." then
ChangeActionBarPage(2);
end
if (event == "CHAT_MSG_SPELL_AURA_GONE_SELF") and arg1== "Prowl fades from you." then
ChangeActionBarPage(1);
end
end
CatProwlBar.xml
Quote:
<Ui xmlns="http://www.blizzard.com/wow/ui/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.blizzard.com/wow/ui/ ..\FrameXML\UI.xsd">
<Script file="CatProwlBar.lua" />
<Frame name="CatFrame" hidden="true">
<Scripts>
<OnLoad>
CatBar_OnLoad();
</OnLoad>
<OnEvent>
CatBar_OnEvent();
</OnEvent>
<OnUpdate>
</OnUpdate>
</Scripts>
</Frame>
</Ui>|||OMG thanks Dinnerbone and Jumpy. As soon as I clean it up some, it will be on the site. You guys will get most of the credit :P.
Thanks Again|||Bad News, I have uncovered a bug. Whenever I leave stealth by using an attack (ie Pounce) my bar does not switch back. Any Ideas?
No comments:
Post a Comment