Skip to content

@renstrom /custom.lua
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Custom script for oUF_NeavRaid that automatically positions and scales the raid frames based on spec and size of the raid
--[[
Slash command usage:
/raidscale 1.2
/raidscale reset
/rs 1.2
/rs reset
]]--
--[ CONFIG ]--
local healerPosition = {'LEFT', UIParent, 'CENTER', 200, 0}
local dpsPosition = {'RIGHT', UIParent, 'RIGHT', -350, 0}
local scaleThreshold = 28 -- Number of players needed to change the raid scale
local largeRaidScale = 0.95 -- Scale
--[ ENDCONFIG ]--
if IsAddOnLoaded('Aptechka') then return end
local _, ns = ...
local config = ns.Config
local userSetScale = false -- Don't do automatic scaling if the user set a custom value by slash command
local function MoveRaidFrames(point, parent, parentPoint, xOffset, yOffset)
for i = 1, config.units.raid.layout.numGroups do
_G['oUF_Neav_Raid'..i]:ClearAllPoints()
if (i == 1) then
_G['oUF_Neav_Raid'..i]:SetPoint(point, parent, parentPoint, xOffset, yOffset)
else
_G['oUF_Neav_Raid'..i]:SetPoint('TOPLEFT', 'oUF_Neav_Raid'..i-1, 'TOPRIGHT', 7, 0)
end
end
end
local function ScaleRaidFrames(scale)
scale = tonumber(scale)
scale = math.abs(scale)
-- Scaling the raid frames causes taint/errors during combat
if InCombatLockdown() or UnitAffectingCombat('player') or UnitAffectingCombat('pet') then
return
end
if scale then
for i = 1, config.units.raid.layout.numGroups do
_G['oUF_Neav_Raid'..i]:SetScale(scale)
end
end
end
local function IsHealer()
return GetSpecialization() and GetSpecializationRole(GetSpecialization()) == 'HEALER'
end
local f = CreateFrame('Frame')
f:RegisterEvent('PLAYER_ENTERING_WORLD')
local function OnEvent(self, event, ...)
if event == 'PLAYER_ENTERING_WORLD' then
self:UnregisterEvent('PLAYER_ENTERING_WORLD')
self:RegisterEvent('ACTIVE_TALENT_GROUP_CHANGED')
self:RegisterEvent('GROUP_ROSTER_UPDATE')
end
if event == 'ACTIVE_TALENT_GROUP_CHANGED' or event == 'PLAYER_ENTERING_WORLD' then
if IsHealer() then
MoveRaidFrames(unpack(healerPosition))
else
MoveRaidFrames(unpack(dpsPosition))
end
end
if event == 'GROUP_ROSTER_UPDATE' and not userSetScale then
if GetNumGroupMembers() >= scaleThreshold then
ScaleRaidFrames(largeRaidScale)
else
ScaleRaidFrames(config.units.raid.scale)
end
end
end
f:SetScript('OnEvent', OnEvent)
-- SLASH COMMANDS
SlashCmdList['RAIDSCALE'] = function(scale)
if InCombatLockdown() or UnitAffectingCombat('player') or UnitAffectingCombat('pet') then
return
end
if scale == 'reset' then
ScaleRaidFrames(config.units.raid.scale)
userSetScale = false
return
end
if tonumber(scale) then
ScaleRaidFrames(scale)
userSetScale = true
else
DEFAULT_CHAT_FRAME:AddMessage('Usage: "/raidscale 1.2" or "/raidscale reset"', 255, 0, 0)
end
end
SLASH_RAIDSCALE1 = '/raidscale'
SLASH_RAIDSCALE2 = '/rs'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.