Quantcast Moving a frame depending on spec - WoWInterface
Thread Tools Display Modes
08-20-18, 02:35 PM   #1
10leej
A Molten Giant
 
10leej's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2011
Posts: 573
Moving a frame depending on spec

So trying to set the position of my raid frames depending on whether the character is a healing spec or not since I like the raid frames under my character when I heal, but not any other time.
I figured using an event would work and while it does I can only seem to watch "PLAYER_ENTERING_WORLD" and while I see the other events fire they don't set the frame position unless I reload the UI.

I can't seem to find a working example either, but that might be me being lazy.

Lua Code:
  1. frame:SetScript("OnEvent", function(self, event, unit)
  2. if event == "PLAYER_SPECIALIZATION_CHANGED" or event == "PLAYER_ENTERING_WORLD" or event == "PLAYER_SPECIALIZATION_CHANGED" then
  3.   if (playerClass == "PRIEST" and GetSpecialization() == 1) then
  4.     frame:SetPoint(unpack(cfg.group.healposition))
  5.   elseif (playerClass == "PRIEST" and GetSpecialization() == 2) then
  6.     frame:SetPoint(unpack(cfg.group.healposition))
  7.   elseif (playerClass == "PALADIN" and GetSpecialization() == 1) then
  8.     frame:SetPoint(unpack(cfg.group.healposition))
  9.   elseif (playerClass == "DRUID" and GetSpecialization() == 4) then
  10.     frame:SetPoint(unpack(cfg.group.healposition))
  11.   elseif (playerClass == "MONK" and GetSpecialization() == 2) then
  12.     frame:SetPoint(unpack(cfg.group.healposition))
  13.   elseif (playerClass == "SHAMAN" and GetSpecialization() == 3) then
  14.     frame:SetPoint(unpack(cfg.group.healposition))
  15.   else
  16.     frame:SetPoint(unpack(cfg.group.position))
  17.   end
  18. end
  19. end)
  20. frame:RegisterEvent("PLAYER_TALENT_UPDATE")
  21. frame:RegisterEvent("PLAYER_SPECIALIZATION_CHANGED")
  22. frame:RegisterEvent("PLAYER_ENTERING_WORLD")

Complete Source Code

It is an oUF layout I'm working on, but I figured this was more of a general problem and not an oUF problem
__________________
Tweets Website
  Reply With Quote
08-20-18, 03:59 PM   #2
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 918
I dont' see a frame:ClearAllPoints()
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle and Move Pad Plus.
  Reply With Quote
08-20-18, 04:32 PM   #3
Vrul
A Frostmaul Preserver
 
Vrul's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2007
Posts: 284
You can make that handle future classes better:
Code:
local party = CreateFrame('Frame')
party:SetScript('OnEvent', function(self, event)
    self:UnregisterEvent(event)

    local function UpdatePosition(self)
        local _, _, _, _, role = GetSpecializationInfo(GetSpecialization())
        self:ClearAllPoints()
        self:SetPoint(unpack(cfg.group[role ~= 'HEALER' and "position" or "healposition"]))
    end
    UpdatePosition(self)

    self:SetScript('OnEvent', UpdatePosition)
    self:RegisterUnitEvent('PLAYER_SPECIALIZATION_CHANGED', 'player')
end)
party:RegisterEvent('PLAYER_ENTERING_WORLD')

Last edited by Vrul : 08-20-18 at 04:38 PM. Reason: Missing closing square bracket
  Reply With Quote
08-21-18, 05:21 PM   #4
10leej
A Molten Giant
 
10leej's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2011
Posts: 573
Originally Posted by Fizzlemizz View Post
I dont' see a frame:ClearAllPoints()
/doh

Originally Posted by Vrul View Post
You can make that handle future classes better:
Code:
local party = CreateFrame('Frame')
party:SetScript('OnEvent', function(self, event)
    self:UnregisterEvent(event)

    local function UpdatePosition(self)
        local _, _, _, _, role = GetSpecializationInfo(GetSpecialization())
        self:ClearAllPoints()
        self:SetPoint(unpack(cfg.group[role ~= 'HEALER' and "position" or "healposition"]))
    end
    UpdatePosition(self)

    self:SetScript('OnEvent', UpdatePosition)
    self:RegisterUnitEvent('PLAYER_SPECIALIZATION_CHANGED', 'player')
end)
party:RegisterEvent('PLAYER_ENTERING_WORLD')
That definately looks better
__________________
Tweets Website
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Moving a frame depending on spec

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off