Sir_Popsilots

Oredoubler

Jun 25th, 2021 (edited)
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.01 KB | None | 0 0
  1. local station = 0
  2. --return station[0]
  3. --washing station[1]
  4. --press station[2]
  5. --pickup station[3]
  6.  
  7. function MoveToWash()
  8.     if station  == 0 then
  9.         turtle.turnRight()
  10.     elseif station == 2 then
  11.         turtle.turnLeft()
  12.     elseif station == 3 then
  13.         turtle.turnRight()
  14.         turtle.turnRight()
  15.     end
  16.     station = 1
  17.     sleep(0.3)
  18. end
  19.  
  20. function MoveToPress()
  21.     if station  == 0 then
  22.         turtle.turnRight()
  23.         turtle.turnRight()
  24.     elseif station == 1 then
  25.         turtle.turnRight()
  26.     elseif station == 3 then
  27.         turtle.turnLeft()
  28.     end
  29.     station = 2
  30.     sleep(0.3)
  31. end
  32.  
  33. function MoveToPickUp()
  34.     if station == 0 then
  35.         turtle.turnLeft()
  36.     elseif station ==1 then
  37.         turtle.turnLeft()
  38.         turtle.turnLeft()
  39.     elseif station == 2 then
  40.         turtle.turnRight()
  41.     end
  42.     station = 3
  43.     sleep(0.3)
  44. end
  45.  
  46. function MoveToReturn()
  47.     if station == 1 then
  48.         turtle.left()
  49.     elseif station == 2 then
  50.         turtle.left()
  51.         turtle.left()
  52.     elseif station == 3 then
  53.         turtle.turnRight()
  54.     end
  55.     station = 0
  56.     sleep(0.3)
  57. end
  58.  
  59. function FindLastFreeSlot()
  60.     local slot = 0
  61.     for i = 1, 16, 1 do
  62.         if turtle.getItemCount(i) == 0 then
  63.             return i
  64.         end
  65.     end
  66.     return 16
  67. end
  68.  
  69. function SuckUpItemsFromChest()
  70.     MoveToReturn()
  71.     for i = 1, 16, 1 do
  72.         turtle.suck()
  73.     end
  74. end
  75.  
  76. function ReturnAllItems()
  77.     MoveToReturn()
  78.     for i = 1, 16, 1 do
  79.         turtle.select(i)
  80.         turtle.drop()
  81.     end
  82. end
  83.  
  84. function FindName(str)
  85.     local strlength = string.len(str)
  86.    
  87. end
  88.  
  89. function TempStorage()
  90.     local HowManyItemsAreInThere = 0
  91.     for i = 1, 16, 1 do
  92.         if turtle.getItemCount(i)>0 then
  93.             local b = turtle.getItemDetail(i)
  94.             if string.find(b.name,"crushed") then
  95.                 turtle.select(i)
  96.                 turtle.dropUp()
  97.                 HowManyItemsAreInThere = HowManyItemsAreInThere + 1
  98.             end
  99.         end
  100.     end
  101.     turtle.select(1)
  102.     return HowManyItemsAreInThere
  103. end
  104.  
  105. function GrindItems(LastItemSlot)
  106.     local TimeToSleep
  107.     for i = 1, LastItemSlot, 1 do
  108.         if turtle.getItemCount(i)>0 then
  109.             TimeToSleep = turtle.getItemCount(i) * 4
  110.             turtle.select(i)
  111.             local b = turtle.getItemDetail(i)
  112.             print("attempting to crush " , b.name)
  113.             if string.find(b.name,"crushed") then
  114.                 print("attempt unsuccessful")
  115.             else
  116.                 print("attempt successful")
  117.                 turtle.dropDown()
  118.                 sleep(TimeToSleep)
  119.                 turtle.suckDown()
  120.             end
  121.         end
  122.     end
  123.     turtle.select(1)
  124. end
  125.  
  126. function GetAllItemCount()
  127.     local count = 0
  128.     for i = 1, 16, 1 do
  129.         count = count + turtle.getItemCount(i)
  130.     end
  131.     return count
  132. end
  133.  
  134. function Wash()
  135.     MoveToWash()
  136.     local temp = FindLastFreeSlot()
  137.     for z = 1, temp, 1 do
  138.         turtle.select(z)
  139.         turtle.drop()
  140.         sleep(35)
  141.     end
  142.     turtle.select(1)
  143.     for i = 1, 16, 1 do
  144.         turtle.suck()
  145.     end
  146.     turtle.select(1)
  147. end
  148.  
  149. function PressAndPickUp()
  150.     MoveToPress()
  151.     local temp = FindLastFreeSlot()
  152.     local WaitTime = GetAllItemCount()/16 * 1.6 + 7
  153.     for i = 1, temp, 1 do
  154.         turtle.select(i)
  155.         turtle.drop()
  156.     end
  157.     turtle.select(1)
  158.     MoveToPickUp()
  159.     sleep(WaitTime)
  160.     turtle.suck()
  161.     turtle.suck()
  162. end
  163.  
  164. while true do
  165.     os.pullEvent("redstone")
  166.     MoveToReturn()
  167.     turtle.select(1)
  168.     SuckUpItemsFromChest()
  169.     GrindItems(FindLastFreeSlot())
  170.     if GetAllItemCount()>64 then
  171.         local repeats = TempStorage()
  172.         ReturnAllItems()
  173.         for i = 1, repeats, 1 do
  174.             turtle.select(1)
  175.             turtle.suckUp()
  176.             Wash()
  177.             PressAndPickUp()
  178.             ReturnAllItems()
  179.         end
  180.     else
  181.         Wash()
  182.         PressAndPickUp()
  183.         ReturnAllItems()
  184.     end
  185. end
  186.  
  187.  
Add Comment
Please, Sign In to add comment