Feldherren

Turtle Inventory Sort

May 6th, 2019
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.74 KB | None | 0 0
  1. local function sortInventory()
  2.     local inventory = {}
  3.     for curSlot=1,16 do
  4.         if turtle.getItemCount(curSlot) ~= 0 then
  5.             inventory[curSlot] = turtle.getItemDetail(curSlot)
  6.         else
  7.             inventory[curSlot] = "empty"
  8.         end
  9.     end
  10.     for slotA=1,16 do
  11.         if inventory[slotA] ~= "empty" then
  12.             for slotB=1,16 do
  13.                 if inventory[slotB] ~= "empty" then
  14.                     if slotA ~= slotB then
  15.                         if (inventory[slotA].name == inventory[slotB].name) and (inventory[slotA].damage == inventory[slotB].damage) then
  16.                             if inventory[slotA].count + inventory[slotB].count <= 64 then
  17.                                 turtle.select(slotB)
  18.                                 turtle.transferTo(slotA)
  19.                                 inventory[slotB] = "empty"
  20.                             end
  21.                         end
  22.                     end
  23.                 end
  24.             end
  25.         end
  26.     end
  27. end
  28.  
  29. sortInventory()
Advertisement
Add Comment
Please, Sign In to add comment