view Classes/ContainerItem.class.lua @ 110:67bd5057ecb7

Implemented vendor restocking with the mover. Comitting so I can always review this working version, but I?ll be disabling all part of it as it is not going to work properly without seriously compromising the code structure. Debug messages are now appended with ?Inventorium? (my MailOpener addon was making stuff difficult). Now properly removing the refill window from the displayed static popup windows list so new popups won?t be aligned at odd locations. Changed ?CreateMoverFrame? to not contain any scenario-specific info. All settings can be set with SetFrameSettings. Items that belong to speciality bags are now put there. Other items now ignore spaciality bags. Implemented test code for mailbox refill support. It has been disabled due to some issues but may be introduced later. The guild withdrawal limit is now taken into consideration. Queue is now reset before scanning again.
author Zerotorescue
date Fri, 14 Jan 2011 23:25:05 +0100
parents 3bec0ea44607
children 41f0689dfda1
line wrap: on
line source
local addon = select(2, ...);

-- Define the class

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

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

function addon.ContainerItem:AddLocation(container, slot, count, price)
	table.insert(self.locations, {
		["container"] = container,
		["slot"] = slot,
		["count"] = count,
		["price"] = price,
	});
	
	-- -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

function addon.ContainerItem:GetVendorPrice()
	for _, loc in pairs(self.locations) do
		if loc.price then
			return loc.price;
		end
	end
end