Blackhome

dropAll

Jan 6th, 2025 (edited)
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.63 KB | Gaming | 0 0
  1. -- Drops all slots forward except items from list in above storage
  2. function Forward(notDroppedBlocks)
  3.     local bDrop = true
  4.     local returnValue = true
  5.     for i = 1, 16, 1 do
  6.         if turtle.getItemCount(i) > 0 then
  7.             turtle.select(i)
  8.             if notDroppedBlocks then
  9.                 for j = 1, #notDroppedBlocks, 1 do
  10.                     local itemDetail = turtle.getItemDetail()
  11.                     if itemDetail then
  12.                         if itemDetail.name == notDroppedBlocks[j] then
  13.                             bDrop = false
  14.                         end
  15.                     end
  16.                 end
  17.             end
  18.             if bDrop then
  19.                 if not turtle.drop() then
  20.                     returnValue = false
  21.                 end
  22.             end
  23.             bDrop = true
  24.         end
  25.     end
  26.     return returnValue
  27. end
  28.  
  29. -- Drops all slots up except items from list in above storage
  30. function Up(notDroppedBlocks)
  31.     local bDrop = true
  32.     local returnValue = true
  33.     for i = 1, 16, 1 do
  34.         if turtle.getItemCount(i) > 0 then
  35.             turtle.select(i)
  36.             if notDroppedBlocks then
  37.                 for j = 1, #notDroppedBlocks, 1 do
  38.                     local itemDetail = turtle.getItemDetail()
  39.                     if itemDetail then
  40.                         if itemDetail.name == notDroppedBlocks[j] then
  41.                             bDrop = false
  42.                         end
  43.                     end
  44.                 end
  45.             end
  46.             if bDrop then
  47.                 if not turtle.dropUp() then
  48.                     returnValue = false
  49.                 end
  50.             end
  51.             bDrop = true
  52.         end
  53.     end
  54.     return returnValue
  55. end
  56.  
  57. -- Drops all slots down except items from list in above storage
  58. function Down(notDroppedBlocks)
  59.     local bDrop = true
  60.     local returnValue = true
  61.     for i = 1, 16, 1 do
  62.         if turtle.getItemCount(i) > 0 then
  63.             turtle.select(i)
  64.             if notDroppedBlocks then
  65.                 for j = 1, #notDroppedBlocks, 1 do
  66.                     local itemDetail = turtle.getItemDetail()
  67.                     if itemDetail then
  68.                         if itemDetail.name == notDroppedBlocks[j] then
  69.                             bDrop = false
  70.                         end
  71.                     end
  72.                 end
  73.             end
  74.             if bDrop then
  75.                 if not turtle.dropDown() then
  76.                     returnValue = false
  77.                 end
  78.             end
  79.             bDrop = true
  80.         end
  81.     end
  82.     return returnValue
  83. end
  84.  
  85. return { Forward = Forward, Up = Up, Down = Down}
Add Comment
Please, Sign In to add comment