Hello,
I'm trying to bind a spell to middle click depending on player class from within the Factory function. Somehow it doesn't work. Here the code snippets:
lua Code:
oUF:Factory(function(self)
local playerClass = cfg.playerClass
local spellName
if playerClass == "HUNTER" then
spellName = GetSpellInfo(34477) -- Misdirection
elseif playerClass == "DRUID" then
spellName = GetSpellInfo(29166) -- Innervate
elseif playerClass == "PALADIN" then
spellName = GetSpellInfo(31789) -- Righteous Defense
elseif playerClass == "WARRIOR" then
spellName = GetSpellInfo(3411) -- Intervene
elseif playerClass == "ROGUE" then
spellName = GetSpellInfo(57934) -- Tricks of the Trade
elseif not spellName then
spellName = "Misdirection"
end
self:SetActiveStyle("Rain")
self:Spawn("player", "oUF_Rain_Player"):SetPoint("CENTER", -210, -215)
self:Spawn("pet", "oUF_Rain_Pet"):SetPoint("BOTTOMLEFT", oUF_Rain_Player, "TOPLEFT", 0, 10)
self:Spawn("focus", "oUF_Rain_Focus"):SetPoint("BOTTOMRIGHT", oUF_Rain_Player, "TOPRIGHT", 0, 10)
self:Spawn("target", "oUF_Rain_Target"):SetPoint("CENTER", 210, -215)
self:Spawn("targettarget", "oUF_Rain_TargetTarget"):SetPoint("BOTTOMRIGHT", oUF_Rain_Target, "TOPRIGHT", 0, 10)
self:Spawn("focustarget", "oUF_Rain_FocusTarget"):SetPoint("BOTTOMLEFT", oUF_Rain_Target, "TOPLEFT", 0 , 10)
if (cfg.showParty) then
local party = self:SpawnHeader(
"oUF_Rain_Party", nil, "solo,party,raid",
"showParty", true,
"showRaid", true,
"showPlayer", true,
"showSolo", true,
"maxColumns", 4,
"unitsPerColumn", 1,
"columnAnchorPoint", "LEFT",
"columnSpacing", 7.5,
"oUF-initialConfigFunction", ([[
self:SetWidth(110)
self:SetHeight(22)
self:SetAttribute("type3", "spell")
self:SetAttribute("spell3", %s)
]]):format(spellName)
)
party:SetPoint("LEFT", UIParent, "BOTTOM", -231.25, 150)
party:Show()
end
...
I tested this on a druid, expecting to get Innervate or Misdirection if spellName and playerClass are not available. Instead I got nil. If I use self:SetAttribute("spell3", "Innervate") it works as expected. Is there an explanation for this? (Hopefully I typed it right
)
I could also set the secure attributes from within the Shared function. Do I loose or gain something when doing so?
Thank you for your help
Rain