- Fix for NPC guild text
starlon [08-05-08 - 07:41]
- Fix for NPC guild text
- Percent sign adjusted
- Fix for raid panel problem and other possible issues. Note that the Targeting module won't work inside the raid panel.
diff --git a/Modules/Targeting.lua b/Modules/Targeting.lua
index 705a540..a6e400c 100644
--- a/Modules/Targeting.lua
+++ b/Modules/Targeting.lua
@@ -20,7 +20,7 @@ function mod:SetUnit()
if UnitInRaid("player") then
local txt = ''
for i=1, GetNumRaidMembers() do
- if UnitGUID("mouseover") == UnitGUID("raid" .. i .. "target") then
+ if UnitExists("mouseover") and UnitGUID("mouseover") == UnitGUID("raid" .. i .. "target") then
local c = RAID_CLASS_COLORS[select(2, UnitClass("raid" .. i))]
local name = UnitName("raid" .. i)
txt = txt .. ("|cFF%02x%02x%02x%s|r "):format(c.r*255, c.g*255, c.b*255, name)
diff --git a/Modules/Text.lua b/Modules/Text.lua
index f011004..0102ba0 100644
--- a/Modules/Text.lua
+++ b/Modules/Text.lua
@@ -52,6 +52,7 @@ local linesToAddRightG = {}
local linesToAddRightB = {}
local unitLocation
local unitName
+local unitGuild
local NUM_LINES
-- Thanks to ckknight for this
@@ -282,7 +283,8 @@ local lines = setmetatable({
name = "Guild",
left = function() return "Guild:" end,
right = function()
- return GetGuildInfo("mouseover")
+ local guild = GetGuildInfo("mouseover")
+ if guild then return guild else return unitGuild end
end,
updating = false
},
@@ -391,7 +393,7 @@ local lines = setmetatable({
if maxHealth == 100 then
value = health .. "%"
elseif maxHealth ~= 0 then
- value = format("%s/%s (%%%d)", short(health), short(maxHealth), health/maxHealth*100)
+ value = format("%s/%s (%d%%)", short(health), short(maxHealth), health/maxHealth*100)
end
return value
end,
@@ -411,7 +413,7 @@ local lines = setmetatable({
if maxMana == 100 then
value = mana
elseif maxMana ~= 0 then
- value = format("%s/%s (%%%d)", short(mana), short(maxMana), mana/maxMana*100)
+ value = format("%s/%s (%d%%)", short(mana), short(maxMana), mana/maxMana*100)
end
return value
end,
@@ -595,6 +597,7 @@ local getName = function()
end
-- Taken from LibDogTag-Unit-3.0
+local LEVEL_start = "^" .. (type(LEVEL) == "string" and LEVEL or "Level")
local getLocation = function()
if UnitIsVisible("mouseover") or not UnitIsConnected("mouseover") then
return nil
@@ -605,7 +608,7 @@ local getLocation = function()
if not left_2 or not left_3 then
return nil
end
- local hasGuild = not left_2:find("^" .. LEVEL)
+ local hasGuild = not left_2:find(LEVEL_start)
local factionText = not hasGuild and left_3 or self.leftLines[4]:GetText()
if factionText == PVP then
factionText = nil
@@ -620,9 +623,16 @@ local getLocation = function()
end
end
+local getGuild = function()
+ local left_2 = self.leftLines[2]:GetText()
+ if left_2:find(LEVEL_start) then return nil end
+ return "<" .. left_2 .. ">"
+end
+
function mod:SetUnit()
unitName = getName()
unitLocation = getLocation()
+ unitGuild = getGuild()
-- Taken from CowTip
local lastLine = 2