|
10-06-19, 09:17 AM | #1 |
Beginner LF help
Hey im at the very begining when it comes to lua and addons overall. However I did quite enjoy my recent attempts to create my own addons in Classic, but some questions popped in my head and I cant find answers on my own. I would be very happy if someone could help answer any (or all ) of these
My first addon attempt was to show HP&mana text on target and party frames. Its working fine more or less besides this part of code (which I had to replace for manualy written partyframes 1-4). Code:
_G["HealthFrame_party"..i] = CreateFrame("Frame", "HBar_party"..i, UIParent) local HP_something = _G["Health_TEXT_" .. i]; _G["HealthFrameText_party"..i] = HP_something:CreateFontString("Health_TEXT_party"..i, "OVERLAY", "TextStatusBarText") _G["Health_TEXT_party"..i]:SetFont("Fonts\\FRIZQT__.TTF", 10, "OUTLINE") _G["HealthFrameText_party"..i]:ClearAllPoints() _G["HealthFrameText_party"..i]:SetPoint("CENTER", "PartyMemberFrame"..i , "CENTER", 20, 10); Code:
local HP_fontstring = _G["Health_TEXT_" .. unitToken]; HP_fontstring:SetFormattedText("%0.f%%", HealthPercent * 100) Next question is regarding to the _G["string"]. After I used it about 100x times, I gained understanding that it changes string to global variable. Is that correct? In general, should I avoid using too many global variables when making an addon? Would adding local before declaring them help? Next question is about CreateFontString() and SetFont(). Is there a function that would combine these two lines together? i wanted to use font FRIZQT__.TTF", 10, "OUTLINE" So I checked all the game fonts that looks the same and from which my CreateFontString() could inherit from, but I couldnt find one. It either was wrong size, outline or different colour than I wanted. My second (current) addon attemp is to permanently show buffs on party member frames. While I got the main part somewhat working (time will show). I havent figured out any other way to do this than making 4*16 frames for each buff slot on each party member, which is probably wasteful approach to do it? Code:
for m = 1, 4 do for i = 1, 16 do _G["f"..i..m] = CreateFrame("Frame", nil ,UIParent) _G["f"..i..m]:SetFrameStrata("BACKGROUND") _G["f"..i..m]:SetSize(16, 16) _G["t"..i..m] = _G["f"..i]:CreateTexture(nil,"ARTWORK") _G["t"..i..m]:SetAllPoints(_G["f"..i]) _G["t"..i..m].texture = _G["t"..i] _G["f"..i..m]:SetPoint("BOTTOMRIGHT", "PartyMemberFrame" .. m, "BOTTOMRIGHT", (i*16), 0); end end Im very thankful for any advice! |
|
WoWInterface » Developer Discussions » Lua/XML Help » Beginner LF help |
«
Previous Thread
|
Next Thread
»
|
Display Modes |
Switch to Linear Mode |
Hybrid Mode |
Switch to Threaded Mode |
|
|