Lua - кадр дебаффа API World of Warcraft

У меня странная проблема, что с этим аддоном он показывает кадр с текущим дебаффом. Я думаю, что он отображает только первый, а если применяется другой, он просто перекрывает первый. Как сделать так, чтобы новые отображались рядом со старыми?

Это код:

function WCCPlayer_OnLoad() 
    this:SetHeight(40)
    this:SetWidth(40)
    this:SetPoint("CENTER", 0, 0)
    this:RegisterEvent("UNIT_AURA")
    this:RegisterEvent("PLAYER_AURAS_CHANGED")

    this.texture = this:CreateTexture(this, "BACKGROUND")
    this.texture:SetAllPoints(this)
    this.cooldown = CreateFrame("Model", "Cooldown", this, "CooldownFrameTemplate")
    this.cooldown:SetAllPoints(this) 
    this.maxExpirationTime = 0
    this:Hide()
end

function WCCPlayer_OnEvent()
    local spellFound = false
    for i=1, 16 do -- 16 is enough due to HARMFUL filter
        local texture = UnitDebuff("player", i)
        WCCTooltip:ClearLines()
        WCCTooltip:SetUnitDebuff("player", i)
        local buffName = WCCTooltipTextLeft1:GetText()

    if spellIds[buffName] then
        spellFound = true
        for j=0, 31 do
            local buffTexture = GetPlayerBuffTexture(j)
            if texture == buffTexture then
                local expirationTime = GetPlayerBuffTimeLeft(j)
                this:Show()
                this.texture:SetTexture(buffTexture)
                this.cooldown:SetModelScale(1)
                if this.maxExpirationTime <= expirationTime then
                    CooldownFrame_SetTimer(this.cooldown, GetTime(), expirationTime, 1)
                    this.maxExpirationTime = expirationTime
                end
                return
            end
        end     
    end
end
if spellFound == false then
    this.maxExpirationTime = 0
    this:Hide()
end
end

function WCCTarget_OnLoad()

end

function WCCTarget_OnEvent()

end

person Pokeystab    schedule 14.04.2018    source источник
comment
Все еще застрял на нем. Пробовал кое-что, но я просто не могу заставить другие дебаффы появляться рядом ...   -  person Pokeystab    schedule 15.04.2018


Ответы (1)


Я думаю, что все дело в позиции кадра, и, как вы сказали, новый кадр отображается поверх предыдущего.

Вам необходимо, чтобы новая позиция кадра была рядом с предыдущей, чтобы каждый раз, когда вы запускаете функцию WCCPlayer_OnLoad (), она увеличивала координату X на ширину кадра.

Сначала объявите локальную переменную setPointX вне функции, затем увеличьте переменную setPointX на ширину кадра, (в вашем случае 40) при каждом запуске функции;

local setPointX, setPointY = 0,0 -- x and y variables

function WCCPlayer_OnLoad()
    this:SetHeight(40)
    this:SetWidth(40)
    this:SetPoint('CENTER', setPointX, setPointY) -- use variables to set the frame point
    this:RegisterEvent('UNIT_AURA')
    this:RegisterEvent('PLAYER_AURAS_CHANGED')

    this.texture = this:CreateTexture(this, 'BACKGROUND')
    this.texture:SetAllPoints(this)
    this.cooldown = CreateFrame('Model', 'Cooldown', this, 'CooldownFrameTemplate')
    this.cooldown:SetAllPoints(this)
    this.maxExpirationTime = 0
    this:Hide()
    setPointX = setPointX + 40 -- increase the x variable by the width of the frame
end

У меня нет опыта в программировании (просто пытаюсь научить себя Java и Lua), поэтому, несомненно, будут лучшие и более эффективные / действенные способы решения вашей проблемы.

person Walkerbo    schedule 25.06.2018