lotrointerface.com
Search Downloads

LoTROInterface SVN SortPack

[/] [trunk/] [JackdawPlugins/] [SortPack/] [Stack.Lua] - Rev 156

Compare with Previous | Blame | View Log

function Stack()

Timer=Turbine.UI.Control()

        function Timer:Start()
                FirstStart= Turbine.Engine.GetGameTime()
                
                Slot=1
                Start= Turbine.Engine.GetGameTime()
                Timer:SetWantsUpdates(true)
        end
        
        function Timer:Update()
                local Time = Turbine.Engine.GetGameTime()
                local elapsed = Time - Start
                
                if elapsed>0.2 then
                        if Slot>size then
                                Timer:SetWantsUpdates(false)
                                Timer=nil
                                Turbine.Shell.WriteLine("<rgb=#888888>Stack finished after "..Time-FirstStart.." seconds.")
                                return
                        end
                        
                        --Get the name of the current item
                        aitem=backpack:GetItem(Slot)
                        
                        --If there is no item to search for then see what is in the current slot.
                        if SearchItem==nil then
                                if aitem~=nil then
                                        local itemInfo=aitem:GetItemInfo()
                                        Current=        itemInfo:GetName()
                                        StackSize=      itemInfo:GetMaxStackSize()
                                        Quantity=       aitem:GetQuantity()
                                        if StackSize>Quantity then
                                                SearchItem=Current
                                        else
                                                Slot=Slot+1
                                                return
                                        end
                                else
                                        Slot=Slot+1
                                        return
                                end
                        end
                        
                        if SearchItem~=nil then
                                        --If the stack is full - get outta here!
                                        local itemInfo=aitem:GetItemInfo()
                                        if aitem:GetQuantity()==StackSize then
                                                SearchItem=nil
                                                Slot=Slot+1
                                                Start= Turbine.Engine.GetGameTime()
                                                return
                                        end
                                
                                        --Search for the item in the rest of the pack.
                                        for i=Slot+1,size do
                                                item=backpack:GetItem(i)
                                                if item~=nil then local itemInfo=item:GetItemInfo() Name=itemInfo:GetName() 
                                                        if Name==SearchItem then
                                                                local itemInfo=item:GetItemInfo()
                                                                if item:GetQuantity()~=StackSize then                                                                   
                                                                        backpack:PerformItemDrop(item,Slot, false)
                                                                        Start= Turbine.Engine.GetGameTime()
                                                                        return
                                                                end
                                                        end
                                                end
                                        end
                                        SearchItem=nil
                                        Slot=Slot+1
                                        Start= Turbine.Engine.GetGameTime()
                                        return
                                end
                        end             
                end
        Timer:Start()
end

Compare with Previous | Blame


All times are GMT -5. The time now is 02:02 PM.


Our Network
EQInterface | EQ2Interface | Minion | WoWInterface | ESOUI | LoTROInterface | MMOUI | Swtorui