Created
September 12, 2010 22:01
-
-
Save cschomburg/576500 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Multiple item-buttons per bagSlot | |
-- Untested and probably inefficient | |
function Implementation:UpdateSlot(event, bagID, slotID) | |
-- Existing code here - maybe also exclusive filtering | |
-- Cycle through containers which should be non-exclusive | |
for id, container in pairs(self.contByID) do | |
-- Find the button for the slot in the container, if any. | |
-- could be faster to have a separate table with bag/slot-IDs as keys | |
local button | |
for i, btn in pairs(container.buttons) do | |
if(btn.bagID == bagID and btn.slotID == slotID) then | |
button = btn | |
break | |
end | |
end | |
-- Check if the item can go into the container | |
if(container.filters:Check(item)) then | |
if(not button) then -- Create a new button when necessary | |
button = self.buttonClass:New(bagID, slotID) | |
container:AddButton(button) | |
end | |
button:Update() | |
elseif(button) then -- Didn't fit into container? Remove existing button | |
container:RemoveButton(button) | |
button:Free() | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment