Thread Tools Display Modes
Prev Previous Post   Next Post Next
06-15-10, 08:44 AM   #1
Grimsin
A Molten Giant
 
Grimsin's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2006
Posts: 990
breaking it down.

Okay upon everyone's suggestion im attempting to shorten code.

best way i can see especially when needing to do something for 4 sets of frames all the time, is to use local function blahblah(i) where i = the partyframe number. The problem or question i have is how to tag certain lines when trying to use ..i.. like the following...

lua Code:
  1. local function Party1Style1NameTextEvents()
  2.     local Party1Exists = UnitExists("Party1")
  3.     if Party1Exists == 1 then
  4.         local Party1Name = UnitName("Party1")
  5.         local Party1NameStr = ("%s"):format(Party1Name)
  6.         Party1NameText:SetText(Party1NameStr)
  7.     end
  8.         GrimUI.Party1NameColoring()
  9. end
  10. GrimUI.Party1Style1NameTextEvents = Party1Style1NameTextEvents

ultimately i need everywhere it says Party1 to read Party..i..

ive been successful in breaking down somethings but the tag is different for certain things... like the following
lua Code:
  1. CreateFrame('Frame', "Party"..i.."PedestalFrame", _G["GUI_Party"..i.."Frame"])

the one version is a already made frame... the other is the new frame. one needs _G and [] the other does not. there is a handful of other things not frame name or current frame id like to change 1 to a variable to shorten the 4x repeated party frame creation...
__________________
"Are we there yet?"

GrimUI
[SIGPIC][/SIGPIC]
  Reply With Quote
 

WoWInterface » Developer Discussions » Lua/XML Help » breaking it down.


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off