魔兽世界Lua-更改框架:SetAttribute() [英] World of Warcraft Lua - Changing frame:SetAttribute()

查看:826
本文介绍了魔兽世界Lua-更改框架:SetAttribute()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为《魔兽世界》开发一个插件,该插件将彻底修改界面以适应我的游戏风格.

I'm working on an addon for World of Warcraft that completely overhauls the interface to adapt to my play style.

在此插件中,我想有一个大按钮,可作为我法师的主要dps旋转".我希望它根据任何给定时间的最佳状态来更改其施放的咒语.它不会自动施放咒语,只会为用户提供下一个最佳选择.

In this addon, I would like to have a large button that acts as a "main dps rotation" for my mage. I would like it to change what spell it casts based on what is optimal at any given time. It doesn't cast the spell automatically, it just presents the next best option for the user.

到目前为止,这是我的代码:

Here is my code so far:

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语句的正确部分,则该按钮将不起作用.

If heatingUpIsActive == true, I would like the button to cast ("spell", "Inferno Blast") instead of ("spell", "Fireball"), but it doesn't work if I place that into the correct part of the if statements.

有什么想法吗?

推荐答案

正如Mud所说,您无法在战斗中重新绑定按钮.暴雪进行了此更改,以防止机器人能够自动执行战斗.值得注意的是,要施放咒语,您需要使用一种安全模板,而这些安全模板仅允许修改属性,以控制未使用战斗时它们的工作.因此,您不能在战斗中一键更改法术.同样,它们也阻止您修改属性的位置或可见性,因此也不能在鼠标下方移动按钮.

As Mud said, you cannot rebind buttons in combat anymore. Blizzard made this change to prevent bots from being able to automate combat. Notably, in order to cast a spell you need to use one of the secure templates, and these secure templates only allow modification of the attributes that control what they do when you're not in combat. So you cannot have one button change spells mid-combat. Similarly, they also prevent you from modifying attributes like their position or visibility, so you cannot move buttons under the mouse either.

您能做的最好的事情就是显示一个视觉指示器,指示应该施放哪种咒语,但要依靠用户实际按下正确的按钮.

The best you can do is display a visual indicator of what spell should be cast, but rely on the user to actually press the correct button.

这篇关于魔兽世界Lua-更改框架:SetAttribute()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆