Klazam33

OrebAttacker

May 4th, 2021 (edited)
555
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 7.90 KB | None | 0 0
  1. os.loadAPI("kapi")
  2.  
  3.     function burnCoal()
  4.         local burnCoal = turtle.getItemCount(1)-1
  5.         turtle.select(1)
  6.         turtle.refuel(burnCoal)
  7.     end
  8.  
  9.  
  10. while true do
  11.     kapi.menu("I consume Orebs at my whims.\nPut coal in slot 1 to fuel my ire.\nPut the ignition key in slot 2.\nPut End Chest output in slot 3.\nYou have ten seconds to comply. If you're not ready, CTRL+T to stop.\n")
  12.     sleep(10)
  13.     kapi.printFuel()
  14.    
  15.     x = 0
  16.     while x == 0 do
  17.     if turtle.getFuelLevel() < 1000 then -- Check for fuel levels, if too low, will wait until fed.
  18.         print("please feed me... coal in slot 1... \nPress enter when I have food")
  19.           z = kapi.keyread()
  20.           if z == keys.enter then
  21.             print("nom, nom")
  22.             burnCoal()
  23.             kapi.printFuel()
  24.           else
  25.             print("Not valid input!")
  26.             sleep(2)
  27.           end
  28.     else
  29.         print("I am sated.")
  30.         x = 1
  31.     end
  32.     end
  33.    
  34.         while x == 1 do -- Checks for the necessary end chest in front of the turtle to start the process
  35.           turtle.select(3)  
  36.           if turtle.compare() == false then
  37.                 print("The Way is Shut. Place Ignition Chest in front of me.")
  38.                 sleep(30)
  39.                term.clearLine()
  40.           else
  41.              x = 0
  42.           end
  43.         end -- ending ignition check
  44.    
  45.       time = 10
  46.       while time > 0 do -- Countdown timer
  47.         sleep(1)
  48.         time = time-1
  49.         if time > 0 then
  50.             term.clear()
  51.             print("Make sure to place me on the bottom left corner of 5x5, on the very top, facing inwards. Ensure two blocks of air is between me and the corner of the 5x5 block under me. Place End Chest connected to the ritual in front of me when ready to ignite.\n\nSnoozing for " ..time.. " seconds.")
  52.         else
  53.             term.clear()
  54.             print("Attacking Oreb now")
  55.             sleep(2)
  56.         end
  57.       end -- ending countdown timer
  58.  
  59.       if turtle.detect() == true then -- Put key in ignition
  60.                 turtle.select(2)
  61.                 turtle.drop(1)
  62.       else
  63.                 print("Can't place inventory here! Terminating program.")
  64.                 break
  65.       end
  66.    
  67.     kickoff = 0
  68.  
  69.     while kickoff == 0 do
  70.      
  71.       print("Starting Cycle...")
  72.       turtle.select(1)
  73.       print("Down 2")
  74.       kapi.down(2)
  75.      
  76.       seriesStart = 1 -- Slice
  77.       series = 1
  78.       sideStart = 1 -- Side of Slice
  79.       side = 1
  80.       vertStart = 15 -- Initial vertical position (13)
  81.       vert = 15
  82.       horzStart = 5 -- Initial horzitional position (5)
  83.       horz = 5
  84.      
  85.      
  86.       while series < 9 do -- track cycles done
  87.  
  88.       while side < 5 do -- track sides done
  89.        
  90.       while horz > 0 do -- track forward distance
  91.         while vert > 0 do -- track up and down distance
  92.             if turtle.getItemCount(16) < 1 then
  93.                     vert = vert -1
  94.                     print("Mine 1 down, then move 1 down. \nCurrent position:"..vert)
  95.                     kapi.mine("d")
  96.                     kapi.down()
  97.             else
  98.                     kapi.endDumpUp(4)
  99.                     turtle.select(4)
  100.                     print("Dumping")
  101.                     turtle.select(1)
  102.             end
  103.             if turtle.getFuelLevel() < 1000 then -- Check for fuel levels, if too low, eats fuel.
  104.                     burnCoal()
  105.                     print("refuelling")
  106.                     kapi.printFuel()
  107.             else
  108.                     print("I'm sated.")
  109.                    
  110.             end
  111.         end --vert
  112.                
  113.         horz = horz-1
  114.         vert = vertStart
  115.         print("Going up "..vert.." blocks.")
  116.         kapi.up(vert)
  117.         print("Mining 1 forward then moving 1 forward.\nCurrent position:"..horz)
  118.         kapi.mine("f")
  119.         kapi.forward()
  120.        
  121.       end --horz
  122.         side = side+1
  123.         horz = horzStart-1
  124.         print("Going backwards 1, then, turning 1, mining 1 forward then moving 1 forward.")
  125.         kapi.turn("b")
  126.         kapi.forward()
  127.         kapi.turn("l")
  128.         kapi.mine("f")
  129.         kapi.forward()
  130.         print("On side:"..side)
  131.         kapi.printFuel()
  132.        
  133.       end -- side
  134.  
  135.       side = 1
  136.       series = series+1 -- Track cycles
  137.       print("Starting Series "..series)
  138.  
  139.         if series == 2 then
  140.             print("Set position")
  141.             kapi.turn("b")
  142.             kapi.forward(2)
  143.             kapi.turn("r")
  144.             kapi.forward()
  145.             kapi.turn("r")
  146.             kapi.down()
  147.            
  148.             vertStart = 14 -- Initial vertical position
  149.             vert = 14
  150.             horzStart = 7 -- Initial horzitional position
  151.             horz = 7
  152.                
  153.            
  154.         elseif series == 3 then
  155.             print("Set position")
  156.             kapi.turn("b")
  157.             kapi.forward(2)
  158.             kapi.turn("r")
  159.             kapi.forward()
  160.             kapi.turn("r")
  161.  
  162.             vertStart = 14 -- Initial vertical position
  163.             vert = 14
  164.             horzStart = 9 -- Initial horzitional position
  165.             horz = 9
  166.  
  167.         elseif series == 4 then
  168.             print("Set position")
  169.             kapi.turn("b")
  170.             kapi.forward(2)
  171.             kapi.turn("r")
  172.             kapi.forward()
  173.             kapi.turn("r")
  174.  
  175.             vertStart = 14 -- Initial vertical position
  176.             vert = 14
  177.             horzStart = 11 -- Initial horzitional position
  178.             horz = 11
  179.                    
  180.          elseif series == 5 then
  181.             print("Set position")
  182.             kapi.turn("b")
  183.             kapi.forward(2)
  184.             kapi.turn("r")
  185.             kapi.forward()
  186.             kapi.turn("r")
  187.             kapi.down()
  188.            
  189.             vertStart = 13 -- Initial vertical position
  190.             vert = 13
  191.             horzStart = 13 -- Initial horzitional position
  192.             horz = 13
  193.             burnCoal()
  194.                
  195.            
  196.         elseif series == 6 then
  197.             print("Set position")
  198.             kapi.turn("b")
  199.             kapi.forward(2)
  200.             kapi.turn("r")
  201.             kapi.forward()
  202.             kapi.turn("r")
  203.             kapi.down()
  204.  
  205.             vertStart = 12 -- Initial vertical position
  206.             vert = 12
  207.             horzStart = 15 -- Initial horzitional position
  208.             horz = 15
  209.  
  210.         elseif series == 7 then
  211.             print("Set position")
  212.             kapi.turn("b")
  213.             kapi.forward(2)
  214.             kapi.turn("r")
  215.             kapi.forward()
  216.             kapi.turn("r")
  217.            
  218.  
  219.             vertStart = 12 -- Initial vertical position
  220.             vert = 12
  221.             horzStart = 17 -- Initial horzitional position
  222.             horz = 17
  223.  
  224.         elseif series == 8 then
  225.             print("Set position")
  226.             kapi.turn("b")
  227.             kapi.forward(2)
  228.             kapi.turn("r")
  229.             kapi.forward()
  230.             kapi.turn("r")
  231.             kapi.down()
  232.  
  233.             vertStart = 11 -- Initial vertical position
  234.             vert = 11
  235.             horzStart = 19 -- Initial horzitional position
  236.             horz = 19
  237.                    
  238.         else
  239.             print("doneski")
  240.  
  241.         end
  242.  
  243.       end -- series
  244.  
  245.  
  246.       print("returning to origin") -- return to origin and dump stuff
  247.       kapi.turn("r")
  248.       kapi.forward(7)
  249.       kapi.turn("l")
  250.       kapi.forward(6)
  251.       kapi.up(6)
  252.       print("Ending Cycle...")
  253.       sleep(5)
  254.       kapi.endDumpUp(4)
  255.       burnCoal()
  256.        
  257.       if turtle.detect() == true then -- Taking key out of ignition
  258.                 turtle.select(2)
  259.                 turtle.suck(1)
  260.       else
  261.                 print("Can't find inventory here! Terminating program.")
  262.                 break
  263.       end -- Deignite
  264.      
  265.       time = 10800
  266.       while time > 0 do -- Countdown timer
  267.         sleep(1)
  268.         time = time-1
  269.         if time > 0 then
  270.             term.clear()
  271.             print("Make sure to place me on the bottom left corner of 5x5, on the very top, facing inwards. Ensure two blocks of air is between me and the nearest block under me. Place End Chest connected to the ritual in front of me when ready to ignite.\n\nSnoozing for " ..time.. " seconds.")
  272.         else
  273.             term.clear()
  274.             print("Attacking Oreb now")
  275.             sleep(2)
  276.         end
  277.       end -- ending countdown timer
  278.  
  279.       if turtle.detect() == true then -- Put key in ignition
  280.                 turtle.select(2)
  281.                 turtle.drop(1)
  282.       else
  283.                 print("Can't place inventory here! Terminating program.")
  284.                 break
  285.       end -- End the snooze cycle
  286.     end -- ending the kickoff
  287. end -- ending the while true do
Add Comment
Please, Sign In to add comment