Advertisement
you_dont_say

Untitled

Mar 13th, 2021
1,233
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.67 KB | None | 0 0
  1. function right()
  2.   turtle.turnRight()
  3.   turtle.forward()
  4.   turtle.turnRight()
  5. end
  6.  
  7. function left()
  8.   turtle.turnLeft()
  9.   turtle.forward()
  10.   turtle.turnLeft()
  11. end
  12.  
  13. function move(area)
  14.   local totalarea = area*2
  15.   local lengthdetection = 0
  16.   local direction = 'right'
  17.  
  18.   for i = 1,totalarea do
  19.     turtle.forward()
  20.     lengthdetection =lengthdetection + 1
  21.     if lengthdetection == 5 then
  22.       if direction == 'right' then
  23.         direction = 'left'
  24.         right()
  25.       end
  26.       if direction == 'left'then
  27.         direction = 'right'
  28.         left()
  29.       end
  30.       lengthdetection = 0
  31.     end
  32.   end
  33. end
  34.  
  35.  
  36. write('Enter Area')
  37. area = read()
  38. move(area)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement