Help with some Font settings
EDIT:
Disreguard this post.. Was able to work most of the issues out with the "search" function. for those that might want to see the code im currently using. This code was posted by Phanx and editied to my likeing. Code:
local shorts = { Coke |
Öhm. :)
What is C["unitframes"].fontStyle and where does it come from? |
I've been able to do the following for the player but how would I do this for Arean and boss frames?
Code:
PlayerFrameHealthBarText:SetFont(C["media"].font, C["unitframes"].player.fontSize,"THINOUTLINE"); |
I vaguely remember posting that... not sure if it was in my original version, or from your edits, but here's a slightly more efficient version:
Code:
local shorts = { Quote:
Code:
local font, _, flags = fontstring:GetFont() Code:
local font, _, flags = TextStatusBarText:GetFont() |
Quote:
I want to be able to adjust each frames font size individually per what the user wants. I think ill just stick with doing it the long way per frame. Thanks Coke PS this is what im talking about the long way. My current unitframes addon: Code:
local B, C, DB = unpack(select(2, ...)) -- Import: B - function; C - config; DB - Database |
One more question concerning font.
How can I make the following font classcolor to match the person:
Thanks for any help with this. |
The simplest solution is probably going to be to hook the function that sets the text:
Code:
hooksecurefunc("UnitFrame_Update", function(self) If you wanted to color pets by their owner's class, the simplest solution would probably be to look at the pet's creature type and just make an assumption -- eg. beast = hunter, demon = warlock, etc. |
Quote:
Thank you for this it works great. Im confused on trying to do the "reaction" part. I've tried: Code:
self.name:SetTextColor(FACTION_BAR_COLORS[reaction].r, FACTION_BAR_COLORS[reaction].g, FACTION_BAR_COLORS[reaction].b) Even tried: Code:
FACTION_BAR_COLORS = { and thanks again for all your help. Coke P.S. Error I keep getting: Code:
Message: ...ace\AddOns\BasicUI\Modules\Unitframes\Unitframes.lua:199: attempt to index field '?' (a nil value) |
Post your entire code if you want help with it. Your snippet refers to a variable that may or may not be defined correctly or incorrectly or at all somewhere else, but you didn't post that part, so it really tells me nothing.
|
Entire Code
Sorry about that.
Unitframes.lua: Lua Code:
Defaults.lua: Lua Code:
Engine.lua: Lua Code:
Config.lua: Lua Code:
Is there any other code that you might need? Coke |
UnitReaction can return nil. Here's a version based on the coloring in my oUF layout that will do class colors for players, or gray for tapped units, or reaction colors for other units, with a fallback in case of invalid class/reaction data:
Lua Code:
|
Quote:
What I was able to use was the name coloring from nTooltip with some modifications. The only down fall to this coding is that the player's name is not class color matched, but all targets become classcolor, grey for dead or tapped, and normal color for npc's. Here is the code: Lua Code:
Thanks for the help on this. One last quest for you Phanx The numeric code seems to show 0 ("Zero") when a target is dead is there a way to remove these when the target is dead? Something like: Lua Code:
Again Thank You for all your help with the coding. Coke |
Your code is creating a new copy of a function every time any unit frame is updated, which is really bad. It's also hardcoding the unit to "target" which is probably not what you want, unless you only want your code to work on the target frame, in which case it's still the wrong way to go about it; if you want to limit it to the target frame, you need to check the actual unit and return out if it's not "target", as the current method will color every unit frame according to the properties of your current target.
The code I posted has nothing to do with oUF or tags, but after looking at it again, I see I forgot to define the "unit" variable. You should really have some kind of error display turned on. It will make things so much easier for you (and anyone else who tries to help you) while you're working with code. If you already have one (I recommend BugSack) then you should really post the error message when you report that something "doesn't work". Anyway, here is a fixed version: Code:
hooksecurefunc("UnitFrame_Update", function(self) Code:
hooksecurefunc("TextStatusBar_UpdateTextStringWithValues", function(statusBar, fontString, value, valueMin, valueMax) |
Quote:
Also installed bugsack as suggested. Right now no errors. Thanks again for all your help. Coke |
Pet Name Color to White
I've been trying all morning to get the pet eg beast, demon, and elemental to have there names white.
At first I tried UnitIsPet(unit) but it seems that the wow api does not have that in it. Then I went searching and found UnitCreatureType(unit) then I tried: Lua Code:
But the above code turned every name color white. So I did more searching and found a post that had a function created for UnitIsPet so I copy/pasted the: Lua Code:
Lua Code:
and this changes the Pet name color to White but bugsack gives me this error: Code:
5x BasicUI-5.4.4\Modules\Unitframes\Unitframes.lua:193: bad argument #1 to "strsub" (string expected, got nil) Hopefully this is enough info for you. If not below is the complete Unitframes.lua just in case. Coke Unitframes.lua: Lua Code:
|
UnitGUID can return nil so you need to account for that:
Code:
local function UnitIsPet(unit) Code:
local function UnitIsPet(unit) Code:
if UnitCreatureType("beast") or UnitCreatureType("demon") or UnitCreatureType("elemental") then |
Quote:
I have added: Code:
local function UnitIsPet(unit) Thanks again Coke |
Based on what you are using it for you don't really need a separate UnitIsPet function, also the class name used to index CUSTOM_CLASS_COLORS and RAID_CLASS_COLORS should be in all caps:
Code:
hooksecurefunc("UnitFrame_Update", function(self) |
Quote:
Coke |
Statusbar Text
the following code was supplied by Phanx but I was wondering if there is a way to make it do the following.
Full Health = 345K Full Mana = 160K Not Full Health = 160K/345K Not Full Mana = 80K/160K Code Supplied by Phanx: Lua Code:
Thank in advance for any help. Coke |
Add the part highlighted in teal:
Code:
else |
Quote:
Last question then I think I'm done with font's. My tooltip addon I use is based primarily off of nTooltip and for his pets he uses a color like: Code:
r = 157/255 How would I get the highlighted yellow code to be this color: Code:
hooksecurefunc("UnitFrame_Update", function(self) I know I couldjust change the tooltip font to: Code:
r = 1 Thanks again for all your guys help with my font questions. Coke |
Code:
local PET_COLOR = { r = 157/255, g = 197/255, b = 255/255 } |
Quote:
Now for a personal question do you do programming for a living or is this just a hobby like me? Either way you are great at it and thank you for all you do for us less then program savvy people. Coke |
Yet another font string question...
Is there a way to hide a party members realm, I've search the forums and only found this function for the chat not for the unit frames. I would really like to change "-REALNAME" to (*) if possible. Coke |
Lua Code:
What is happening here is that strsplit will pass everything before and after the defined delimiter to as many variables as we allow it to. NAME-REALM keys are always delimited by a "-", and I am almost positive that no REALM keys contain a "-", thus we can safely split the name from the realm in this way. If unitRealm becomes defined, we print unitName with "(*)" concatenated; else we print just the name. This should be quite adaptable, let me know if you need any further assistance. |
Quote:
Coke |
I mean....it doesn't necessarily pertain to anything in particular, it is just applied API. Technically, you could pass any name token through it as long as there aren't any "-" outside of the delimitation. If there is no realm name, you just get a name; if there is a realm name, you get the "(*)".
The one issue I see is the inconsistency in how name-realm tokens are passed through certain functions and events at the moment. "(*)" has typically been used for units on other realms, but some events -- CLEU for example -- are passing names with realms attached regardless of if they are on your realm or not. Tl;dr: You may get "(*)" for units that are on your realm as well, giving the false impression that they are cross-realm. Of course, you could cache your realm and match it against what got split and go from there. |
Quote:
Lua Code:
Should set the name of my party members to just there name? |
That looks functional to me, log into WoW and try it =~].
|
when I log in I get this error with all addons enabled:
Code:
3x BasicUI-5.4.7\Modules\Unitframes.lua:50: bad argument #2 to "strsplit" (string expected, got table) Code:
Message: Interface\AddOns\BasicUI\Modules\Unitframes.lua:50: bad argument #2 to 'strsplit' (string expected, got table) |
It's a table value. The fontstring widget itself.
Use: _G[partyFrame].name:GetText() |
Lua Code:
needs to be Lua Code:
|
2 Attachment(s)
Quote:
Below I have attached my Unitframes.lua, Phanx helped me with a code to change my Unit Text color and I think it is conflicting with this script. I get this error: Code:
Message: Interface\AddOns\BasicUI\Modules\Unitframes.lua:52: bad argument #2 to 'strsplit' (string expected, got table) Coke |
I suspect the issue is that you are iterating over every possible party unitframe, even when no unit has been assigned to it. If there is no unit, there is no name token to pass into strsplit.
What I suspect you need to do is listen to GROUP_ROSTER_UPDATE and iterate over the party frames that actually have assigned units. That is the only thing I can think of looking over your code. Hopefully someone else will take a look and offer some insight. |
It would be simpler to just ignore the original text and get the name again:
Code:
_G[partyFrame].name:SetText(GetUnitName("party"..i)) Code:
_G[partyFrame].name:SetText(GetUnitName("party"..i, true)) (a) you did not, in fact, make the change Clamsoda suggested, as your originalName variable is still referring to the fontstring, rather than its text contents, or (b) the unit in question doesn't exist. Using GetUnitName instead of manipulating the existing text will avoid this problem, but you should really not bother doing anything with frames that aren't shown. I see you're checking GetNumGroupMembers() >= 1 on each loop iteration; this is wasteful and won't achieve the desired result anyway, because having 1 party member doesn't mean you have 4 party members. Instead, just check that the frame being processed is shown: Code:
for i = 1, MAX_PARTY_MEMBERS do Code:
hooksecurefunc("UnitFrame_Update", function(self, isParty) |
All times are GMT -6. The time now is 05:14 AM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI