View Single Post
04-11-13, 08:25 PM   #4
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,327
You pretty much have the framework down for transferring your template into Lua, All you really need to do is put in the code for Lua to create the objects within the loop that the template would've done.

Lua Code:
  1. local item=CreateFrame("Button","BagBuddy_Item"..idx,frame,"SecureActionButtonTemplate");
  2. item:SetSize(37,37);
  3. item:SetAttribute("type2","item");
  4. item:SetScript("OnEnter",BagBuddy_Button_OnEnter);
  5. item:SetScript("OnLeave",BagBuddy_Button_OnLeave);
  6.  
  7. item:SetNormalTexture("Interface\\Buttons\\UI-Quickslot2");
  8. item:SetPushedTexture("Interface\\Buttons\\UI-Quickslot-Depress");
  9. item:SetHighlightTexture("Interface\\Buttons\\ButtonHilight-Square","ADD");
  10. do local tex=item:GetNormalTexture();-- Hack to modify the existing texture object
  11.     tex:ClearAllPoints();
  12.     tex:SetPoint("CENTER",0,-1);
  13.     tex:SetSize(64,64);
  14. end
  15.  
  16. item.icon=item:CreateTexture("$parentIconTexture","BORDER");
  17.  
  18. item.count=item:CreateFontString("$parentCount","BORDER","NumberFontNormal");
  19. item.count:SetPoint("BOTTOMRIGHT",-5,2);
  20. item.count:SetJustifyH("RIGHT");
  21. item.count:Hide();
  22.  
  23. item.glow=item:CreateTexture("$parentGlow","OVERLAY");
  24. item.glow:SetPoint("CENTER");
  25. item.glow:SetSize(70,70);
  26. item.glow:SetTexture("Interface\\Buttons\\UI-ActionButton-Border");
  27. item.glow:SetBlendMode("ADD");
  28. item.glow:SetAlpha(0.6);

If there aren't any errors I missed, that should create the exact frame your template is making. Just replace the line where you create the item button with this and as Haleth suggested, move the contents of the OnLoad function to the main chunk and replace all references of self with frame.
__________________
WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)

Last edited by SDPhantom : 04-11-13 at 08:31 PM.
  Reply With Quote