non_dual_being

cave 2.0

Jul 9th, 2018
38
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.82 KB | None | 0 0
  1. function checkFuel()
  2.  
  3. currentFuel = turtle.getFuelLevel()
  4. currentSlot = turtle.getSelectedSlot()
  5.  
  6. if turtle.getFuelLevel() < 1 then
  7.   for slot = 1,16 do
  8.     if turtle.refuel() then
  9.       return true, "Fueled"
  10.         elseif slot == 16 then
  11.           return false, "No fuel left"
  12.           end
  13.        end
  14.     else
  15.       print("there is still "..currentFuel.." Fuel left")
  16.       return false
  17.   end
  18. end    
  19.  
  20. checkFuel()
  21.  
  22. function askLenght()
  23.  
  24. print("Choose the lenght of the cave")
  25.  
  26. term.write("enter a number between 1-10: ")
  27. caveLenght = tonumber(read())
  28.  
  29. if caveLenght == nil or caveLenght == string then
  30.   print("Please enter a valid value")
  31.   askLenght()
  32.  
  33. elseif caveLenght < 1 or caveLenght > 10 then
  34.     print("Number must be between 1-10")
  35.     askLenght()
  36. else
  37.   print("Cavelenght = "..caveLenght)
  38.   end
  39.  end
  40.  
  41. function askWide()
  42.  
  43. print("Choose the Wide of the cave")
  44.  
  45. term.write("enter a number between 1-10: ")
  46. caveWide = tonumber(read())
  47.  
  48. if caveWide == nil or caveWide == string then
  49.   print("Please enter a valid value")
  50.   askWide()
  51.  
  52. elseif caveWide < 1 or caveWide > 10 then
  53.     print("Number must be between 1-10")
  54.     askWide()
  55. else
  56.   print("CaveWide = "..caveWide)
  57.   end
  58.  end
  59.  
  60.  
  61. function askDepth()
  62.  
  63. print("Choose the depth of the cave")
  64.  
  65. term.write("enter a number between 1-10: ")
  66. caveDepth = tonumber(read())
  67.  
  68. if caveDepth == nil or caveDepth == string then
  69.   print("Please enter a valid value")
  70.   askDepth()
  71.  
  72.  
  73. elseif caveDepth < 1 or caveDepth > 10 then
  74.     print("Number must be between 1-10")
  75.     askDepth()
  76.  
  77.  
  78. else  print("Cavedepth = "..caveDepth)
  79.   end
  80.  end
  81.  
  82. function cave()
  83. checkFuel()
  84.  print("Making a cave "..caveLenght.." long "..caveWide.." wide "..caveDepth.." deep ")
  85.  
  86. for depth = 1, caveDepth do
  87.     turtle.digDown()
  88.     turtle.down()
  89.     checkFuel()
  90.  
  91. for wide = 1, caveWide do
  92.  
  93.     for lenght = 1, caveLenght do
  94.         turtle.dig()
  95.         turtle.forward()
  96.     end
  97.  
  98. if wide %2 == 0 and wide < caveWide then
  99.   turtle.turnRight()
  100.   turtle.dig()
  101.   turtle.forward()
  102.   turtle.turnRight()
  103. elseif wide %2 ~= 0 and wide < caveWide then
  104.   turtle.turnLeft()
  105.   turtle.dig()
  106.   turtle.forward()
  107.   turtle.turnLeft()
  108.   end
  109. end
  110.    
  111. if caveWide % 2 == 0 then  
  112.   turtle.turnLeft()
  113.     for backWideeven = 1, caveWide do
  114.       turtle.forward()
  115.       end
  116.   turtle.turnLeft()
  117.  
  118. elseif caveWide == 1 then
  119.  
  120.   for backoneLenght = 1, caveLenght() do
  121.     turtle.back()
  122.     end
  123.    
  124.  
  125.  elseif caveWide % 2 ~= 0 then
  126.     for backLenght = 1,caveLenght do
  127.       turtle.back()
  128.     end
  129.  
  130.     turtle.turnRight()
  131.  
  132.     for backWide = 1,caveWide do
  133.       turtle.forward()
  134.       end
  135.  
  136.     turtle.turnLeft()
  137. end
  138.  
  139.  
  140. if depth == caveDepth then
  141.   for backup = 1, caveDepth do
  142.     turtle.up()
  143.     end
  144.   end
  145. end
  146. end
  147.  
  148. askLenght()
  149. askWide()
  150. askDepth()
  151.     cave()
Add Comment
Please, Sign In to add comment