gpt4 book ai didi

Lua - 魔兽世界 API Debuff 框架

转载 作者:行者123 更新时间:2023-12-02 04:30:00 24 4
gpt4 key购买 nike

我遇到了一个奇怪的问题,使用这个 AddOn 它会显示一个带有当前 debuff 的帧。我认为它只显示第一个,如果应用另一个,它只会与第一个重叠。我怎样才能让它在旧的旁边显示新的?

这是代码:

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

最佳答案

我认为这完全与框架位置有关,正如您所说,新框架显示在前一框架之上。

您需要让新的框架位置紧挨着前一个框架位置,这样每次您运行 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),所以毫无疑问会有更好、更高效/有效的方法来解决您的问题。

关于Lua - 魔兽世界 API Debuff 框架,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49834962/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com