You can just have one frame that hosts several Fontstrings and updates them as required (OnEvent, OnUpdate, or both) eg:
Lua Code:
local fpsCheck = 3 -- update ~3 seconds
local AshStats = CreateFrame("frame", "AshStatsFrame")
AshStats:SetBackdrop({ bgFile="Interface\\DialogFrame\\UI-DialogBox-Background",
edgeFile="Interface\\DialogFrame\\UI-DialogBox-Border",
tile=1, tileSize=32, edgeSize=32,
insets={left=11, right=12, top=12, bottom=11}
})
AshStats:SetWidth(170)
AshStats:SetHeight(400)
AshStats:SetPoint("CENTER",UIParent)
AshStats:EnableMouse(true)
AshStats:SetMovable(true)
AshStats:RegisterForDrag("LeftButton")
AshStats:SetScript("OnDragStart", function(self) self:StartMoving() end)
AshStats:SetScript("OnDragStart", function(self) self:StartMoving() end)
AshStats:SetScript("OnDragStop", function(self) self:StopMovingOrSizing() end)
AshStats:SetFrameStrata("FULLSCREEN_DIALOG")
-- fps fontstring
AshStats.fps = AshStats:CreateFontString("$parentFPS","OVERLAY","GameTooltipText")
AshStats.fps:SetPoint("TOPLEFT", 10, -10)
AshStats.fps:SetFont("Fonts\\FRIZQT__.TTF", 10, "THINOUTLINE")
-- latence fontstring
AshStats.lat = AshStats:CreateFontString("$parentLatency","OVERLAY","GameTooltipText")
AshStats.lat:SetPoint("TOPLEFT", AshStats.fps, "BOTTOMLEFT", 0, 0)
AshStats.lat:SetFont("Fonts\\FRIZQT__.TTF", 10, "THINOUTLINE")
-- zone fontstring
AshStats.zone = AshStats:CreateFontString("$parentZone","OVERLAY","GameTooltipText")
AshStats.zone:SetPoint("TOPLEFT", AshStats.lat, "BOTTOMLEFT", 0, 0)
AshStats.zone:SetFont("Fonts\\FRIZQT__.TTF", 10, "THINOUTLINE")
-- other fontstring
AshStats.arm = AshStats:CreateFontString("$parentArm","OVERLAY","GameTooltipText")
AshStats.arm:SetPoint("TOPLEFT", AshStats.zone, "BOTTOMLEFT", 0, 0)
AshStats.arm:SetFont("Fonts\\FRIZQT__.TTF", 10, "THINOUTLINE")
AshStats:RegisterEvent("PLAYER_ENTERING_WORLD");
AshStats:RegisterEvent("ZONE_CHANGED")
AshStats:RegisterEvent("ZONE_CHANGED_INDOORS")
AshStats:RegisterEvent("ZONE_CHANGED_NEW_AREA")
local function eventHandler(self, event, ...)
if event == "PLAYER_ENTERING_WORLD" then -- updates on entering world events only
self.arm:SetText("Some Stat or other")
end
-- everthing below updates on all events
-- zone text
self.zone:SetText(GetMinimapZoneText())
local r, g, b = 1, 1, 1
local ZoneType = GetZonePVPInfo()
if ZoneType == "sanctuary" then
r, g, b = .41, .8, .94
elseif ZoneType == "friendly" then
r, g, b = .1, 1, .1
elseif ZoneType == "contested" then
r, g, b = 1, .7, 0
elseif ZoneType == "hostile" then
r, g, b = 1, .1, .1
elseif ZoneType == "arena" then
r, g, b = 1, .1, .1
else
r, g, b = 1, .82, 0
end
self.zone:SetTextColor(r, g, b)
end
AshStats:SetScript("OnEvent", eventHandler);
AshStats.elapsed = fpsCheck
AshStats:SetScript("OnUpdate", function(self, elapsed)
self.elapsed = self.elapsed - elapsed -- Countdown to zero
if self.elapsed > 0 then return end
self.elapsed = fpsCheck -- and reset/start again
-- FPS
self.fps:SetText("Frame Rate - "..format("%0.i", GetFramerate()))
-- Latency
local _,_,Latency = GetNetStats()
local r, g, b
if Latency > PERFORMANCEBAR_MEDIUM_LATENCY then -- 600
r, g, b = 1, 0, 0
elseif Latency > PERFORMANCEBAR_LOW_LATENCY then -- 300
r, g, b = 1, .82, 0
else
r, g, b = 0, 1, 0
end
self.lat:SetText(Latency.."ms")
self.lat:SetTextColor(r, g, b)
end)