Where to start? - Boilerplate Help
Hi all,
I'll preface this by admitting that I'm very new to all of this; outside of editing the lua of existing addons, I don't have much experience and I'm pretty much learning as I go. My first question is about documentation--I've not found much other than the in-line documentation in the oUF code and the boilerplate. Does anything along these lines exist? I've had a go at spawning a player health bar; it's not throwing up any errors but isn't displaying either. I feel like I might have missed something really obvious, but after an hour of checking various bits I just can't work it out. Can anyone point me in the right direction? EDIT: Having tested, my party frames have disappeared too. Thanks in advance! I have oUF where it should be (unembedded) and have a single TOC entry pointing to a single LUA file (which I've pasted in its entirety below): Lua Code:
|
Here is a super simple layout to get you started.
https://github.com/zorker/rothui/blo...iler/spawn.lua Personally I have not used the factory yet. Spawning any unit other than party and raid is pretty straight forward. Those need a group header and some more config settings. |
Thanks Zork (big fan!), this is exactly what I was looking for.
Would you mind briefly explaining how oUF Factory works? As I understand it, it's just a pre-built frame that you can edit, rather than spawning your own--is that right? |
You can check p3lims layout.
https://github.com/p3lim-wow/oUF_P3l...P3lim.lua#L610 The factory allows you to register a function that runs on PLAYER_LOGIN which normally activates a style function and spawns all the units you have specified. p3lim is using one style function for all called Shared but in that style function he has a conditional check for unitspecific. If it matches another subset function will be called for unitspecific settings. My approach is a little different. I like to have seperate style functions per unit that load a unit specific config and then call a generic style function which is creating all desired elements based on config settings. On top of that I spawn the units directly when the addon is loaded and not on player login. You would need to do the latter if you have saved variables which load after the addon is executed and before the player is logged in. You can easily use the factory with my example by enclosing the spawn in a function which you call with the factory. https://github.com/zorker/rothui/com...c338fbdc454150 |
Useful, thank you.
I think that what I'm failing to understand is what oUF Factory actually does. What purpose does it serve? Like I say, I'm a total beginner. |
If the player is logged in the function provided to the factory is called immediately. If not it is called once the event PLAYER_LOGIN has fired.
https://github.com/oUF-wow/oUF/blob/...actory.lua#L27 |
Gotcha. Thanks for your help man. :)
I'm sure I'll be back in the future with some more questions! |
Quote:
@Jagwah You pass a callback to the factory, that is a function which specifies which styles are to be used for which units, and creates (spawns) and places the unit frames. You can call the factory multiple times. Callbacks are then executed in the call order, thus you control this order for your layout. So basically a callback suitable for oUF's factory is a function consisting of calls to oUF:SetActiveStyle, oUF:Spawn/oUF:SpawnHeader and frame:SetPoint. oUF is passed as an argument to your callback and frame is the return of :Spawn/:SpawnHeader A style in oUF terms is a tuple consisting of a style name and a style function. The name has to be unique, so using your layout name as a prefix is a good idea. The style function defines the visual appearance of the unit frames spawned in the factory callback after :SetActiveStyle has been called with the specified style name. Your styles have to be known to oUF, so you have to use oUF:RegisterStyle(styleName, styleFunction) before you call oUF's factory. How and where you define your style function is entirely up to you. Normally you would strive to do some separation by domain and by concern and reduce code repetition. This will make your code easier to read and follow and thus easier to maintain. A good idea is to define different styles for different units based on their appearance, e.g. player and target are normally the most prominent frames in a layout, so group them together in one style. Pet, focus and targettarget could share a separate style as well, the same for party and raid. You could then easily test different styles by just changing the argument in the :SetActiveStyle call. |
I'm really not sure what to say...
|
Thanks Rainrider, that puts it in really simple terms.
I'm not sure what you mean, Zork? I've had a busy few weeks but got some time to sit down with your boiler layout this evening. Reading over all of this has made me realise that I probably need to revise the basics before I can make sense of everything, but this is more than enough to get started. One more question, and I appreciate that I've asked a lot already--how would spawning nameplates work in your way of doing things? The demo in the sticky uses unit:match("nameplate") as part of an if statement, but I can't see any way to check for that in your example. Would you create a separate config entry for L.C.nameplate, and then link that back to oUF using frame.health = XXXX? Or would it need to be handled totally separately as it isn't sharing the common style? I'm not entirely sure I'm making sense, so don't worry too much if I'm way off the mark. Still a lot to learn! Thanks, both, for your help. |
That was just regarding Rainriders quote. By the time of posting I had not used the Factory. I added two posts later and linked the commit.
Nameplates are easy to spawn too. https://github.com/zorker/rothui/blo...spawn.lua#L148 https://github.com/oUF-wow/oUF/blob/master/ouf.lua#L742 |
Ah, right.
Thanks so much for your help, it's much appreciated. Plenty to be getting on with! |
Hello again -- I've had a play around with the boiler layout and after rewriting a few times to try and get the hang of it, I've managed to get a power bar loaded too.
The problem that I'm having is that despite setting different points in the settings table, the power bar is layering directly under the health bar, and I can't get it to move. Here's my code: https://pastebin.com/y7wqPLiY I'm sure there are more efficient ways to setup the power bar than directly duplicating the SetupFrame function, but this was the easiest way I could work it out! Any ideas? |
To me, it seems like you are setting points of oUF object, not a power bar's.
Code:
local function SetupHealthFrame(self) |
You are placing the health and power bars on top of each other.
|
All times are GMT -6. The time now is 10:28 PM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI