Advertisement
MrTurtle

Room Clearing/Digging Turtle

Jun 3rd, 2014
265
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.71 KB | None | 0 0
  1. print("Loading Robust Turtle API...")
  2. local load = os.loadAPI("t")
  3. if load then
  4.   print("Robust Turtle API loaded.")
  5. else
  6.  print("Robust Turtle API not found in the root directory with filename t")
  7.  print("Attempting to download as t from pastebin...")
  8.  os.sleep(1)
  9.  local response = http.get("http://pastebin.com/raw.php?i= e0UksEtT")
  10.  if response then
  11.     print("Great Success.")    
  12.     local data = response.readAll()
  13.     response.close()
  14.     local file = fs.open("t", "w")
  15.     file.write(data)
  16.     file.close()
  17.     print("Downloaded as t")
  18.     load = os.loadAPI("t")
  19.     if load then
  20.      print("Robust Turtle API installed & loaded.")
  21.     end
  22.  else
  23.     print( "Download Failed. Please Install Manually." )
  24.     return
  25.  end
  26. end
  27.  
  28.  
  29. --room clearer
  30.  
  31. function layer(l,w)
  32.     local alternate = "right"
  33.     for i =1, w do
  34.         t.forward(l)
  35.         if alternate == "right" and i~=w then
  36.             t.right()
  37.             t.forward()
  38.             t.right()
  39.             alternate = "left"
  40.         elseif alternate == "left" and i~=w then
  41.             t.left()
  42.             t.forward()
  43.             t.left()
  44.             alternate = "right"
  45.         elseif alternate == "left" and i==w then
  46.             t.right()
  47.             t.forward(w-1)
  48.             t.right()
  49.         elseif alternate == "right" and i==w then
  50.             t.strafeLeft(w-1)
  51.             t.back(l)
  52.         end
  53.     end
  54. end
  55.  
  56. term.clear()
  57. term.setCursorPos(1,1)
  58. print("Room Clearer Turtle. ")
  59. print("length?")
  60. local length = (t.readNum()-1)
  61. print("width?")
  62. local width = t.readNum()
  63. print("height of room?")
  64. local height = t.readNum()
  65.  
  66.  
  67. t.forward()
  68. t.strafeLeft(width/2)
  69. for i=1, height do
  70.   layer(length,width)
  71.   --does not move up after digging last layer
  72.   if i ~= height then
  73.     t.up()
  74.   end
  75. end
  76. t.sDown(height-1)
  77. t.sStrafeRight(width/2)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement