Advertisement
CelticCoder

predictSimpleQuarry

Nov 13th, 2023 (edited)
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- Quarry Dimension Input and Mining Program
  2. fuelcost = 0
  3. -- Function to ask the user for input
  4. function getUserInput(prompt)
  5.   write(prompt .. ": ")
  6.   return read()
  7. end
  8.  
  9. -- Function to Mine to Depth
  10. function mineDepth()
  11.   for i = 1, depth do
  12.     fuelcost = fuelcost + 1
  13.   end
  14.   for j = 1, depth do
  15.     fuelcost = fuelcost + 1
  16.   end
  17. end
  18.  
  19. -- Function to mine a layer
  20. function mine(width, length)
  21.   for i = 1, length do
  22.     for j = 1, width do
  23.       mineDepth()
  24.       fuelcost = fuelcost + 1
  25.     end
  26.     if i < length then
  27.       if i % 2 == 1 then
  28.         mineDepth()
  29.         fuelcost = fuelcost + 1
  30.       else
  31.         mineDepth()
  32.         fuelcost = fuelcost + 1
  33.       end
  34.     end
  35.   end
  36. end
  37.  
  38. -- Ask the user for dimensions
  39. choice = 0
  40. while choice ~= 1 do
  41.     print("Note DO NOT MINE PAST LEVEL -56!!!")
  42.     width = tonumber(getUserInput("Enter the width"))
  43.     length = tonumber(getUserInput("Enter the length"))
  44.     depth = tonumber(getUserInput("Enter the depth"))
  45.     width = width - 1
  46.  
  47.     -- Calculate and display the volume
  48.     volume = width * length * depth
  49.     print("The quarry will have a volume of " .. volume .. " cubic blocks.")
  50.     if volume < 800 then
  51.         print("Proceed?")
  52.         choice = tonumber(getUserInput("Refuel = 2, Yes = 1, No = 0"))
  53.     elseif volume >= 800 then
  54.         print("WARNING volume is over 800 (max is 1000)!!!!!")
  55.         print("Proceed?")
  56.         choice = tonumber(getUserInput("Refuel = 2, Yes = 1, No = 0"))
  57.     end
  58.     if choice == 2 then
  59.         fake = tonumber(getUserInput("Please insert Buckets, Press Any Number to Continue..."))
  60.         os.loadAPI("turtleRefuel")
  61.     end
  62. end
  63. size = {width, length, depth}
  64. -- Excavate
  65. fuelcost = fuelcost + 1
  66. mine(width, length)
  67. mineDepth()
  68.  
  69. -- Return to Start
  70. if length % 2 == 1 then
  71.   for i = 1, width do
  72.     fuelcost = fuelcost + 1
  73.   end
  74. end
  75. for j = 2, length do
  76.     fuelcost = fuelcost + 1
  77. end
  78. fuelcost = fuelcost + 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement