Go to Page... |
|
Thread Tools | Display Modes |
|
04-11-13, 01:03 PM | #1 |
Help Creating Textures, Frames, etc in Lua. And some questions!
Greetings,
Okay, so i'm trying to create a complete working AddOn using lua only! I know how to create a few using .XML to make the graphics and add event handlers. But i'm not sure in lua. As an example i'm going to use BagBuddy. Allright, first i would like to ask if this is considered readable or if it can be written in an better way: Lua Code:
the function BagBuddy_OnLoad(self) is empty because i'm not sure on how i would add 28 x buttons to the frame without using an XML template. The template for the original BagBuddy looks like this: XML Code:
Using the above template i would add each button to the frame like this: Lua Code:
but this is easy because i can inherit the item's from BagBuddyItemTemplate in my XML document. How can i create something similar using lua only? Also how do i set alphaMode="ADD" in lua? Hope you guys understand what i'm trying to accomplish, if not, please ask me and i'll try to explain |
|
04-11-13, 03:09 PM | #2 |
We already discussed "templates" in Lua here: http://www.wowinterface.com/forums/s...ad.php?t=46184
|
|
04-11-13, 03:40 PM | #3 |
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. Last edited by Haleth : 04-11-13 at 03:45 PM. |
|
04-11-13, 08:25 PM | #4 | |
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:
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
Last edited by SDPhantom : 04-11-13 at 08:31 PM. |
||
04-12-13, 04:43 AM | #5 | |||
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. |
||||
04-12-13, 05:46 AM | #6 |
Allright here is my code, but it ain't working.. Doesn't create a button. Sorry - but as of now i'm still not good enough to figure out myself how to get it working, so some more help would be Lovely!
Lua Code:
I looked it through and doesn't seem like a typing mistake. Last edited by fRodzet : 04-12-13 at 05:55 AM. |
|
WoWInterface » Developer Discussions » Lua/XML Help » Help Creating Textures, Frames, etc in Lua. And some questions! |
«
Previous Thread
|
Next Thread
»
|
Display Modes |
Switch to Linear Mode |
Hybrid Mode |
Switch to Threaded Mode |
|
|