diff Core.lua @ 16:56de19d9bd8d

Cleaned up the messages. You can turn the notifications of price changes off and those messages will only show gold or silver if they are more than 0. I have also removed the dependency on AceConsole because it doesn't allow changing the color of the addon name when I print messages.
author Asa Ayers <Asa.Ayers@Gmail.com>
date Sat, 03 Jul 2010 10:05:53 -0700
parents 44e70a3fdb19
children 67f4151d535c
line wrap: on
line diff
--- a/Core.lua	Sat Jul 03 07:40:01 2010 -0700
+++ b/Core.lua	Sat Jul 03 10:05:53 2010 -0700
@@ -1,5 +1,5 @@
 local addonName, addonTable = ...; 
-_G[addonName] = LibStub("AceAddon-3.0"):NewAddon(addonName, "AceConsole-3.0", "AceEvent-3.0", "AceBucket-3.0")
+_G[addonName] = LibStub("AceAddon-3.0"):NewAddon(addonName, "AceEvent-3.0", "AceBucket-3.0")
 local addon = _G[addonName]
 addonTable.ItemAuditor = addon
 
@@ -17,10 +17,15 @@
 function addon:OnInitialize()
 	local DB_defaults = {
 		char = {
-			debug = false,
 			ah = 1,
 			use_quick_auctions = false,
 		},
+		profile = {
+			messages = {
+				debug = false,
+				cost_updates = true,
+			}
+		},
 		factionrealm = {
 			item_account = {},
 			items = {},
@@ -55,6 +60,11 @@
 	self:RefreshQAGroups()
 end
 
+function addon:Print(message)
+	local prefix = "|cFFA3CEFF"..tostring( self ).."|r: "
+	DEFAULT_CHAT_FRAME:AddMessage( prefix .. message)
+end
+
 function addon:GetCurrentInventory()
 	local i = {}
 	local bagID
@@ -229,10 +239,10 @@
 	end
 	
 	if abs(value) > 0 then
-		self:Debug("Updated price of " .. itemName .. " to " .. self:FormatMoney(item.invested) .. "(change: " .. self:FormatMoney(value) .. ")")
-		
-		if item.invested <= 0 then
-			self:Debug("Updated price of " .. itemName .. " to " ..self:FormatMoney(0))
+		if  item.invested <= 0 then
+			if self.db.profile.messages.cost_updates then
+				self:Print(format("Updated price of %s from %s to %s. %sYou just made a profit of %s.", itemName, self:FormatMoney(item.invested - value), self:FormatMoney(0), GREEN, self:FormatMoney(abs(item.invested))))
+			end
 			self:RemoveItem(link)
 		-- This doesn't work when you mail the only copy of an item you have to another character.
 		--[[
@@ -240,6 +250,10 @@
 			self:Print("You ran out of " .. itemName .. " and never recovered " .. self:FormatMoney(item.invested))
 			self:RemoveItem(link)
 		]]
+		else
+			if self.db.profile.messages.cost_updates then
+				self:Print(format("Updated price of %s from %s to %s. (total change:%s)", itemName, self:FormatMoney(item.invested - value), self:FormatMoney(item.invested), self:FormatMoney(value)))
+			end
 		end
 	end