Advertisement
Sir_Popsilots

Storage

Mar 1st, 2021 (edited)
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.69 KB | None | 0 0
  1. local Chest1slots_Stone = {}
  2. local Chest2slots_Wood = {}
  3. local Chest3slots_Ores = {}
  4. local Chest4slots_Other = {}
  5. local ChestPath = {false,false,false,false}
  6. local x,z = -2,0
  7. function CheckChest(slot)
  8.     if turtle.getItemCount(slot)>0 then
  9.         local temp= turtle.getItemDetail(slot)
  10.         local SlotItemName = temp.name
  11.         if string.find(SlotItemName,"stone") then
  12.             table.insert(Chest1slots_Stone,slot)
  13.             ChestPath[1] = true
  14.         elseif string.find(SlotItemName,"log") or (string.find(SlotItemName,"planks")) then
  15.             table.insert(Chest2slots_Wood,slot)
  16.             ChestPath[2] = true
  17.         elseif string.find(SlotItemName,"ore") then
  18.             table.insert(Chest3slots_Ores,slot)
  19.             ChestPath[3] = true
  20.         else
  21.             table.insert(Chest4slots_Other,slot)
  22.             ChestPath[4] = true
  23.         end
  24.     end
  25. end
  26.  
  27. function blockpickup()
  28.     local i = 1
  29.     repeat
  30.         turtle.suckDown()
  31.         i = i + 1
  32.         turtle.select(i)
  33.     until i == 16
  34.     turtle.select(1)
  35. end
  36.  
  37. function go_to(chestnum)
  38.     if chestnum == 0 then
  39.         repeat
  40.             turtle.back()
  41.             x = x - 1
  42.         until x == -2
  43.     else
  44.         if x < chestnum then
  45.             for i = 1,chestnum-x do
  46.                 turtle.forward()
  47.                 x = x + 1
  48.             end
  49.         else
  50.             if x > chestnum then
  51.                 for i = 1,x-chestnum do
  52.                     turtle.back()
  53.                     x = x - 1
  54.                 end
  55.             end
  56.         end
  57.     end
  58. end
  59.  
  60. function turnINTOchest()
  61.     turtle.turnLeft()
  62.     turtle.forward()
  63. end
  64.  
  65. function turnOUTFROMchest()
  66.     turtle.back()
  67.     turtle.turnRight()
  68.    
  69. end
  70.  
  71. function PlaceItemsInChest(chestnum)
  72.     go_to(chestnum)
  73.     turnINTOchest()
  74.     if chestnum == 1 then
  75.         for i = 1,#Chest1slots_Stone do
  76.             turtle.select(Chest1slots_Stone[i])
  77.             turtle.dropDown()
  78.         end
  79.     elseif chestnum == 2 then
  80.         for i = 1,#Chest2slots_Wood do
  81.             turtle.select(Chest2slots_Wood[i])
  82.             turtle.dropDown()
  83.         end
  84.     elseif chestnum == 3 then
  85.         for i = 1 ,#Chest3slots_Ores do
  86.             turtle.select(Chest3slots_Ores[i])
  87.             turtle.dropDown()
  88.         end
  89.     elseif chestnum == 4 then
  90.         for i = 1 ,#Chest4slots_Other do
  91.             turtle.select(Chest4slots_Other[i])
  92.             turtle.dropDown()
  93.         end
  94.     end
  95.     turnOUTFROMchest()
  96. end
  97.  
  98. blockpickup()
  99. local slot = 1
  100. repeat
  101.     CheckChest(slot)
  102.     slot = slot + 1
  103. until slot == 16
  104. for i = 1 ,4 do
  105.     if ChestPath[i] then
  106.         PlaceItemsInChest(i)
  107.     end
  108. end
  109. turtle.select(1)
  110. go_to(0)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement