Advertisement
rharris31415

Untitled

Mar 31st, 2015
239
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.84 KB | None | 0 0
  1. local pos = {0, 0, 0}
  2. local turn = 0
  3. local axis = 1
  4.  
  5. function left()
  6.   turtle.turnLeft()
  7.   turn = turn - 1
  8. end
  9.  
  10. function right()
  11.   turtle.turnRight()
  12.   turn = turn + 1
  13. end
  14.  
  15. function forward()
  16.   if not turtle.forward() then
  17.     print("There is something in front of me")
  18.   else
  19.     if turn % 4 == 0 or turn % 4 == 1 then
  20.       axis = 1
  21.     else
  22.       axis = -1
  23.     end
  24.     if turn % 4 == 1 or turn % 4 == 3 then
  25.       pos[1] = pos[1] + axis
  26.     else
  27.       pos[2] = pos[2] + axis
  28.     end
  29.   end
  30. end
  31.  
  32. function up()
  33.   if not turtle.up() then
  34.     print("There is something on top of me")
  35.   else
  36.     pos[3] = pos[3] + 1
  37.   end
  38. end
  39.  
  40. function down()
  41.   if not turtle.down() then
  42.     print("There is something underneath me")
  43.   else
  44.     pos[3] = pos[3] - 1
  45.   end
  46. end
  47.  
  48. if turtle.getFuelLevel() < 1 then
  49.   turtle.refuel()
  50. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement