世界 of Warcraft Lua - 改变 frame:SetAttribute()

我正在制作一个适合我的游戏风格的 World of Warcraft 插件,该插件将完全改变用户界面。

在此插件中,我想要有一个大按钮,它可以作为我的法师的主要 dps 循环。我希望它根据任何给定时间的最佳情况改变其施法的法术。它不会自动施法,只是向用户呈现下一个最佳选项。

以下是我的代码:


local Button = CreateFrame("Button", "MyButton", UIParent,"SecureActionButtonTemplate") Button:SetWidth(256) Button:SetHeight(256) Button:SetFrameStrata("HIGH") Button:SetPoint("LEFT") Button:SetText("Main Rotation") Button:RegisterForClicks("AnyUp") Button:SetAttribute("type", "spell") Button:SetAttribute("spell", "Fireball")

Button:RegisterEvent("UNIT_AURA"); local function auraGained(self, event, ...) if (UnitAura("player", "Heating Up")) then if (heatingUpIsActive == false) then heatingUpIsActive = true print (heatingUpIsActive) print ("Heating Up is active!") Button:SetAttribute("spell", "Inferno Blast") end else heatingUpIsActive = false print("Heating Up is NOT active.") print(heatingUpIsActive) end end Button:SetScript("OnEvent", auraGained);

local tex = Button:CreateTexture("ARTWORK"); tex:SetPoint("LEFT") tex:SetWidth(256) tex:SetHeight(256) tex:SetTexture("Interface\\AddOns\\InterfaceOverhaul\\Button2")

如果 heatingUpIsActive == true,我希望按钮施放 ("spell", "Inferno Blast"),而不是 ("spell", "Fireball"),但如果我将它放到正确的 if 语句部分中,它会失效。

有什么想法吗?

点赞
用户582
用户582

正如 Mud 所说,你不能在战斗中重新绑定按钮。 暴雪公司进行了这个修改,是为了防止机器人能够自动化战斗。 值得注意的是,为了施放咒语,你需要使用其中一个安全样板,并且这些安全样板仅允许修改控制它们的属性,当你不在战斗中时这些属性发挥作用。 因此,你不能让一个按钮在战斗中改变咒语。 同样,他们还防止你修改属性,例如它们的位置或可见性,因此你不能将按钮移动到鼠标下方。

你能做的最好的事情就是展示一个表明应该施放什么咒语的视觉指示器,但仍需要依赖用户按下正确的按钮。

2013-04-05 08:21:13