Return integers, ignore cents
Yaron Kfir [05-24-14 - 05:47]
Return integers, ignore cents
diff --git a/MathUtils.lua b/MathUtils.lua
index 00b1514..e7fc3a3 100644
--- a/MathUtils.lua
+++ b/MathUtils.lua
@@ -10,7 +10,7 @@ function MathUtils:WeightedAverage(itemTable)
sum = sum + item.purchasePrice
weight = weight + item.stackCount
end
- return sum / weight
+ return math.floor(sum / weight)
end
function MathUtils:Max(itemTable)
diff --git a/PriceTracker.lua b/PriceTracker.lua
index 291e32e..7b84133 100644
--- a/PriceTracker.lua
+++ b/PriceTracker.lua
@@ -8,7 +8,6 @@ PriceTracker = {
settingsVersion = 0.1,
mathUtils = MathUtils
}
-
local PriceTracker = PriceTracker
-- Addon initialization
@@ -79,7 +78,7 @@ function PriceTracker:OnUpdateTooltip(item)
ItemTooltip:AddLine("Price Tracker", "ZoFontHeader2")
local r, g, b = ZO_TOOLTIP_DEFAULT_COLOR:UnpackRGB()
ItemTooltip:AddLine("Suggested Price:", "ZoFontGame", r, g, b, TOPLEFT, MODIFY_TEXT_TYPE_NONE, LEFT, false)
- ItemTooltip:AddLine(self:FormatTooltipLine(self:FormatPrice(price), item.dataEntry.data.stackCount or item.dataEntry.data.stack), "ZoFontGame", r, g, b, LEFT, MODIFY_TEXT_TYPE_NONE, CENTER, false)
+ ItemTooltip:AddLine(self:FormatTooltipLine(price, item.dataEntry.data.stackCount or item.dataEntry.data.stack), "ZoFontGame", r, g, b, LEFT, MODIFY_TEXT_TYPE_NONE, CENTER, false)
end
function PriceTracker:OnHideTooltip()
@@ -183,15 +182,6 @@ function PriceTracker:SuggestPrice(itemName)
-- return PriceTracker.mathUtils:WeightedAverage(matches)
end
--- Format the price into a more-readable string. Omit decimal point if price is an integer
-function PriceTracker:FormatPrice(price)
- if(math.floor(price) == price) then
- return price
- end
-
- return string.format("%.2f", price)
-end
-
function PriceTracker:FormatTooltipLine(price, stackCount)
return string.format("%7s|t16:16:%s|t %-25s %7s|t16:16:%s|t %-25s", price, "EsoUI/Art/currency/currency_gold.dds", "(per item)", price * stackCount, "EsoUI/Art/currency/currency_gold.dds", "(stack of " .. stackCount .. ")")
end