WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   oUF (Otravi Unit Frames) (https://www.wowinterface.com/forums/forumdisplay.php?f=87)
-   -   Beginner (https://www.wowinterface.com/forums/showthread.php?t=56131)

GreyFox777 03-28-18 09:14 PM

Beginner
 
Hello community!


Im new to Ouf and i want to start learning and write my own unit frames. Can you help me to get started?

I need some examples of Addon structure (toc/lua files),

and if possible the code to create player frame and clickable overlay over the player frame,with their own width and height.

runamonk 03-29-18 04:38 AM

I would check out some existing ones.

oUF P3lim / oUF Simple are good ones to help you start.

Look here at all the layouts.

GreyFox777 03-29-18 10:08 AM

well... i did that 10 times... i just cannot understand what there is.

Rainrider 03-29-18 10:22 AM

I would highly recommend oUF_p3lim or oUF_Phanx over oUF_Simple.

If you are up to it, you could also try oUF_Layout, which is a layout planned for learning purposes. However it is still work in progress and it lacks review, but most of the planned stuff is already in there. I'm planning a small code guide but am not sure when I'll have the time to finish it. Maybe parts of the code will change and some could get rebased to get a smoother learning curve based on feedback.

You could just follow the commits to see how the layout evolved. The prerequisites are that you know the Lua basics and get along with Github. Just ask here if you have trouble understanding something.

GreyFox777 03-29-18 11:30 AM

Seems interesting. So i have to work only in settings.lua? How do i change the color of a bar? The bar are black, and i want to get then from green 100% of HP to red 0% of hp.

I just do not understand how the framework makes everything easier for me?

Rainrider 03-29-18 01:35 PM

The idea is to follow the commit order and recreate the changes locally for yourself.

For example the first commit shows that a file named oUF_Layout.toc was created and some content added to it. You place this file in a folder named oUF_Layout, and this folder itself resides in your WoW addons folder (World of Warcraft\Interface\AddOns). This is the same for every addon and is required for it to be loaded by WoW.

Every commit in Git holds a diff of the current state (the one introduced by the commit) of the repository compared to the previous one. So viewing a commit on Github shows you exactly what was added (green) and removed (red) and where. There is also a short commit message that explains the reason for it. This however means that you should follow the commits in order, if you want to learn and are a beginner.

From the fifth commit onward you will start to see the layout in-game (or rather parts of it). Feel free to change the code and reload the interface to view your changes. Breaking it is part of learning how it works.

Quote:

So i have to work only in settings.lua?
No. All of it is required. Every piece of code is there for a reason.

Quote:

How do i change the color of a bar?
Just try to recreate the commits one by one until you reach the one with the message "Add some custom colors". If you can't answer your question yourself by then, ask here again.

Quote:

The bar are black, and i want to get then from green 100% of HP to red 0% of hp.
Depends on which bars you are referring to. For the health and power bars, oUF has the .colorSmooth option. oUF_Layout uses this for the health bars of the player and target frames.

Quote:

I just do not understand how the framework makes everything easier for me?
Imagine you want to order some food in a restaurant. You only have to talk to the waiter. You don't have to know how s/he processes your order, how the their payment system works or how and by whom the food is prepared. And further you don't have to adapt if anything in this chain changes - the one who has to adapt is the waiter. A framework is a lot like that.

Rainrider 03-29-18 01:50 PM

Please keep in mind that creating a new oUF layout from scratch could be a lot of work, especially if you lack understanding of Lua and how addons in WoW work. It is easier to find a layout you like and try to alter its code to suit your needs.

However, if you want to learn, here are some links that might prove helpful:
The Lua 5.1 Manual
Getting started with writing addons

Also install addons that catch and display Lua errors like !BugGrabber and BugSack.

GreyFox777 03-29-18 02:16 PM

i saw them all, but none of them has Texture frames. My idea was to use Texture for the Units.

Like player are black only texture, target, focus etc depends on unitclassification, if rare then silver texture, if elite then gold.


I did my whole interface with WA + many custom code. But very hard to understand how to implement this on native addon.

The reason i want to start doing this, is huge lags causing because of WA.:(


For some reason, i always get stuttering, if there are many ads spawning.

Rainrider 03-29-18 03:19 PM

You have to invest the time in it, because nobody will do it for you. If you don't like that or don't have the time, then just use a layout of your liking. There is no other way around it :)

Tim 03-29-18 04:24 PM

Quote:

Originally Posted by GreyFox777 (Post 327386)
The reason i want to start doing this, is huge lags causing because of WA.:(

Generally the reason why an addon will cause fps/lag is due to poor/improper coding.

As for oUF.. It's a framework that you have to build off of. If you want your very own layout you're going to have to do exactly what Rainrider suggested and put time into learning how to either build your own from scratch or figure out how things are done by a layout created by someone else.

GreyFox777 03-29-18 04:59 PM

Quote:

Originally Posted by Tim (Post 327388)
Generally the reason why an addon will cause fps/lag is due to poor/improper coding.

As for oUF.. It's a framework that you have to build off of. If you want your very own layout you're going to have to do exactly what Rainrider suggested and put time into learning how to either build your own from scratch or figure out how things are done by a layout created by someone else.

The reason it laggs, is because wow is poorly made. Everything running singlethreaded. I have tons on addons and WA auras. That all laggs like hell, just because wow cannot handle it. Hopefully DX12 will do something.

Tim 03-29-18 05:05 PM

Don't be so quick to blame WoW itself for the reasoning you lag or run into fps issues. Just because people release addons or create WA strings doesn't mean they're flawless. I bet if you did a trial and error of loading WoW with 1 addon enabled each time you would find the culprit causing the issues. WA could very well be the offending addon due to once again, improper coding within WA strings.

GreyFox777 03-29-18 05:54 PM

Quote:

Originally Posted by Tim (Post 327391)
Don't be so quick to blame WoW itself for the reasoning you lag or run into fps issues. Just because people release addons or create WA strings doesn't mean they're flawless. I bet if you did a trial and error of loading WoW with 1 addon enabled each time you would find the culprit causing the issues. WA could very well be the offending addon due to once again, improper coding within WA strings.

Well... most triggers i have from pros. All other auras are default. But i tried to disable everything that contains custom code. Same stuttering while combat.

I just not understand how can it be laggy, if there are ZERO errors...

JDoubleU00 03-29-18 09:56 PM

Quote:

Originally Posted by GreyFox777 (Post 327392)
Well... most triggers i have from pros. All other auras are default. But i tried to disable everything that contains custom code. Same stuttering while combat.

I just not understand how can it be laggy, if there are ZERO errors...

Just because there are no errors, does not mean the code is optimally written. Code can cause lag without causing an error.

GreyFox777 03-29-18 11:08 PM

Quote:

Originally Posted by JDoubleU00 (Post 327397)
Just because there are no errors, does not mean the code is optimally written. Code can cause lag without causing an error.

Okay, that can be. But how you explain then, my custom code i have it disabled completely. I don't think default wa auras will be laggy as hell.

runamonk 03-30-18 01:19 AM

If everyone got lag and stuttering there would be a lot more complaints on the forums and the game wouldn't be nearly as popular.

I would disable ALL addons and test from there. Some other info would help, what are you machine specs? What settings are you running at? Have you tried resetting your video settings in game to stock?

GreyFox777 03-30-18 05:44 AM

I have tried to disable every aura, one by one, but still lags. Tried to disable the addons one by one. Doesen't help.

So i think it's WA (but what auras?) I have around 700 auras. In raid are ~80 enabled.



My specs are just fine:

i7 6700k @4.60
GTX 1080
16 GB RAM
SSD

runamonk 03-30-18 05:49 AM

No I mean literally all your addons not all your auras. I assume you're using more than a single addon. So press esc, click on addons and uncheck all of them.

and dude 700 auras? wtf.

GreyFox777 03-30-18 10:26 AM

Quote:

Originally Posted by runamonk (Post 327402)
No I mean literally all your addons not all your auras. I assume you're using more than a single addon. So press esc, click on addons and uncheck all of them.

and dude 700 auras? wtf.

I have my whole interface build with WA. It pretty good, it has everything i need :)

But 700 are not at the same time enabled. Without any addons it work flawlessly. But disabling everything isn't a solution.

runamonk 03-30-18 10:33 AM

My guess is doing your whole interface with WA is going to be the issue for sure. Wow man. I don't think that was the original intention of WA hehe. That seems a bit excessive. Well that was easy.

Now the hard part is going to be recreating what you need from your old interface to another addon either oUF as the framework and create your own layout. I would start by grabbing one layout that uses the oUF framework and start messing with it and learning how it works. That's what I did with mine. I started with oUF P3lim and oUF Lumen and I've basically created a whole new layout from using those as starter baseline.

Just get one element/unit working and go from there.

Out of curiosity could you post a screen shot of your UI?

GreyFox777 03-30-18 11:15 AM

Quote:

Originally Posted by runamonk (Post 327405)
My guess is doing your whole interface with WA is going to be the issue for sure. Wow man. I don't think that was the original intention of WA hehe. That seems a bit excessive. Well that was easy.

Now the hard part is going to be recreating what you need from your old interface to another addon either oUF as the framework and create your own layout. I would start by grabbing one layout that uses the oUF framework and start messing with it and learning how it works. That's what I did with mine. I started with oUF P3lim and oUF Lumen and I've basically created a whole new layout from using those as starter baseline.

Just get one element/unit working and go from there.

Out of curiosity could you post a screen shot of your UI?



I tried some weeks to create one frame, but i just not understand how to do it with or without oUF :(

Here are screenshots:

https://imgur.com/a/AvT2j
https://imgur.com/a/3uiTo
https://imgur.com/a/vnaGG
https://imgur.com/a/xdd6t
https://imgur.com/a/GiSGW
https://imgur.com/a/lU8cs
https://imgur.com/a/47pKe

It has icons, locale flags, raid/group targeting count. HP bar changes the color, if there dispellable debuff on a player, like poison (green) disease (brown) etc... All frames are clickable.

In group shows role icon.

Party frames are set to alpha 0.6 if too far away. Else set on 1

runamonk 03-31-18 01:14 AM

Love the interface. You could reproduce most of that with just about any units addon though; without having to make your own layout in oUF.

Although if you like doing a bit of coding it's more fun with oUF and it will perform better in WoW that having to do it all in wa.

Have you done any coding at all in any language? If not it's going to make it a bit harder for you to do a layout with oUF.

Here is a basic screenshot of what I've done with my layout for oUF. All the bottom panels are frames created with basic lua with a basic texture applied to them.

My minimal layout.

GreyFox777 03-31-18 05:46 AM

unfortenately, i have never messed with any language.

JDoubleU00 03-31-18 11:47 AM

Troubleshooting
 
This is a good list of steps for troubleshooting addons. Give it a look and see if anything can help you locate the source of your lag (unless it is 700 Weak Auras). Your whole UI is made from Weak Auras? <mind blown>

GreyFox777 03-31-18 03:14 PM

Quote:

Originally Posted by JDoubleU00 (Post 327421)
This is a good list of steps for troubleshooting addons. Give it a look and see if anything can help you locate the source of your lag (unless it is 700 Weak Auras). Your whole UI is made from Weak Auras? <mind blown>

Only unit frames, and some other stuff, like rogue combo points. And there is not 700 auras enabled at same time :)

I think i know what can be cause laggs. Many auras has the same code on init, like:

local char
local string_byte = string.byte
local sub = sub

local function chsize(char)
if not char then
return 0
elseif char > 240 then
return 4
elseif char > 225 then
return 3
elseif char > 192 then
return 2
else
return 1
end
end

function aura_env.custom_utf8sub(str, startChar, numChars)
if not str then return "" end
local startIndex = 1
while startChar > 1 do
local char = string_byte(str, startIndex)
startIndex = startIndex + chsize(char)
startChar = startChar - 1
end

local currentIndex = startIndex

while numChars > 0 and currentIndex <= #str do
local char = string_byte(str, currentIndex)
currentIndex = currentIndex + chsize(char)
numChars = numChars -1
end
return str:sub(startIndex, currentIndex - 1)
end

function aura_env.utf8len(str)
if not str then return 0 end
local len = 0
local currIndex = 1
while currIndex <= #str do
local char = string_byte(str, currIndex)
currIndex = currIndex + chsize(char)
len = len + 1
end
return len
end

But normally it should be loaded only one time. Or for example if i have the same code for color box, that loads twice, like player and target. That can be the issue, but im not at 100% sure.

Seerah 03-31-18 04:52 PM

You are using WA for **way** more than it was originally intended. You are putting tons of strain on WA, and your code is inefficient because you are working within the constraints of WA. This is why you are having performance problems.

You should find addons that do what you want (or write your own), rather than abusing WA. I understand that is the purpose for your thread here.

If you need help with oUF, that is what this forum section is for. If you need help with learning how to write addons, there is the IRC channel and these forum sections. Be sure to check out the stickied threads.

But let's get you away from WA for everything but what it's original purpose is. ;)

neverg 04-01-18 06:42 PM

I don't want to beat the dead horse but ye, I think you answered what your problem is when you use WA for way more than it was intended.

This kinda reminds me of this XKCD: https://xkcd.com/1172/

:D

GreyFox777 04-04-18 12:46 PM

Is there any Discord channel for UI creating?

Ammako 04-04-18 01:09 PM

There is an irc mirror afaik but most people just hang out at irc.freenode.net#wowuidev

GreyFox777 04-04-18 01:27 PM

Quote:

Originally Posted by Ammako (Post 327449)
There is an irc mirror afaik but most people just hang out at irc.freenode.net#wowuidev

irc.freenode.net: Terminated

i don't know why it's not working

Ammako 04-04-18 01:36 PM

Works for me using HexChat. What client are you using?

GreyFox777 04-04-18 01:36 PM

Can some one show me please, how to anchor a texture to clickable panel (like making texture clickable)?

GreyFox777 04-04-18 02:31 PM

Quote:

Originally Posted by Ammako (Post 327451)
Works for me using HexChat. What client are you using?

I get it to work, but they are not helpfull... they just redirecting me to ouF forum.



Im disappointed...:(

Tim 04-04-18 08:15 PM

The reason they're not being very helpful in the manner you seek is bc that chat is not there for you to just ask for people to code this and that for you. They've directed you to oUF in hopes you would teach yourself how to create your own oUF layout and go from there.

runamonk 04-05-18 04:12 AM

Learn some basic lua and how to create your own addon first. It will help you understand what to do.

neverg 04-05-18 06:09 AM

What has been said and get to look at someone else's code. Pick a simple addon and see how things are done.

This should help you out:

https://us.battle.net/forums/en/wow/topic/20742244205

http://wowwiki.wikia.com/wiki/AddOn_...l/Introduction

http://wowprogramming.com/

https://wow.gamepedia.com/World_of_Warcraft_API

Then take a look at some addons, you can explore what Roth in his addons for instance: https://github.com/zorker/rothui/tree/master/wow7.0

Ammako 04-05-18 09:28 AM

If you've never done any lua nor made any addons yourself before, going straight into making your own oUF layout may be a bit over-ambitious. If you aren't able to understand the tutorial layout Rainrider linked you, you're probably better off starting by making more basic addons until you get a better grasp for it.

If you don't want to learn, then you'll probably be better served by using someone else's layout that they uploaded on here or on Curse (or any other UI addons; it doesn't have to be oUF.) A custom UI doesn't have to be self-made, if you're just wanting to replace all your WeakAuras.

GreyFox777 04-05-18 12:23 PM

Or i just rent some coder :p

jeffy162 04-05-18 05:30 PM

Quote:

Originally Posted by GreyFox777 (Post 327463)
Or i just rent some coder :p

I hope you've got some really really deep pockets, 'cause coders don't come cheap (IF they charge the going rate for coding, at least).

Rainrider 04-07-18 04:34 AM

If you hire someone, keep in mind that with the next expansion stuff might change and you might have to look for somebody to fix your layout again.

GreyFox777 04-11-18 01:20 PM

Hey guys, why my health color are not refreshing automatically if entering AFK?

local function UpdateHealthColor(health, unit, cur, max)
health:RegisterEvent('PLAYER_FLAGS_CHANGED')
local r, g, b, t
-- local afk = UnitIsAFK(unit)

if(health.disconnected and health.colorDisconnected or UnitIsDeadOrGhost(unit)) then
health:SetValue(max)
t = colors.disconnected
elseif(health.colorTapping and not UnitPlayerControlled(unit) and UnitIsTapDenied(unit)) then
t = colors.tapped

elseif UnitIsAFK(unit) then
r, g, b = 1, 0, 0
health:SetScript('OnEvent', UpdateHealthColor)

elseif(health.colorSmooth) then
r, g, b = health.__owner.ColorGradient(cur, max, unpack(colors.smooth))
else
t = colors.health
end

if(t) then
r, g, b = t[1], t[2], t[3]
end

if(b) then
health:SetStatusBarColor(r, g, b)
end
end

Kkthnx 04-11-18 02:16 PM

Quote:

Originally Posted by GreyFox777 (Post 327491)
Hey guys, why my health color are not refreshing automatically if entering AFK?

local function UpdateHealthColor(health, unit, cur, max)
health:RegisterEvent('PLAYER_FLAGS_CHANGED')
local r, g, b, t
-- local afk = UnitIsAFK(unit)

if(health.disconnected and health.colorDisconnected or UnitIsDeadOrGhost(unit)) then
health:SetValue(max)
t = colors.disconnected
elseif(health.colorTapping and not UnitPlayerControlled(unit) and UnitIsTapDenied(unit)) then
t = colors.tapped

elseif UnitIsAFK(unit) then
r, g, b = 1, 0, 0
health:SetScript('OnEvent', UpdateHealthColor)

elseif(health.colorSmooth) then
r, g, b = health.__owner.ColorGradient(cur, max, unpack(colors.smooth))
else
t = colors.health
end

if(t) then
r, g, b = t[1], t[2], t[3]
end

if(b) then
health:SetStatusBarColor(r, g, b)
end
end

First off a really good practice is to keep your code clean and readable. Second, are you using frequentUpdates?

Here is your code in ghostbin
https://ghostbin.com/paste/ukhcu

Maybe you need to run Health.PostUpdate = UpdateHealthColor? I don't member really just assuming atm. Going to look into it when I get home though for you.


All times are GMT -6. The time now is 05:30 PM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI