【发布时间】:2013-04-05 00:07:02
【问题描述】:
我正在为《魔兽世界》开发一个插件,它会彻底改造界面以适应我的游戏风格。
在这个插件中,我想要一个大按钮,作为我的法师的“主要 dps 旋转”。我希望它根据任何给定时间的最佳咒语来改变它施放的咒语。它不会自动施法,它只是为用户提供下一个最佳选择。
到目前为止,这是我的代码:
print "Interface Overhaul : LOADED"
heatingUpIsActive = false
print(heatingUpIsActive)
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 语句的正确部分,它将不起作用。
有什么想法吗?
【问题讨论】:
-
"It doesn't work if I" -- 你告诉我们你没有提供的代码不起作用,这是毫无价值的。向我们展示不起作用的实际代码。如果您尝试以编程方式重新绑定按钮,那么在您进入战斗的那一刻将无法正常工作。
-
@Mud “如果你想以编程方式重新绑定按钮......” 你似乎明白了它的要点,但我编辑了这篇文章以反映我之前提到的内容。有没有办法解决这个问题?
-
没有。这在 5 或 6 年前是可能的,人们过去常常将一把钥匙绑定到他们的整个轮换中,让脚本为他们挑选法术。然后暴雪彻底改造了系统以防止这种情况发生。你可以做你最初说你想做的事情(即不施法,只向用户展示下一个法术),但你不能在战斗中根据脚本逻辑一键切换法术。这些天法师轮换不是只有一两个按钮吗? :)
标签: lua add-on world-of-warcraft