Advertisement
Inksaver

Turn Left/Right Commands

Apr 5th, 2020
380
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.56 KB | None | 0 0
  1. --[[
  2.     Template for 2 commands l.lua and r.lua
  3.     Use: r 3    turn right 2x
  4.     Use: l 3    turn left 3x
  5. ]]
  6. args = {...}
  7.  
  8. function main()
  9.     local numTurns = 0
  10.  
  11.     if args[1] ~= nil then
  12.         for i = 1, args[1], 1 do
  13.             -- if turtle.turnRight() then --r.lua
  14.             if turtle.turnLeft() then -- l.lua
  15.                 numTurns = numTurns + 1
  16.             end
  17.         end
  18.     else
  19.         -- if turtle.turnRight() then -- r.lua
  20.         if turtle.turnLeft() then -- l.lua
  21.             numTurns = 1
  22.         end
  23.     end
  24.     -- print("Turned Right "..numTurns.." times") -- r.lua
  25.     print("Turned Left "..numTurns.." times") -- l.lua
  26. end
  27.  
  28. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement