view Classes/ContainerItem.class.lua @ 117:239e25a058c7

Implemented mail refilling support. Respecting the MailAddonBusy global when opening so addons like MailOpener shouldn?t interfere.
author Zerotorescue
date Sat, 15 Jan 2011 13:15:16 +0100
parents 41f0689dfda1
children dc6f405c1a5d
line wrap: on
line source
local addon = select(2, ...);

-- Define the class

addon.ContainerItem = {};
addon.ContainerItem.__index = addon.ContainerItem;

-- Construct
function addon.ContainerItem:New()
	local self = {};
	
	setmetatable(self, addon.ContainerItem);
	
	-- Standard info everything needs
	self.totalCount = 0;
	self.locations = {};
	
	return self;
end

function addon.ContainerItem:AddLocation(container, slot, count)
	table.insert(self.locations, {
		["container"] = container,
		["slot"] = slot,
		["count"] = count,
	});
	
	-- -1 indicates unlimited supply
	if self.totalCount ~= -1 then
		if count == -1 then
			self.totalCount = -1;
		else
			self.totalCount = (self.totalCount + count);
		end
	end
	
	return true;
end