sciencefreak74

turtle_guard

May 3rd, 2022
1,346
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.62 KB | None | 0 0
  1. os.loadAPI("betterTurtle")
  2. betterTurtle.retrieveLocation()
  3.  
  4. while true do
  5.     length = math.random(1,20)
  6.     i = 1
  7.     while i <= length do
  8.         i = i + 1
  9.         success = betterTurtle.forward()
  10.         turtle.attack()
  11.         if not success then
  12.             i = length + 1
  13.         end
  14.         position = betterTurtle.retrieveLocation()
  15.         x = position[1]
  16.         z = position[3]
  17.         if x > 10 or x < -10 or z > 10 or z < -10 then
  18.             betterTurtle.turnRight()
  19.             betterTurtle.turnRight()
  20.             betterTurtle.forward()
  21.             i = length + 1
  22.         end
  23.     end
  24.     turn = math.random(1,4)
  25.     i = 1
  26.     while i <= length do
  27.         i = i + 1
  28.         betterTurtle.turnRight()
  29.         turtle.attack()
  30.     end
  31. end
Advertisement
Add Comment
Please, Sign In to add comment