View Full Version : guild and creature type?
Roath
07-07-2006, 10:04 AM
I was wondering since we have $nam, $cla etc. is it possible to have one for guild and one for creature type? (eg. humanoid, undead, beast, critter etc.)
Zhaligkira
07-07-2006, 11:36 AM
I know that creature type already shows up, but it would be pretty neat to have the guild name show as well.
Roath
07-07-2006, 11:52 AM
how do i make creature type show up? im making custom layout and would like to know how :S
Firehawk
07-08-2006, 06:05 AM
yeah, Guild name would be awesome.
anyone got an idea?
Roath
07-08-2006, 06:20 AM
ok i found out that $cla displays the creature type if its a hostile or neutral target, but not if its friendly... how can i change it so that it only shows creature type, and not class?
another thing... how can i add a new text to the unitframe, simply adding one with the same stuff as eg. level doesn't give any errors but the text just doesn't show up
Firehawk
07-11-2006, 04:59 PM
/bump
Guild names anyone? 8[
Belkelel
07-12-2006, 07:30 AM
ok, I tried a bit and found a solution for the guildname:
open the Lib.lua and search for the Nurfed_UnitFrames:UpdateName() function. Here my modified code (changes are red):
function Nurfed_UnitFrames:UpdateName()
local text = getglobal(this:GetName().."name");
local icon = getglobal(this:GetName().."classicon");
local name = UnitName(this.unit);
local class, eclass = UnitClass(this.unit);
local info = Nurfed_Units.class[eclass];
local guild = "";
local creature = UnitCreatureType(this.unit);
local display = text.format;
if (text and info and display) then
local level = UnitLevel(this.unit);
local binding = "";
if (UnitIsPlayer(this.unit)) then
name = info.color..name.."|r";
guild = GetGuildInfo(this.unit);
if(not guild) then
guild = "";
end
elseif (string.find(this.unit, "target", 1, true)) then
local color = unitlib:GetReaction(this.unit);
color = string.format("|cff%02x%02x%02x", (color.r*255), (color.g*255), (color.b*255));
name = color..name.."|r";
end
local id, found = gsub(this.unit, "party([1-4])", "%1");
if (found == 1) then
binding = GetBindingText(GetBindingKey("TARGETPARTYMEMBER"..id), "KEY_");
binding = utility:FormatBinding(binding);
end
display = string.gsub(display, "$nam", name);
display = string.gsub(display, "$lev", level);
display = string.gsub(display, "$cla", class);
display = string.gsub(display, "$key", binding);
display = string.gsub(display, "$gld", guild);
display = string.gsub(display, "$cre", creature);
text:SetText(display);
end
if (icon and info) then
icon:SetTexCoord(info.right, info.left, info.top, info.bottom);
end
end
If you want to use this near the Level also add this in the function Nurfed_UnitFrames:UpdateLevel()
function Nurfed_UnitFrames:UpdateLevel()
local text = getglobal(this:GetName().."level");
if (text) then
local display = text.format;
local class, eclass = UnitClass(this.unit);
local level = UnitLevel(this.unit);
local color = GetDifficultyColor(level);
local guild = "";
local creature = UnitCreatureType(this.unit);
if (UnitIsPlusMob(this.unit)) then
level = level.."+";
elseif (level == 0) then
level = "";
elseif (level < 0) then
level = "??";
end
if (unitlib.classification[UnitClassification(this.unit)]) then
class = unitlib.classification[UnitClassification(this.unit)];
if (class == BOSS) then
level = "";
color = { r = 1, g = 0, b = 0 };
elseif (UnitCreatureType(this.unit)) then
class = class.." "..UnitCreatureType(this.unit);
end
else
if (UnitIsPlayer(this.unit)) then
local color = unitlib.class[eclass].color;
class = color..class.."|r";
guild = GetGuildInfo(this.unit);
if(not guild) then
guild = "";
end
elseif (UnitCreatureType(this.unit) == "Humanoid" and UnitIsFriend("player", this.unit)) then
class = "NPC";
elseif (UnitCreatureType(this.unit)) then
class = UnitCreatureType(this.unit);
end
end
if (UnitIsCorpse(this.unit)) then
class = class.." "..CORPSE;
end
if (not class) then
class = "";
end
if (not level) then
class = "";
end
display = string.gsub(display, "$lev", level);
display = string.gsub(display, "$cla", class);
display = string.gsub(display, "$gld", guild);
display = string.gsub(display, "$cre", creature);
text:SetText(display);
text:SetTextColor(color.r, color.g, color.b);
end
end
These chances should provide a new Text Format Var $gld. Will work for all Players (for NPCs etc it will give you just a space).
edit: Added in GREEN the code for the new Text Format Var $cre providing the Creature-Type.
Here a small example ($gld used next to $nam in the targetframe)
http://storage.perfect-pixel.de/guildname.jpg
greetings
Belkelel
07-12-2006, 11:29 AM
another thing... how can i add a new text to the unitframe, simply adding one with the same stuff as eg. level doesn't give any errors but the text just doesn't show up
Do you mean a simple static text or a new variable text?
Mind-X
07-13-2006, 05:48 AM
i would like to use this code, but i want to guildname appears after target's name only if it isnt ur own guild. Is there any way to make guildies like NPCs so they dont show guildname?
akeela
07-13-2006, 08:12 AM
it works fine for players in a guild but when i try to target someone without a guild i get a error and the target frame displays the name of my last target
"Interface\Addons\Nurfed_UnitFrames\Lib.lua:427: bad argument #3 to `gsub' (string or function expected)"
i only did the changes in function Nurfed_UnitFrames:UpdateName()
hope this makes sence ;D
Belkelel
07-13-2006, 11:40 AM
it works fine for players in a guild but when i try to target someone without a guild i get a error and the target frame displays the name of my last target
"Interface\Addons\Nurfed_UnitFrames\Lib.lua:427: bad argument #3 to `gsub' (string or function expected)"
i only did the changes in function Nurfed_UnitFrames:UpdateName()
hope this makes sence ;D
yeah I see, I got sometimes the same error, but cant imagine where it came from. I'll try to build a handler for this.
Edit:
Ok I added a handler to the code above to fix the issue with guildless Players (gsub does not like empty strings...)
@Mind-X
if you only want to show the name of other guilds you can extend the handler:
change
if(not guild) then
guild = "";
end
to
if(not guild or guild == GetGuildInfo("player")) then
guild = "";
end
greetings
Bel
akeela
07-13-2006, 07:09 PM
thanks a million ;D working like a charm now
Ralrra
07-17-2006, 12:02 AM
How would I go about creating a new string for just the guild name so I could anchor it elsewhere in the frame? Using your code I can add the $gld variable to the name string, but if I add a new Child to the unit frame the text doesn't show up.
How would I go about creating a new string for just the guild name so I could anchor it elsewhere in the frame? Using your code I can add the $gld variable to the name string, but if I add a new Child to the unit frame the text doesn't show up.
Having the same problem too. I think it may have something to do with \Nurfed_Utility\Nurfed_Frames.lua, concerning SetPoint. Either way, for some reason, you can't add any other new Child FontString, even if it's an exact duplicate of something like the $parentlevel or $parentname. lol, I wish I wasn't so mediocre at LUA programming; maybe I'd be able to figure this one out :[
ToastOMator
07-20-2006, 04:33 AM
I discovered a bug with the creature type addition.
I used your code for the UpdateName method. The guild display works fine. But i got an error while beeing in a battleground(Warsong) and targeting a player who was not near me via the raid frame.
The error was in the line:
display = string.gsub(display, "$cre", creature);
It said something about something beeing nil. I think the creature has been nil. Most likely you have to check the creture vaiable if it is nil like you did with the guild one:
if(not creature) then
creature= "";
end
Roath
07-20-2006, 09:42 AM
I discovered a bug with the creature type addition.
I used your code for the UpdateName method. The guild display works fine. But i got an error while beeing in a battleground(Warsong) and targeting a player who was not near me via the raid frame.
The error was in the line:
display = string.gsub(display, "$cre", creature);
It said something about something beeing nil. I think the creature has been nil. Most likely you have to check the creture vaiable if it is nil like you did with the guild one:
if(not creature) then
creature= "";
end
where do i place that?
Belkelel
07-20-2006, 11:21 AM
@roath
before the
display = string.gsub(display, "$cre", creature);
@ToastOMator
ok your are right, I forgot the "range"-problem of variables ;)
ErMeR
07-21-2006, 07:11 PM
When I try to add the gld var to it's own child to modify it doesn't show up, is there some event I need to register or something I am missing other than just adding a normal text child?
Jaded
08-04-2006, 12:54 AM
When I try to add the gld var to it's own child to modify it doesn't show up, is there some event I need to register or something I am missing other than just adding a normal text child?
Id also like to know how to do this, so I can add $cre to its own location instead of added onto $lev/$nam.
Any thoughts?
Riano
09-21-2006, 02:52 AM
@Belkelel
Can u upload the lib.lua you use to show the guildnames just like your picture:confused:
Belkelel
09-21-2006, 12:06 PM
I'm sorry, I dont have it anymore.
Powered by vBulletin® Version 4.1.9 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.