MihaMi

Untitled

Jan 21st, 2021 (edited)
410
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local xPos = 0
  2. local yPos = 0
  3. local zPos = 0
  4.  
  5. local dir = 0
  6.  
  7.  
  8.  
  9. local function moveDown()
  10.     print("Moving down")
  11.     if turtle.down() then
  12.         yPos = yPos+1
  13.     else
  14.         print("Reason: ",turtle.down())
  15.         return false
  16.     end
  17.     print("Moved down. yPos: ",yPos)
  18.     return true
  19. end
  20.  
  21. local function moveUp()
  22.     print("Moving up")  
  23.     if turtle.up() then
  24.         yPos = yPos+1
  25.     else
  26.         print("Reason: ",turtle.up())
  27.         return false
  28.     end
  29.     print("Moved up. yPos: ",yPos)
  30.     return true
  31. end
  32.  
  33. local function left()
  34.     print("Turning left")
  35.     if turtle.turnLeft() then
  36.         dir = dir + 1
  37.         if dir == 4 then
  38.             dir = 0
  39.         end
  40.         print("Turned left. Dir: ",dir)
  41.     else
  42.         print("Reason: ",turtle.turnLeft())
  43.         return false
  44.     end
  45.     return true
  46. end
  47.  
  48. local function right()
  49.     print("Turning right")  
  50.     if turtle.turnRight() then     
  51.         dir = dir - 1
  52.         if dir == -1 then
  53.             dir = 3
  54.         end
  55.         print("Turned right. Dir: ",dir)
  56.     else
  57.         print("Reason: ",turtle.turnRight())
  58.         return false
  59.     end
  60.     return true
  61. end
  62.  
  63.  
  64.  
  65. local function goBack()
  66.     local oldXPos = xPos
  67.     local oldYPos = yPos
  68.     local oldZPos = zPos
  69.     local oldXDir = xDir
  70.     local oldZDir = zDir
  71. end
  72.  
  73.  
  74. local function test()
  75.     term.clear()
  76.     for i=0,1 do
  77.         moveUp()
  78.     end
  79.     sleep(5)
  80.     term.clear()
  81.  
  82.     for i=0,1 do
  83.         moveDown()
  84.     end
  85.     sleep(5)
  86.     term.clear()   
  87. end
  88.  
  89. test()
  90.  
RAW Paste Data