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. |
|
04-12-13, 05:59 AM | #7 | |
Your problem was "self" on icon setpoint.
I added some suggestions. Lua Code:
Not sure how your panel should look. But do a quick test. Is this your panel? Lua Code:
If yes you can use the "ButtonFrameTemplate" to create your panel. It will have all the buttons already included. There are ton of other templates. Hmm I just checked. BankFrame.xml is using "PortraitFrameTemplate". So you can probably use that instead. https://github.com/tekkub/wow-ui-sou...kFrame.xml#L94 .
__________________
| Simple is beautiful. | WoWI AddOns | GitHub | Zork (WoW)
Last edited by zork : 04-12-13 at 06:10 AM. |
||
04-12-13, 06:09 AM | #8 | |
But still the buttons ain't created. hmm |
||
04-12-13, 06:13 AM | #9 | |
Please don't quote full posts.
You have "lua errors" enabled right? Have you seen my texture change? You used "OVERLAY". It may "overlay" all your buttons . Addtionally check my panel template edit. It is good practice to use already given Blizzard templates. Especially if you want to copy-cat the BankUI. Normally you don't have to create your panel manually. There are basic templates that wil do this for you. Btw there is a button template for bank icons aswell. That is: "BankItemButtonGenericTemplate" So you could change your button to: Lua Code:
First use templates for stuff. If sth is missing or you need changes you can still do that afterwards. You don't have to reprogram templates.
__________________
| Simple is beautiful. | WoWI AddOns | GitHub | Zork (WoW)
Last edited by zork : 04-12-13 at 06:21 AM. |
||
04-12-13, 06:23 AM | #10 |
Thank you!!! It sort of worked, just have to change a few options as the frame itself got kinda ****ed ^^ But the buttons is now shown as expected!
Also i didn't have LUA Errors enabled till now... OMG :P Is there any smart AddOn/Tool/w.e to help you get the anchor point of something? Like i keep testing anchor points and then use /reload ingame to see the result? Last edited by fRodzet : 04-12-13 at 06:35 AM. |
|
04-12-13, 07:40 AM | #11 | |
Well...you can make inline frame dragable aswell. You listen to DragStop.
Once that fires you calculate the point diffenrence of the parent element to your current frame. I used this function somewhere. I can be changed to deliver the offset you need for your stuff. But actually I do resize/reloading. You only need a couple of tries to get stuff right and don't need to do it again. Lua Code:
__________________
| Simple is beautiful. | WoWI AddOns | GitHub | Zork (WoW)
Last edited by zork : 04-12-13 at 07:43 AM. |
||
04-12-13, 09:24 AM | #12 | ||
Code:
item.coun:SetPoint("BOTTOMRIGHT", -5, 2) $parent works for any function in the Widget API and CreateFrame() that can reference a frame by its name. Just think of Lua as a backend for the XML. Using the right functions, you can just plug in the values directly. More information on these functions is available in the Widget API page on WoWPedia. Note CreateFrame() is in the WoW API section.
__________________
WoWInterface AddOns
|
|||
WoWInterface » Developer Discussions » Lua/XML Help » Help Creating Textures, Frames, etc in Lua. And some questions! |
«
Previous Thread
|
Next Thread
»
|
Thread Tools | |
Display Modes | |
|
|