Advertisement
mDiyo

turtlerotate

Dec 1st, 2013
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.65 KB | None | 0 0
  1. local tArgs = {...}
  2. local rotation = tArgs[1]
  3. if rotation == nil then
  4.   print("Usage: rotate <amount>")
  5.   return -1
  6. end
  7.  
  8. rotation = tonumber(rotation)
  9. local direction
  10. if rotation == 0 then
  11.   print ("Rotating nowhere")
  12.   return 0
  13. elseif rotation > 0 then
  14.   direction = "right "
  15. elseif rotation < 0 then
  16.   direction = "left "
  17. end
  18. print("Rotating ", direction, rotation, " times")
  19. rotate(rotation)
  20.  
  21. function rotate(arg)
  22.   if arg < 0 then
  23.     rotation = -arg
  24.     for r = 0, rotation-1, 1 do
  25.       turtle.turnLeft()
  26.     end
  27.   elseif arg > 0 then
  28.     rotation = arg
  29.     for r = 0, rotation-1, 1 do
  30.       turtle.turnRight()
  31.     end
  32.   end
  33. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement