Reply
Thread Tools Display Modes
Unread 12-08-12, 09:30 AM   #1
gr0by
A Deviate Faerie Dragon
Join Date: Oct 2008
Posts: 18
if Buff on me in combat only iam log on warri

Code:
if class == "WARRIOR" then
    whoaUnitFrames.config.repositionPartyText = false

local frame = CreateFrame("FRAME")
frame:RegisterEvent("UNIT_AURA")
frame:RegisterEvent("PLAYER_REGEN_ENABLED")
frame:RegisterEvent("PLAYER_REGEN_DISABLED")
frame:SetScript("OnEvent", function(_, event)
   if event == "PLAYER_REGEN_ENABLED" then
     SpellActivationOverlay_HideOverlays(SpellActivationOverlayFrame, 6673) 
   elseif event == "PLAYER_REGEN_DISABLED" then

-- powerauras
frame:SetScript("OnEvent", function(self, event, ...)
        local unitid = ... if unitid ~= "player" then return end

        if not UnitBuff("player", "Schlachtruf") and not UnitBuff("player", "Befehlsruf") then
                SpellActivationOverlay_ShowOverlay(SpellActivationOverlayFrame, 6673, "INTERFACE\\ICONS\\Ability_Warrior_BattleShout.blp", "TOP", 1.1, 139, 65, 239, false, false)
        else
                SpellActivationOverlay_HideOverlays(SpellActivationOverlayFrame, 6673)
        end
end)


   end
end)
[COLOR="rgb(72, 61, 139)"]end[/color]
[COLOR="rgb(72, 61, 139)"]A[/color] Whoa unitframes

Iam new whit Lua and I've stolen a lot of things together
what it should do?!?
When I'm warrior and not Commanding Shout or Battle Shout in the fight on me than show a icon over me.
gr0by is offline   Reply With Quote
Unread 12-08-12, 11:14 AM   #2
d87
A Warpwood Thunder Caller
AddOn Author - Click to view addons
Join Date: Jan 2006
Posts: 99
Here's something similar to what i use...

Code:
local function BuffGroup(ids, r,g,b)
    local buffs = {}
    for _,id in ipairs(ids) do
        buffs[id] = GetSpellInfo(id)
    end
    return function()
        for spellID, spellName in pairs(buffs) do
            local name, _,_, count, _, duration, expirationTime, caster, _,_, aura_spellID = UnitAura("player", spellName, nil, "HELPFUL")
            if name then return true, caster, r,g,b end
        end
        return false, nil, r,g,b
    end
end

local battle = BuffGroup({6673, 19506, 57330}, "BATTLE") -- battle shout, trueshot, horn of winter
local commanding = BuffGroup({469, 6307, 21562}, "COMMANDING") -- commanding, blood pact, pwf

local shout_check = function() 
            local present, caster,r,g,b = battle()
            if present and caster ~= "player" then
                return commanding()
            else return present, caster,r,g,b end
        end

local f = CreateFrame("Frame")
f:RegisterUnitEvent("UNIT_AURA", "player")
f:SetScript("OnEvent", function(self, event, ...)
        local present, caster, shout_type = shout_check()
        if not present then
                -- show something
        else
                -- hide
        end
end)

---
This doesn't include combat condition, but actually you probably want to be buffed before it starts.

Last edited by d87 : 12-08-12 at 11:25 AM.
d87 is offline   Reply With Quote
Unread 12-09-12, 05:15 AM   #3
gr0by
A Deviate Faerie Dragon
Join Date: Oct 2008
Posts: 18
no, I want to be remembered only in the fight.
First, I want to benefit from the buff rage
secondly, my script works well so.
just outside of combat the script, will not delete the icon
gr0by is offline   Reply With Quote
Unread 12-09-12, 03:09 PM   #4
d87
A Warpwood Thunder Caller
AddOn Author - Click to view addons
Join Date: Jan 2006
Posts: 99
add frame:SetScript("OnEvent", nil) for REGEN_ENABLED
d87 is offline   Reply With Quote
Unread 12-09-12, 03:17 PM   #5
gr0by
A Deviate Faerie Dragon
Join Date: Oct 2008
Posts: 18
can you be more specific?
in your script or mine?
but thanks for your answer
gr0by is offline   Reply With Quote
Unread 12-09-12, 03:43 PM   #6
humfras
A Warpwood Thunder Caller
AddOn Author - Click to view addons
Join Date: Oct 2009
Posts: 98
The code you posted replaces its own OnEvent function.
Because of this, it no longer reacts to the "PLAYER_REGEN_..." events.
__________________
Author of VuhDo CursorCastBar OptiTaunt Poisoner RaidMobMarker

Last edited by humfras : 12-09-12 at 04:08 PM.
humfras is offline   Reply With Quote
Unread 12-09-12, 05:09 PM   #7
humfras
A Warpwood Thunder Caller
AddOn Author - Click to view addons
Join Date: Oct 2009
Posts: 98
My suggestion / meine Empfehlung:
Code:
local frame = CreateFrame("Frame")
local events = {}
local incombat

local function checkerfunc()
	if not UnitBuff("player", "Schlachtruf") and not UnitBuff("player", "Befehlsruf") then
		SpellActivationOverlay_ShowOverlay(SpellActivationOverlayFrame, 6673, "INTERFACE\\ICONS\\Ability_Warrior_BattleShout.blp", "TOP", 1.1, 139, 65, 239, false, false)
	else
		SpellActivationOverlay_HideOverlays(SpellActivationOverlayFrame, 6673)
	end
end

function events:PLAYER_REGEN_ENABLED(...)
	incombat = false
	SpellActivationOverlay_HideOverlays(SpellActivationOverlayFrame, 6673)
end
function events:PLAYER_REGEN_DISABLED(...)
	incombat = true
	checkerfunc()
end

function events:UNIT_AURA(unit)
	if unit ~= "player" or not incombat then return end	--only proceed if the player has an aura event
	checkerfunc()
end

frame:SetScript("OnEvent", function(self, event, ...)
	events[event](self, ...)
end)
for k, v in pairs(events) do
	frame:RegisterEvent(k)
end
__________________
Author of VuhDo CursorCastBar OptiTaunt Poisoner RaidMobMarker

Last edited by humfras : 12-09-12 at 05:31 PM.
humfras is offline   Reply With Quote
Unread 12-10-12, 08:12 AM   #8
gr0by
A Deviate Faerie Dragon
Join Date: Oct 2008
Posts: 18
big thanks it works!
gr0by is offline   Reply With Quote
Reply

Go BackWoWInterface » Developer Discussions » Lua/XML Help » if Buff on me in combat only iam log on warri

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off