Advertisement
Darthseid

Stack Exchange Function

Feb 28th, 2016
3,060
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.04 KB | None | 0 0
  1. function ReorderInventory( keys )
  2. local caster = keys.caster
  3.     local target = keys.target
  4.     local slots = {}
  5.     for itemSlot = 0, 5, 1 do
  6.  
  7.         -- Handle the case in which the caster is removed
  8.         local item
  9.         if IsValidEntity(caster) then
  10.             item = caster:GetItemInSlot( itemSlot )    
  11.         end
  12.        
  13.         if item ~= nil then
  14.             table.insert(slots, itemSlot)
  15.         end
  16.     end
  17.  
  18.     for k,itemSlot in pairs(slots) do  
  19.         caster:SwapItems(itemSlot,k+6)
  20.     end
  21. end
  22.  
  23. function ReorderStash( keys )
  24. local caster = keys.caster
  25.     local target = keys.target
  26.     local slots = {}
  27.     for itemSlot = 6, 11, 1 do
  28.  
  29.         -- Handle the case in which the caster is removed
  30.         local item
  31.         if IsValidEntity(caster) then
  32.             item = caster:GetItemInSlot( itemSlot )
  33.        
  34.         end
  35.         if item ~= nil then    
  36.             table.insert(slots, itemSlot)
  37.         end    
  38.     end
  39.    
  40.     for k,itemSlot in pairs(slots) do
  41.         caster:SwapItems(itemSlot,k-6)     
  42.     end
  43. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement