diff Core.lua @ 45:a66f6fc57cfb

Fixed two nil related errors and an error with calculating how much an item is worth when it is being created or destroyed.
author Asa Ayers <Asa.Ayers@Gmail.com>
date Tue, 20 Jul 2010 00:09:54 -0700
parents 003de902ae64
children 234896be4087
line wrap: on
line diff
--- a/Core.lua	Mon Jul 19 22:49:02 2010 -0700
+++ b/Core.lua	Tue Jul 20 00:09:54 2010 -0700
@@ -220,10 +220,11 @@
 			local trackID
 			if outboundSubject ~= nil then
 				self:Debug(outboundSubject)
-				trackID = tonumber(select(3, outboundSubject:find('[[]IA: (%d*)[]]')))
+				trackID = select(3, outboundSubject:find('[[]IA: (%d*)[]]'))
 				
-				self:Debug('COD ID: %s', trackID)
 				if trackID ~= nil then
+					trackID = tonumber(trackID)
+					self:Debug('COD ID: %s', trackID)
 					local cod = self.db.factionrealm.outbound_cod[trackID]
 					if cod == nil then
 						skipMail[mailSignature] = true
@@ -308,6 +309,10 @@
 	
 	if self.items[link] ~= nil then
 		self.items[link].count =  Altoholic:GetItemCount(self:GetIDFromLink(link))
+		
+		if self.items[link].invested == nil then
+			self.items[link].invested = 0
+		end
 	end
 	
 	if viewOnly == true and self.items[link] == nil then
@@ -432,7 +437,7 @@
 			count = count - countModifier
 		end
 		if count > 0 then 
-			return ceil(item.invested), ceil(item.invested/item.count), count
+			return ceil(item.invested), ceil(item.invested/count), count
 		end
 		
 	end