Advertisement
Susceptance

rotate

Apr 25th, 2022
816
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.40 KB | None | 0 0
  1. dirTable = {{0, 1, 2, -1}, {-1, 0, 1, 2}, {2, -1, 0, 1}, {1, 2, -1, 0}}
  2.  
  3. function faceDir(dir, from)
  4.     print("rotating to " .. dir .. " from " .. from)
  5.     turn = dirTable[from][dir]
  6.     turnABS = math.abs(turn)
  7.  
  8.     if turn == 0 then
  9.         return
  10.     end
  11.    
  12.     if turn > 0 then
  13.         for i=1, turnABS do
  14.             turtle.turnRight()
  15.         end
  16.     else
  17.         for i=1, turnABS do
  18.             turtle.turnLeft()
  19.         end
  20.     end
  21.     return dir
  22. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement