WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   if Buff on me in combat only iam log on warri (https://www.wowinterface.com/forums/showthread.php?t=45398)

gr0by 12-08-12 09:30 AM

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.

d87 12-08-12 11:14 AM

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.

gr0by 12-09-12 05:15 AM

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

d87 12-09-12 03:09 PM

add frame:SetScript("OnEvent", nil) for REGEN_ENABLED

gr0by 12-09-12 03:17 PM

can you be more specific?
in your script or mine?
but thanks for your answer

humfras 12-09-12 03:43 PM

The code you posted replaces its own OnEvent function.
Because of this, it no longer reacts to the "PLAYER_REGEN_..." events.

humfras 12-09-12 05:09 PM

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


gr0by 12-10-12 08:12 AM

big thanks it works!


All times are GMT -6. The time now is 09:29 PM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI