Quantcast

Use LuaTexts Short() and HP, MaxHP, Power, MaxPower.

Scott Sibley [07-24-11 - 10:50]
Use LuaTexts Short() and HP, MaxHP, Power, MaxPower.
Bug fix to error catching.
Filename
Modules/UnitTooltip/UnitTooltip.lua
StarTip.lua
diff --git a/Modules/UnitTooltip/UnitTooltip.lua b/Modules/UnitTooltip/UnitTooltip.lua
index 8fababe..51dc61a 100644
--- a/Modules/UnitTooltip/UnitTooltip.lua
+++ b/Modules/UnitTooltip/UnitTooltip.lua
@@ -249,13 +249,13 @@ return L["Alive"]
         left = 'return L["Health:"]',
         right = [[
 if not UnitExists(unit) then self:Stop(); return self.lastHealth end
-local health, maxHealth = UnitHealth(unit), UnitHealthMax(unit)
+local health, maxHealth = HP(unit), MaxHP(unit)
 local r, g, b = HPColor(health, maxHealth)
 local value = L["Unknown"]
 if maxHealth == 100 then
     value = Colorize(health .. "%", r, g, b)
 elseif maxHealth ~= 0 then
-    value = Colorize(format("%s/%s (%d%%)", short(health), short(maxHealth), health/maxHealth*100), r, g, b)
+    value = Colorize(format("%s/%s (%d%%)", Short(health, true), Short(maxHealth, true), health/maxHealth*100), r, g, b)
 end
 self.lastHealth = value
 return value
@@ -271,14 +271,14 @@ return PowerName(unit)
 ]],
         right = [[
 if not UnitExists(unit) then self:Stop(); return self.lastMana end
-local mana = UnitMana(unit)
-local maxMana = UnitManaMax(unit)
+local mana = Power(unit)
+local maxMana = MaxPower(unit)
 local r, g, b = PowerColor(nil, unit)
 local value = L["Unknown"]
 if maxMana == 100 then
     value = Colorize(tostring(mana), r, g, b)
 elseif maxMana ~= 0 then
-    value = Colorize(format("%s/%s (%d%%)", short(mana), short(maxMana), mana/maxMana*100), r, g, b)
+    value = Colorize(format("%s/%s (%d%%)", Short(mana, true), Short(maxMana, true), mana/maxMana*100), r, g, b)
 end
 self.lastMana = value
 return value
@@ -962,7 +962,7 @@ function mod:CreateLines()
             v.color = v.colorR
             v.maxWidth = v.maxWidthR
             v.minWidth = v.minWidthR
-            llines[j].rightObj = v.right and WidgetText:New(mod.core, "StarTip.UnitTooltip: " .. v.name .. " (right)", copy(v), 0, 0, v.layer or 0, StarTip.db.profile.errorLevel, widgetUpdate)
+            llines[j].rightObj = v.right and WidgetText:New(mod.core, "StarTip.UnitTooltip:" .. v.name .. ":right:", copy(v), 0, 0, v.layer or 0, StarTip.db.profile.errorLevel, widgetUpdate)

            if v.left then
                llines[j].leftObj.fontObj = _G[v.name .. "Left"] or CreateFont(v.name .. "Left")
diff --git a/StarTip.lua b/StarTip.lua
index a8c58ef..31cd927 100644
--- a/StarTip.lua
+++ b/StarTip.lua
@@ -40,7 +40,7 @@ local function disableUT(name, side)
 		if(v.name == name) then
 			UT.db.profile.lines[k].enabled = false
 			UT:CreateLines()
-			StarTip:Print(format(L["StarTip disabled a tooltip line named %s due to an error in the line's %s segment."], v.name, side))
+			error(format(L["StarTip disabled a tooltip line named %s due to an error in the line's %s segment."], v.name, side))
 		end
 	end
 end
@@ -51,10 +51,10 @@ do
 	function onError(event, errorObject)
 		for k, v in pairs(addon:GetErrors(BugGrabber:GetSessionId())) do
 			if type(v.message) == "string" then
-				v.message:gsub('t.*StarTip\.UnitTooltip:(.*):left:.*', function(name)
+				v.message:gsub('t.*StarTip\.UnitTooltip:(.-):left:.*', function(name)
 					disableUT(name, "left")
 				end)
-				v.message:gsub('t.*StarTip\.UnitTooltip:(.*):right:.*', function(name)
+				v.message:gsub('t.*StarTip\.UnitTooltip:(.-):right:.*', function(name)
 					disableUT(name, "right")
 				end)
 			end