View Single Post
04-12-13, 04:43 AM   #5
fRodzet
A Flamescale Wyrmkin
Join Date: Mar 2013
Posts: 114
Originally Posted by Seerah View Post
We already discussed "templates" in Lua here: http://www.wowinterface.com/forums/s...ad.php?t=46184
I'm sorry for the double post, but i had more questions for my lua code than in that topic - i should have edited the post.

Originally Posted by Haleth View Post
First of all, your code looks good, but you're making your functions global. They should either be local or part of the frame's table, like you do with the frame's regions/children.

Your BagBuddy_MakeMovable function is not needed, since you're only calling it once (at least so far). Just use the function's body, replacing 'self' with 'frame', your local variable.

OnLoad functions don't actually work in lua, because after calling CreateFrame(), the frame's (non-existing) OnLoad handler will have run already. Just put the code directly in the source file.

As for the alpha mode, that would be SetBlendMode.
Thank you for the answer! I'll make my functions local instead. I decided to use the BagBuddy_MakeMovable function as i was not sure to wether i was going to develop the bagbuddy abit and maybe add some new feutures which would maybe require a new frame - if this is not the case i will ofc add the movable scripts directly to the frame created.

Originally Posted by SDPhantom View Post
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.
Thank you so much! Imma look this code through and see what youve done! Also thank you for showing how to give the ADD alphaMode in lua, i tried: SetHighlightTexture("Source", SetAlpha="ADD") haha now i get why that didn't work

imma update the full script soon, and tell you guys if i got any errors.

$parent works for lua aswell? or is that XML only?

Last edited by fRodzet : 04-12-13 at 04:46 AM.
  Reply With Quote