I would definitely use the manually created table instead. That's more reliable.
You're just missing a reference to your font strings. When you make the global reference the variable will just be overwritten and refer to whatever you assigned to it last, as you've noticed. What you should do is make a reference on the frames themselves.
Do this when creating the frames:
Code:
for k, v in ipairs(DCSITEM_SLOT_FRAMES) do
local duraFS = v:CreateFontString("FontString","OVERLAY","GameTooltipText")
duraFS:SetPoint("BOTTOM",v,"BOTTOM",0,0);
duraFS:SetFont("Fonts\\FRIZQT__.TTF", 14, "THINOUTLINE");
duraFS:SetFormattedText("lollolol");
v.durability = duraFS
end
You may now access the font string through the
durability field of each frame.
Code:
local function duraRefresh()
for k, v in ipairs(DCSITEM_SLOT_FRAMES) do
local slotId = v:GetID();
-- print(slotId)
local durCur, durMax = GetInventoryItemDurability(slotId)
if durCur == nil or durMax == nil then
v.durability:SetFormattedText("");
elseif ( durCur ~= durMax ) then
v.durability:SetFormattedText("%.0f%%", durCur*(100/durMax));
end
end
end