I've been messing around in lua recently, making basic UI mods and such. Bear in mind i'm no lua or programming expert, and as such my knowledge is limited. Anyway, i was playing around with position of monk chi bar on default blizzard UI. Since in legion chi will only be available to WW monks I figured i should use Specialization condition for that. Here is my code:
local _, Class = UnitClass("player") -- getting the player class
local spec_id = GetSpecialization() -- getting spec info
if Class == "MONK" then
if spec_id == 1 then --this is for brm stagger bar
MonkStaggerBar:SetPoint("CENTER",ParrentUI, "CENTER", 0, -185);
MonkStaggerBar.SetPoint = function() end
elseif spec_id == 3 then --this is for ww chi bar
MonkHarmonyBarFrame:SetPoint("CENTER",ParrentUI, "CENTER", 0, -185);
MonkHarmonyBarFrame.SetPoint = function() end
The problem is when I log in game frame doesn't move. When I do /reload it works perfectly. My guess is that GetSpecialization() function is called before game can even read what my spec is. I also tried printing value of "spec_id" after i grab it with GetSpecialization() function and got the same problem. "nil" when I log in, and value after reload.
If anyone can help me fix this that would be great.