This site makes extensive use of JavaScript.
Please enable JavaScript in your browser.
Live
PTR
10.2.7
PTR
10.2.6
Beta
Outfitter Script & Companions
Post Reply
Return to board index
Post by
20383
This post was from a user who has deleted their account.
Post by
Wanderingfox
Not sure about #2 since I am not familiar with Outfitter's functions, but #1 could be done by doing something like the following:
-- Create a local frame to hold our events since they're frame driven
-- Note: You could use an already existing/recycled frame for this
local frame = CreateFrame("FRAME", "MyAddonFrame")
-- Register our frame to listen to the unit aura event which fires when a buff/debuff changes
frame:RegisterEvent("UNIT_AURA")
-- Create a function to handle our event
local function eventHandler(self, event, arg1)
-- Grab the information the event is passing to our function
-- arg1 contains the unitID that this specific event refers to
local unitID = arg1
-- Check to see if the event is related to a player buff/debuff
if unitID == "Player" then
-- Check to see if the player has stealth active
if UnitBuff("Player", "Stealth") then
-- Dismiss the non-combat pet
DismissCompanion("CRITTER")
end
end
-- Register our event handler function to the frame
frame:SetScript("OnEvent", eventHandler)
Note
: The above are snippets of very simple
DRY
code, so they probably will not work out of the box. I have, however, documented them (as you can see), so it should be possible to change them based on where and how you intend to use them.
Note 2
: I included the arg1 check for completeness sake, it is not technically required since the conditional is implied by the UnitBuff check on the player. It does, however, reduce the number of calls to UnitBuff by only ever continuing if a player buff/debuff has changed.
Note 3
: I would highly suggest using a framework like Ace to do something like this if you must do it through Lua as Ace can register throttled events (called buckets) that will only fire every X seconds, which will greatly reduce the amount of handler calls.
Edit:
It is probably worth saying that this would be
significantly
easier with a macro. Yes I know you said that you do not have the space for it, but I figured I'd include it anyway.
#showtooltip Stealth
/cast Stealth
/stopmacro
/run DismissCompanion("CRITTER")
Post by
409946
This post was from a user who has deleted their account.
Post by
Wanderingfox
Oh right! Knew I forgot something >_<
Thanks. Fixed the initial code.
Post by
20383
This post was from a user who has deleted their account.
Post Reply
You are not logged in. Please
log in
to post a reply or
register
if you don't already have an account.