SHOW:
|
|
- or go back to the newest paste.
| 1 | function compactInv() | |
| 2 | for checkSlot = 1, 16 do | |
| 3 | if turtle.getItemCount(checkSlot) > 0 then | |
| 4 | turtle.select(checkSlot) | |
| 5 | for testSlot = checkSlot, 16 do | |
| 6 | if turtle.compareTo(testSlot) then | |
| 7 | turtle.select(testSlot) | |
| 8 | turtle.transferTo(checkSlot, turtle.getItemCount(testSlot)) | |
| 9 | turtle.select(checkSlot) | |
| 10 | end | |
| 11 | end | |
| 12 | end | |
| 13 | end | |
| 14 | end | |
| 15 | ||
| 16 | function cleanUp() | |
| 17 | for checkSlot = 16, 1, -1 do | |
| 18 | while turtle.getItemCount(checkSlot) > 0 do | |
| 19 | moveSlot = 16 | |
| 20 | turtle.select(checkSlot) | |
| 21 | while not turtle.transferTo(moveSlot, turtle.getItemCount(checkSlot)) do | |
| 22 | moveSlot = moveSlot - 1 | |
| 23 | end | |
| 24 | if moveSlot == checkSlot then | |
| 25 | break | |
| 26 | end | |
| 27 | end | |
| 28 | end | |
| 29 | end | |
| 30 | ||
| 31 | function sortInv() | |
| 32 | for checkSlot = 16, 1, -1 do | |
| 33 | if turtle.getItemCount(checkSlot) > 0 then | |
| 34 | turtle.select(checkSlot) | |
| 35 | moveSlot = 1 | |
| 36 | while not turtle.transferTo(moveSlot, turtle.getItemCount(checkSlot)) do | |
| 37 | moveSlot = moveSlot + 1 | |
| 38 | end | |
| 39 | turtle.select(moveSlot) | |
| 40 | for testSlot = 16, 1, -1 do | |
| 41 | moveSlot2 = moveSlot | |
| 42 | if testSlot > moveSlot2 then | |
| 43 | if turtle.getItemCount(testSlot) > 0 then | |
| 44 | if turtle.compareTo(testSlot) then | |
| 45 | turtle.select(testSlot) | |
| 46 | while not turtle.transferTo(moveSlot2, turtle.getItemCount(testSlot)) do | |
| 47 | moveSlot2 = moveSlot2 + 1 | |
| 48 | end | |
| 49 | turtle.select(moveSlot) | |
| 50 | end | |
| 51 | end | |
| 52 | end | |
| 53 | end | |
| 54 | end | |
| 55 | end | |
| 56 | end | |
| 57 | ||
| 58 | compactInv() | |
| 59 | cleanUp() | |
| 60 | sortInv() | |
| 61 | turtle.select(1) |