diff Modules/ProspectMe_Tooltip.lua @ 62:58d886030d65

Updated the tooltip to allow coloring and returning of negative amounts
author Vynn <mischivin@gmail.com>
date Thu, 08 Dec 2016 23:02:01 -0500
parents 155fa49865f2
children dcb2ec933df7
line wrap: on
line diff
--- a/Modules/ProspectMe_Tooltip.lua	Mon Nov 28 12:30:51 2016 -0500
+++ b/Modules/ProspectMe_Tooltip.lua	Thu Dec 08 23:02:01 2016 -0500
@@ -10,6 +10,14 @@
 		local g, s, c
 		local digits = 0
 		local gsc
+		local neg = false
+
+		--if value is negative, record it and get the absolute value so log10 works
+		if value < 0 then
+			neg = true
+			value = math.abs(value)
+		end
+
 
 		g = math.floor(value/10000)
 		s = math.fmod(math.floor(value/100),100)
@@ -29,7 +37,10 @@
 		else
 			gsc = string.format("|c%s%2.1fk|r", GSC_GOLD, g/1000)
 		end
-
+		--if the original number was negative, add the symbol back in
+		if neg then
+			gsc = "|cffff0000(|r" .. gsc .. "|cffff0000)|r"
+		end
 		return gsc
 	end