Advertisement
Guest User

digwrap.lua

a guest
Jul 15th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.89 KB | None | 0 0
  1. Position = {}
  2. Orientation = 0
  3.  
  4.  
  5. function init()
  6.     Position = {0, 0, 0}    
  7. end
  8.    
  9. function dig_front()
  10.     if turtle.detect() then
  11.         return turtle.dig()    
  12.     end
  13. end
  14.    
  15. function dig_up()
  16.     if turtle.detectUp() then
  17.         return turtle.digUp()
  18.     end
  19. end
  20.  
  21. function dig_down()
  22.     if turtle.detectDown() then
  23.         return turtle.digDown()
  24.     end
  25. end
  26.  
  27. function forward()
  28.     if turtle.forward() then
  29.         if orientation == 0 then
  30.             Position[0] = Position[0] + 1
  31.         elseif orientation == 2 then
  32.             Position[0] = Position[0] - 1
  33.         elseif orientation == 3 then
  34.             Position[1] = Position[1] + 1
  35.         elseif orientation == 4 then
  36.             Position[1] = Position[1] - 1
  37.         end
  38.        
  39.         return true    
  40.     else
  41.         return false
  42.     end    
  43. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement