Advertisement
Leo_Verto

digTShape

May 12th, 2016
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.51 KB | None | 0 0
  1. local t = turtle
  2.  
  3. function detectGravel()
  4.     while t.detect() == true do
  5.         t.dig()
  6.     end
  7. end
  8.  
  9. -- Assumes starting on bottom
  10. function digThreeByH(height, alreadyInside)
  11.     if alreadyInside == false then
  12.         t.dig()
  13.         detectGravel()
  14.         t.forward()
  15.     end
  16.     t.turnLeft()
  17.     for i=1, height do
  18.         t.dig()
  19.         if i < height then
  20.             t.digUp()
  21.             t.up()
  22.         end
  23.     end
  24.     t.turnRight()
  25.     t.turnRight()
  26.     t.dig()
  27.     for i=1, height-1 do
  28.         t.down()
  29.         t.dig()
  30.     end
  31.     detectGravel()
  32.     t.turnLeft()
  33.     t.turnLeft()
  34.     detectGravel()
  35.     t.turnRight()
  36. end
  37.  
  38. function digTunnel(len, height, alreadyInside)
  39.     for i=1, len do
  40.         if alreadyInside == true and i == 1 then
  41.             digThreeByH(height, true)
  42.         else
  43.             digThreeByH(height, false)
  44.         end
  45.     end
  46. end
  47.  
  48. function digTShape(baseLen, baseHeight, armLen, armHeight, alreadyInside)
  49.     digTunnel(baseLen, baseHeight, alreadyInside)
  50.     for i=1, 2 do
  51.         t.dig()
  52.         detectGravel()
  53.         t.forward()
  54.     end
  55.     t.turnRight()
  56.     for i=1, math.floor(armLen/2) do
  57.         t.dig()
  58.         detectGravel()
  59.         t.forward()
  60.     end
  61.     t.turnLeft()
  62.     t.turnLeft()
  63.     digTunnel(armLen, armHeight, true)
  64.     t.turnLeft()
  65.     t.turnLeft()
  66.     for i=1, math.floor(armLen/2) do
  67.         t.forward()
  68.     end
  69.     t.turnRight()
  70.     for i=1, baseLen+1 do
  71.         t.forward()
  72.     end
  73. end
  74.  
  75. digTShape(9,3,15,4, true)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement