Advertisement
ksbd

Chef program for Create Above and Beyond

Dec 6th, 2021
1,310
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. cookTime        = 6
  2. orientateDone   = 0
  3. orientateSlot   = 5
  4. potatoSlot      = 1
  5. potatoCompSlot  = 13
  6. beetSlot        = 2
  7. beetCompSlot    = 14
  8. carrotSlot      = 3
  9. carrotCompSlot  = 15
  10. cabbageSlot     = 4
  11. cabbageCompSlot = 16
  12. stock           = 0
  13. redstoneStopLvl = 7
  14. redstoneLvl     = 0
  15.  
  16. function orientate()
  17.     turtle.select(orientateSlot)
  18.     while (orientateDone == 0) do
  19.         turtle.suck(1)
  20.         if turtle.compareTo(potatoCompSlot) then
  21.             turtle.drop(1)
  22.             orientateDone = 1
  23.    print("Found the potato")
  24.         else
  25.             turtle.drop(1)
  26.             turtle.turnLeft()
  27.         end
  28.     end
  29. end
  30.  
  31. function startup()
  32.     orientate()
  33.     turtle.select(potatoSlot)
  34.     turtle.drop(64)
  35.     turtle.turnLeft()
  36.     turtle.select(beetSlot)
  37.     turtle.drop(64)
  38.     turtle.turnLeft()
  39.     turtle.select(carrotSlot)
  40.     turtle.drop(64)
  41.     turtle.turnLeft()
  42.     turtle.select(cabbageSlot)
  43.     turtle.drop(64)
  44.     turtle.turnLeft()
  45.     turtle.select(potatoSlot)
  46.     print("Startup Complete")
  47. end
  48.  
  49. function getPotato()
  50.     turtle.select(potatoSlot)
  51.     while (turtle.getItemCount(potatoSlot) < 1) do
  52.         turtle.suck(1)
  53.         if (turtle.getItemCount(potatoSlot) < 1) then
  54.             sleep(1)
  55.         end
  56.     end
  57.     print("Got potato")
  58. end
  59.  
  60. function getBeet()
  61.     turtle.select(beetSlot)
  62.     while (turtle.getItemCount(beetSlot) < 1) do
  63.         turtle.suck(1)
  64.         if (turtle.getItemCount(beetSlot) < 1) then
  65.             sleep(1)
  66.         end
  67.     end
  68.     print("Got beet")
  69. end
  70.  
  71. function getCarrot()
  72.     turtle.select(carrotSlot)
  73.     while (turtle.getItemCount(carrotSlot) < 1) do
  74.         turtle.suck(1)
  75.         if (turtle.getItemCount(carrotSlot) < 1) then
  76.             sleep(1)
  77.         end
  78.     end
  79.     print("Got carrot")
  80. end
  81.  
  82. function getCabbage()
  83.     turtle.select(cabbageSlot)
  84.     while (turtle.getItemCount(cabbageSlot) < 1) do
  85.         turtle.suck(1)
  86.         if (turtle.getItemCount(cabbageSlot) < 1) then
  87.             sleep(1)
  88.         end
  89.     end
  90.     print("Got cabbage")
  91. end
  92.  
  93. function stockUp()
  94.     getPotato()
  95.     turtle.turnLeft()
  96.     getBeet()
  97.     turtle.turnLeft()
  98.     getCarrot()
  99.     turtle.turnLeft()
  100.     getCabbage()
  101.     turtle.turnLeft()
  102.     print("Fully Stocked! Time to cook :D")
  103.  stock = stock+1
  104.  print("Current stock: " ..stock)
  105. end
  106.  
  107. function cook()
  108.     while (stock > 0) do
  109.         turtle.select(potatoSlot)
  110.         turtle.dropDown()
  111.         turtle.select(beetSlot)
  112.         turtle.dropDown()
  113.         turtle.select(carrotSlot)
  114.         turtle.dropDown()
  115.         turtle.select(cabbageSlot)
  116.         turtle.dropDown()
  117.         print("1 set of ingredients added")
  118.         stock = stock-1
  119.         print("current stock: " ..stock)
  120.         sleep(cookTime)
  121.     end
  122. end
  123.  
  124. function checkRedstoneLvl()
  125.     redstoneLvl = redstone.getAnalogInput("top")
  126. end  
  127.          
  128. startup()
  129.  
  130. while true do
  131.     checkRedstoneLvl()
  132.     if redstoneLvl < redstoneStopLvl then
  133.         if stock < 1 then
  134.             stockUp()
  135.         else
  136.             cook()
  137.         end
  138.     else
  139.         sleep(10)
  140.         print("The cookpot is full!")
  141.     end
  142. end        
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement