bullseye224

pumpkinPies

Sep 29th, 2023 (edited)
441
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -------------------------------
  2. --Select a slot
  3. -------------------------------
  4. function ss(num)
  5.     turtle.select(num)
  6. end
  7.  
  8. -------------------------------
  9. --Turning Functions
  10. -------------------------------
  11. --Turn Right
  12. function tr(num)
  13.     if (num == nil or num == '') then
  14.         num = 1
  15.     end
  16.     for i=1,num,1 do
  17.         turtle.turnRight()
  18.     end
  19. end
  20.  
  21. --Turn Left
  22. function tl(num)
  23.     if (num == nil or num == '') then
  24.         num = 1
  25.     end
  26.     for i=1,num,1 do
  27.         turtle.turnLeft()
  28.     end
  29. end
  30.  
  31. -------------------------------
  32. --Movement Functions
  33. -------------------------------
  34. --Go forward
  35. function gf(num)
  36.     if (num == nil or num == '') then
  37.         num = 1
  38.     end
  39.     for i=1,num,1 do
  40.         while turtle.detect() do
  41.             turtle.dig()
  42.         end
  43.         turtle.forward()
  44.     end
  45. end
  46.  
  47. --Go Back
  48. function gb(num)
  49.     if (num == nil or num == '') then
  50.         num = 1
  51.     end
  52.     for i=1,num,1 do
  53.         turtle.back()
  54.     end
  55. end
  56.  
  57. --Go Up
  58. function gu(num)
  59.     if (num == nil or num == '') then
  60.         num = 1
  61.     end
  62.     for i=1,num,1 do
  63.         while turtle.detectUp() do
  64.             turtle.digUp()
  65.         end
  66.         turtle.up()
  67.     end
  68. end
  69.  
  70. --Go Down
  71. function gd(num)
  72.     if (num == nil or num == '') then
  73.         num = 1
  74.     end
  75.     for i=1,num,1 do
  76.         if turtle.detectDown() then
  77.             turtle.digDown()
  78.             turtle.down()
  79.         else
  80.             turtle.down()
  81.         end
  82.     end
  83. end
  84.  
  85. -------------------------------
  86. --Digging Functions
  87. -------------------------------
  88. -- Dig Forward
  89. function df()
  90.     while turtle.detect() do
  91.         turtle.dig()
  92.     end
  93. end
  94.  
  95. --Dig Up
  96. function du()
  97.     while turtle.detectUp() do
  98.         turtle.digUp()
  99.     end
  100. end
  101.  
  102. --Dig Down
  103. function dd()
  104.     while turtle.detectDown() do
  105.         turtle.digDown()
  106.     end
  107. end
  108.  
  109. -------------------------------
  110. --Placing Functions
  111. -------------------------------
  112. --Place Forward
  113. function pf(num)
  114.     if (num == nil or num == '') then
  115.         turtle.place()
  116.     else
  117.         ss(num)
  118.         turtle.place()
  119.     end
  120. end
  121.  
  122. --Place Up
  123. function pu(num)
  124.     if (num == nil or num == '') then
  125.         turtle.placeUp()
  126.     else
  127.         ss(num)
  128.         turtle.placeUp()
  129.     end
  130. end
  131.  
  132. --Place Down
  133. function pd(num)
  134.     if (num == nil or num == '') then
  135.         turtle.placeDown()
  136.     else
  137.         ss(num)
  138.         turtle.placeDown()
  139.     end
  140. end
  141.  
  142. -------------------------------
  143. --Refuels the turtle
  144. -------------------------------
  145. function refuel(num)
  146.     if (num == nil or num == '') then
  147.         turtle.refuel()
  148.     else
  149.         ss(num)
  150.         turtle.refuel()
  151.     end
  152. end
  153.  
  154. -------------------------------
  155. --Checks the fuel levels
  156. -------------------------------
  157. function fuelCheck()
  158.     x = 1
  159.     while x==1 do
  160.         refuel(16)
  161.         y=turtle.getFuelLevel()
  162.         print("Fuel level is: ", tostring(y))
  163.         if y > 500 then
  164.             x=2
  165.         else
  166.             print("Add more fuel to slot 16 to continue.")
  167.             os.sleep(120)
  168.             x=1
  169.         end
  170.     end
  171. end --fuelCheck()
  172.  
  173. -------------------------------
  174. --Unload all extra stuff into the chest beneath turtle
  175. -------------------------------
  176. function unloadTurtle()
  177.     print("Unloading Inventory...")
  178.     for i=1,12
  179.     do
  180.         turtle.select(i)
  181.         turtle.dropDown()
  182.     end
  183. end --unloadTurtle
  184.  
  185. -------------------------------
  186. --Craft Sugar from Sugar Cane
  187. -------------------------------
  188. function craftSugar()
  189.     ss(1)
  190.     turtle.suckDown(4)
  191.     turtle.craft()
  192.     turtle.transferTo(sugar,4)
  193.     ss(1)
  194. end --craftSugar
  195.  
  196. -------------------------------
  197. --Harvest Sugar Cane
  198. -------------------------------
  199. function harvestSugarCane()
  200.     gu(2)
  201.     gf(8)
  202.     tr(2)
  203.     gd()
  204.     gf(8)
  205.     tr(2)
  206.     gd()
  207.     unloadTurtle()
  208. end --harvestSugarCane
  209.  
  210. -------------------------------
  211. --Harvest Pumpkin
  212. -------------------------------
  213. function harvestPumpkins()
  214.     -- Go to pumpkins
  215.    
  216.     --Harvest them
  217.     ss(1)
  218.    
  219.     --go to pumpkin chest
  220.     turtle.drop()
  221.     ss(pumpkins)
  222.     turtle.suck(4)
  223.     ss(1)
  224.    
  225. end --harvestPumpkins
  226.  
  227. -------------------------------
  228. --Harvest Eggs
  229. -------------------------------
  230. function harvestEggs()
  231.     --go to egg chest
  232.    
  233.     --Get the eggs we need
  234.     ss(1)
  235.     turtle.drop()
  236.     ss(eggs)
  237.     turtle.suck(4)
  238.     ss(1)
  239.    
  240.  end --harvestEggs
  241.  
  242. -------------------------------
  243. --Craft Pumpkin Pie
  244. -------------------------------
  245. function craftPumpkinPie()
  246.     turtle.craft
  247.     ss(1)
  248.     turtle.drop()
  249.     ss(sugar)
  250.     turtle.drop()
  251.     ss(pumpkins)
  252.     turtle.drop()
  253.     ss(eggs)
  254.     turtle.drop()
  255.     --go back to starting position
  256.     gd()
  257.     gb(5)
  258.     tl()
  259.     gb()
  260.     tl()
  261.     gf()
  262.     tr()
  263.  end --craftPumpkinPie
  264.  
  265. -------------------------------
  266. --Harvest the Supplies
  267. -------------------------------
  268. function harvestPPSupplies(i)
  269.     ss(sugar)
  270.     turtle.dropDown()
  271.     ss(pumpkins)
  272.     turtle.dropDown()
  273.     ss(eggs)
  274.     turtle.dropDown()
  275.    
  276.     harvestSugarCane()
  277.     craftSugar()
  278.     harvestPumkins()
  279.     harvestEggs()
  280.     craftPumpkinPie()
  281. end --harvestPPSupplies
  282. -------------------------------------------------------
  283. -------------------------------------------------------
  284. --These are the strings for the Initial print
  285. --Prints instructions for the User
  286. sugar, pumpkins, eggs = 13, 14, 15
  287. print("Please make sure slots 13, 14, and 15 are empty before we start.")
  288. io.write("You want me to harvest your Pumpkin Pie supplies for an hour? (y/n)")
  289. answer1=io.read()
  290.    
  291. if answer1=="y" then
  292.     i = 0
  293.     while i < 13
  294.     do
  295.         fuelCheck()
  296.         print("Starting program...")
  297.         harvestPPSupplies(i)
  298.         print("Done harvesting I will try again in 5 minutes.")
  299.         i = i + 1
  300.         if redstone.getInput("left") then
  301.             i = 13
  302.         else
  303.             sleep(300)
  304.         end
  305.     end
  306. else
  307.     print("I will wait here until you need me.")
  308. end
  309.  
Add Comment
Please, Sign In to add comment