TheKojent

Try API

Mar 28th, 2013
249
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.77 KB | None | 0 0
  1. --API for movement attempts in the directions a turtle can move.
  2.  
  3. function forward()
  4.   while not turtle.forward() do
  5.     if turtle.detect() then
  6.       if not turtle.dig() then
  7.         return false
  8.       end
  9.     elseif not turtle.attack() then
  10.       sleep(0.5)
  11.     end
  12.   end
  13.   return true
  14. end
  15.  
  16. function down()
  17.   while not turtle.down() do
  18.     if turtle.detectDown() then
  19.       if not turtle.digDown() then
  20.         return false
  21.       end
  22.     elseif not turtle.attackDown() then
  23.       sleep(0.5)
  24.     end
  25.   end
  26.   return true
  27. end
  28.  
  29. function up()
  30.   while not turtle.up() do
  31.     if turtle.detectUp() then
  32.       if not turtle.digUp() then
  33.         return false
  34.       end
  35.     elseif not turtle.attackUp() then
  36.       sleep(0.5)
  37.     end
  38.   end
  39.   return true
  40. end
Advertisement
Add Comment
Please, Sign In to add comment