hevohevo

Untitled

Apr 28th, 2014
284
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.33 KB | None | 0 0
  1. local depth = 50
  2.  
  3. local height = 2
  4. local r = 3
  5.  
  6. function _detect(func)
  7.   while turtle.detect() do
  8.     if not func() then break end
  9.   end
  10.   while turtle.attack() do
  11.   end
  12. end
  13.  
  14. function dig()
  15.   _detect(turtle.dig)
  16.   turtle.turnRight()
  17.   _detect(turtle.dig)
  18.   turtle.turnLeft()
  19.   turtle.turnLeft()
  20.   _detect(turtle.dig)
  21.   turtle.turnRight()
  22.   _detect(turtle.digUp)
  23.   _detect(turtle.digDown)
  24. end
  25.  
  26. function fwd(n, flag_dig_all)
  27.   local _fwd = function()
  28.     repeat
  29.       turtle.attack()
  30.       turtle.dig()
  31.       turtle.suck()
  32.     until turtle.forward()
  33.     return true
  34.   end
  35.   for i=1,n do
  36.     if flag_dig_all then dig() end
  37.     _fwd()
  38.   end
  39. end
  40.  
  41. function up(n)
  42.   local _up = function()
  43.     repeat
  44.       turtle.digUp()
  45.       turtle.attackUp()
  46.       turtle.suckUp()
  47.     until turtle.up()
  48.     return true
  49.   end
  50.  
  51.   for i=1,n do
  52.     _up()
  53.   end
  54. end
  55.  
  56. function down(n)
  57.   local _down = function()
  58.   repeat
  59.     turtle.attackDown()
  60.     turtle.digDown()
  61.     turtle.suckDown()
  62.   until turtle.down()    
  63.   for i=1,n do
  64.     _down()
  65.   end
  66.   return true
  67. end
  68.  
  69. function backToHome()
  70.   _detect(turtle.dig)
  71.   repeat
  72.     turtle.dig()
  73.     turtle.attack()
  74.   until turtle.forward()
  75.   return true
  76. end
  77.  
  78. -- main
  79.  
  80. fwd(depth, true)
  81.  
  82. turtle.turnRight()
  83. turtle.turnRight()
  84.  
  85. down(3)
  86.  
  87. fwd(depth, true)
  88.  
  89. up(3)
Advertisement
Add Comment
Please, Sign In to add comment