CelticCoder

QuarryShaft

Jan 1st, 2024 (edited)
297
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. os.loadAPI("predictSimpleQuarry.lua")
  2. os.loadAPI("userInput.lua")
  3. os.loadAPI("getTurtleFuel.lua")
  4. os.loadAPI("simpleQuarry.lua")
  5. os.loadAPI("turtleChest.lua")
  6. os.loadAPI("turtleForward.lua")
  7.  
  8. local function clearScreen()
  9.     term.clear()
  10.     term.setCursorPos(1, 1)
  11. end
  12.  
  13. function volumeCheck(width, length, depth)
  14.     tw = width
  15.     tl = length
  16.     td = depth
  17.     if tw == 0 then
  18.         tw = 1
  19.     end
  20.     if tl == 0 then
  21.         tl = 1
  22.     end
  23.     if td == 0 then
  24.         td = 1
  25.     end
  26.     volume = tw * tl * td
  27.     width = width - 1
  28.     print("Volume: " .. volume .. " blocks")
  29.    
  30.     if volume > 800 then
  31.         print("WARNING! Volume over 800")
  32.         print("Max is 1024 with Empty Inventory")
  33.         print("With Stacks of 64.")
  34.     end
  35.     choice = tonumber(userInput.getUserInput("Proceed? 1 for yes, 2 for no"))
  36.     if choice == 1 then
  37.         return false
  38.     else
  39.         return true
  40.     end
  41. end
  42.  
  43. function fuelCheck(width, length, depth, loop)
  44.     x = 0
  45.     while x < loop do
  46.         predictSimpleQuarry.predict(width, length, depth)
  47.         x = x + 1
  48.     end
  49.     fuelcost = predictSimpleQuarry.getFuelCost()
  50.     if fuelcost > turtle.getFuelLevel() then
  51.         getTurtleFuel.displayFuelInfo()
  52.         print("Quarry Fuel Cost = " .. fuelcost)
  53.         print("Fuel too Low to Start, Please Insert Buckets")
  54.         choice = tonumber(userInput.getUserInput("Type 1 to Refuel, Type 2 to Re-select Quarry"))
  55.         if choice == 1 then
  56.             turtleRefuel.refuelWithLava()
  57.             turtle.select(1)
  58.             if fuelcost > turtle.getFuelLevel() then
  59.                 print("Fuel Still too Low to Start, Terminating Program")
  60.                 os.sleep(3)
  61.             end
  62.         else
  63.             return false
  64.         end
  65.     end
  66.     return true
  67. end
  68.  
  69. function quarry(loop, choice)
  70.     if choice == "left" then
  71.         direction = 0
  72.     elseif choice == "right" then
  73.         direction = 1
  74.     else
  75.         os.exit(1)
  76.     end
  77.     width = 5
  78.     length = 5
  79.     depth = 27
  80.     volume = width * length * depth * loop + (length * loop)
  81.     width = width - 1
  82.     x = 0
  83.     while x < loop do
  84.         simpleQuarry.quarry(width, length, depth)
  85.         turtle.turnLeft()
  86.         turtleChest.insertAll()
  87.         turtle.turnRight()
  88.         x = x + 1
  89.         y = -2
  90.         if direction == 0 then
  91.             turtle.turnLeft()
  92.             turtle.turnLeft()
  93.         end
  94.         while y < width do
  95.             turtleForward.moveForward()
  96.             y = y + 1
  97.         end
  98.         if direction == 0 then
  99.             turtle.turnLeft()
  100.             turtle.turnLeft()
  101.         end
  102.     end
  103. end
  104.  
  105. function quarryGetDimensions(loop)
  106.     choice = 0
  107.     while choice ~= 1 and choice ~= 2 do
  108.         clearScreen()
  109.         print("Move forward or backwards after quarry?")
  110.         print("1 for Forward, 2 for Backwards\n")
  111.         choice = tonumber(read())
  112.         if choice == 2 then
  113.             direction = 0
  114.         elseif choice == 1 then
  115.             direction = 1
  116.         else
  117.             print("Incorrect Choice, Try again")
  118.             os.sleep(1)
  119.         end
  120.     end
  121.     check = true
  122.     while check do
  123.         clearScreen()
  124.         width = tonumber(userInput.getUserInput("Enter Length: "))
  125.         length = tonumber(userInput.getUserInput("Enter Width: "))
  126.         depth = tonumber(userInput.getUserInput("Enter Depth: "))
  127.         volume = width * length * depth * loop + (length * loop)
  128.         width = width - 1
  129.         check = not fuelCheck(width, length, depth, loop)
  130.         if not check then
  131.             check = volumeCheck(width, length, depth)
  132.         end
  133.     end
  134.     x = 0
  135.     while x < loop do
  136.         simpleQuarry.quarry(width, length, depth)
  137.         turtle.turnLeft()
  138.         turtleChest.insertAll()
  139.         turtle.turnRight()
  140.         x = x + 1
  141.         y = -2
  142.         if direction == 0 then
  143.             turtle.turnLeft()
  144.             turtle.turnLeft()
  145.         end
  146.         while y < width do
  147.             turtleForward.moveForward()
  148.             y = y + 1
  149.         end
  150.         if direction == 0 then
  151.             turtle.turnLeft()
  152.             turtle.turnLeft()
  153.         end
  154.     end
  155. end
Advertisement
Add Comment
Please, Sign In to add comment