Hello again everyone,
I'm working on a small script that makes the MultiBarBottomLeft page with player stance; it works great except one minor problem. When the player zones (either on first login or on entering instance) it randomly is set to the wrong bar. For characters with stances (warrior/druid/rogue) simply switching stances fixes it; for everyone else you have to /reload until it fixes (almost always the first reload).
Not a major issue really, I'm just curious as to what I'm doing wrong
Thanks in advance!
EDIT:
If it helps, it appears as though when it's "broken" it's set to bar 6, which I believe is the default bar for MultiBarBottomLeft perhaps? It's strange though, I have it printing whenever GetBar() is called; it's being called 3 times when you first log in, so you'd imagine that it was actually working.
Is there some self:ForceUpdatePage() I can call on login to ensure that it works proper?
EDIT 2:
Can't seem to figure this one out still; I just switched it to be based out of bar 6 instead of bar 2 which "fixed" it in the sense that when it's not working it's still correct.
Code:
if not TukuiCF["actionbar"].enable == true then return end
---------------------------------------------------------------------------
-- Setup Main Action Bar.
-- Now used for stances, Bonus, Vehicle at the same time.
-- Since t12, it's also working for druid cat stealth. (a lot requested)
---------------------------------------------------------------------------
local bar = CreateFrame("Frame", "TukuiBar2", TukuiActionBarBackground, "SecureHandlerStateTemplate")
bar:ClearAllPoints()
bar:SetAllPoints(TukuiActionBarBackground)
bar:SetFrameLevel(12)
MultiBarBottomLeft:SetParent(bar)
--[[
Bonus bar classes id
DRUID: Caster: 0, Cat: 1, Tree of Life: 2, Bear: 3, Moonkin: 4
WARRIOR: Battle Stance: 1, Defensive Stance: 2, Berserker Stance: 3
ROGUE: Normal: 0, Stealthed: 1
PRIEST: Normal: 0, Shadowform: 1
When Possessing a Target: 5
]]--
local Page = {
["DRUID"] = "[bonusbar:1] 8; [bonusbar:2] 2; [bonusbar:3] 10; [bonusbar:4] 2;",
["WARRIOR"] = "[bonusbar:1] 2; [bonusbar:2] 8; [bonusbar:3] 10;",
["ROGUE"] = "[bonusbar:1] 8;",
["DEFAULT"] = "[bonusbar:0] 2;[bar:2] 2; [bar:3] 2; [bar:4] 2; [bar:5] 2; [bar:6] 2; [bonusbar:5] 2;",
}
local function GetBar()
local condition = Page["DEFAULT"]
local class = TukuiDB.myclass
local page = Page[class]
if page then
condition = condition.." "..page
end
condition = condition.." 2"
print(condition)
return condition
end
bar:RegisterEvent("PLAYER_LOGIN")
bar:RegisterEvent("PLAYER_ENTERING_WORLD")
bar:RegisterEvent("PLAYER_TALENT_UPDATE")
bar:RegisterEvent("ACTIVE_TALENT_GROUP_CHANGED")
bar:RegisterEvent("KNOWN_CURRENCY_TYPES_UPDATE")
bar:RegisterEvent("CURRENCY_DISPLAY_UPDATE")
bar:RegisterEvent("BAG_UPDATE")
bar:SetScript("OnEvent", function(self, event, ...)
if event == "PLAYER_LOGIN" then
local button
for i = 1, NUM_ACTIONBAR_BUTTONS do
button = _G["MultiBarBottomLeftButton"..i]
self:SetFrameRef("MultiBarBottomLeftButton"..i, button)
end
self:Execute([[
buttons = table.new()
for i = 1, 12 do
table.insert(buttons, self:GetFrameRef("MultiBarBottomLeftButton"..i))
end
]])
self:SetAttribute("_onstate-page", [[
control:ChildUpdate("state", newstate)
for i, button in ipairs(buttons) do
button:SetAttribute("actionpage", tonumber(newstate))
end
]])
RegisterStateDriver(self, "page", GetBar())
elseif event == "PLAYER_ENTERING_WORLD" then
--MainMenuBar_UpdateKeyRing()
local button
for i = 1, 12 do
local b = _G["MultiBarBottomLeftButton"..i]
local b2 = _G["MultiBarBottomLeftButton"..i-1]
b:ClearAllPoints()
if i == 1 then
if TukuiDB.lowversion and TukuiCF.actionbar.bottomrows == 2 then
b:SetPoint("BOTTOM", ActionButton1, "TOP", 0, TukuiDB.Scale(4))
else
b:SetPoint("LEFT", ActionButton12, "RIGHT", TukuiDB.Scale(4), 0)
end
else
b:SetPoint("LEFT", b2, "RIGHT", TukuiDB.buttonspacing, 0)
end
end
elseif event == "PLAYER_TALENT_UPDATE" or event == "ACTIVE_TALENT_GROUP_CHANGED" then
if not InCombatLockdown() then -- Just to be safe
RegisterStateDriver(self, "page", GetBar())
-- Due to some odd reason these bars (MultiBarRight, MultiBarLeft) are changing position after you spent a talent point, and switch spec,
-- I couldn't watch the exact event that does it even by using ':RegisterAllEvents()', until I'll figure it out, here is an awful hack.
if event == "ACTIVE_TALENT_GROUP_CHANGED" then
local t = 0
self:SetScript("OnUpdate", function(self, elapsed)
t = t + elapsed
MainMenuBar:Hide()
UIParent_ManageFramePositions()
if t > 5 then
t = 0
self:SetScript("OnUpdate", nil)
end
end)
end
end
else
MainMenuBar_OnEvent(self, event, ...)
end
end)