I have a small function that intends to bring back old cartographer-style world map blips - with embedded group #s and colour changes when the unit is in specific conditions like combat or AFK.
Lua Code:
--
local blippadding = 5
--
local frame = CreateFrame("Frame", nil, WorldMapFrame)
local frequency = .5 -- how often to update blips (while in group when map shown)
local timer = frequency
frame:Hide()
frame:SetScript("OnUpdate", function(self, elapsed)
timer = timer + elapsed
if (timer > frequency) then
timer = 0
local groupSize = GetNumGroupMembers()
local groupUnit = IsInRaid() and "Raid" or "Party"
if (groupSize > 0) then
for i = 1, groupSize do
local blip = _G["WorldMap"..groupUnit..i]
local blipoverlay = blip:CreateTexture(nil, "OVERLAY")
blipoverlay:SetDrawLayer("OVERLAY", 7)
blipoverlay:SetPoint("TOPLEFT", blip.icon, -blippadding, blippadding)
blipoverlay:SetPoint("BOTTOMRIGHT", blip.icon, blippadding, -blippadding)
if blip and blip.unit and blip:IsVisible() then
local _, class = UnitClass(blip.unit)
local _, _, subgroup = GetRaidRosterInfo(i)
if not blip.skinned then
if (UnitInRaid(blip.unit)) then
blipoverlay:SetTexture(format("Interface\\AddOns\\WorldMapForModernists\\blips\\raid%d", subgroup))
else
blipoverlay:SetTexture("Interface\\AddOns\\WorldMapForModernists\\blips\\party")
end
blip.skinned = true
end
if (blip.skinned) then
-- color the texture
local color = CUSTOM_CLASS_COLORS or RAID_CLASS_COLORS[class]
-- by class
if color then
blipoverlay:SetVertexColor(color.r, color.g, color.b)
-- fallback
else
blipoverlay:SetVertexColor(103/255, 103/255, 103/255)
end
if (GetTime() % 1 < .5) then
-- combat (flashing)
if UnitAffectingCombat(blip.unit) then
blipoverlay:SetVertexColor(1, 0, 0)
-- dead (flashing)
elseif UnitIsDeadOrGhost(blip.unit) then
blipoverlay:SetVertexColor(.2, .2, .2)
-- AFK (flashing)
elseif UnitIsAFK(blip.unit) then
blipoverlay:SetVertexColor(255/255, 206/255, 206/255)
end
end
end
end
end
end
end
end)
frame:SetScript("OnEvent",function(self,event)
timer = frequency
self:SetShown(IsInGroup())
end)
frame:RegisterEvent("GROUP_ROSTER_UPDATE")
frame:RegisterEvent("WORLD_MAP_UPDATE")
the colour updates currently won't update like this. If I remove the blip.skinned check on line 25 then it
does update as intended, but I assume that's because it's creating a new texture on every pass which is understandably a very bad thing. I recognise that this is probably written very badly, so what do I need to do to make this work?