view Classes/ContainerItem.class.lua @ 119:dc6f405c1a5d

Now resizing the mover frame based on text size. addon.Locations table now uses location names as value, rather than random numbers. Added proper Merchant restocking support. Please note this currently doesn?t take the bonus queue nor the min crafting queue options into account.
author Zerotorescue
date Sat, 15 Jan 2011 17:03:05 +0100
parents 239e25a058c7
children
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 = {};
	self.price = nil; -- usually unused
	
	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