Advertisement
Selim_042

follow

Jul 19th, 2014
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.51 KB | None | 0 0
  1. arg = {...}
  2. followRange = 3
  3. heightFollowRange = 2
  4. player = bladze420
  5.  
  6. sensor = peripheral.wrap("left")
  7.  
  8. function orient(pos)
  9.   while facing ~= pos do
  10.     turtle.turnRight()
  11.     if facing == 3 then
  12.       facing = 0
  13.     else
  14.       facing = facing + 1
  15.     end
  16.   end
  17.   if not turtle.forward() then
  18.     turtle.attack()
  19.     --turtle.dig()
  20.   end
  21. end
  22.  
  23. function checkBlocks(dir)
  24.   blocks = sensor.sonicScan()
  25.  
  26. end
  27.  
  28. --if arg[1] == int then
  29.   facing = arg[1] --0 is south, 1 is west, 2 is north, 3 is east
  30.   while true do
  31.     if turtle.getFuelLevel() <= 50 then
  32.       print("Fuel low, please refuel")
  33.       print("Fuel level: "..turtle.getFuelLevel())
  34.     end
  35.     data = sensor.getPlayerData(player)
  36.     if data.position.x <= -followRange then
  37.       orient(1)
  38.       --checkBlocks("-x")
  39.     end
  40.     if data.position.x >= followRange then
  41.       orient(3)
  42.       --checkBlocks("x")
  43.     end
  44.     if data.position.y <= -heightFollowRange then
  45.       if not turtle.down() then
  46.         --turtle.digDown()
  47.         turtle.attackDown()
  48.       end
  49.       --checkBlocks("-y")
  50.     end
  51.     if data.position.y >= heightFollowRange then
  52.       if not turtle.up() then
  53.         --turtle.digUp()
  54.         turtle.attackUp()
  55.       end
  56.       --checkBlocks("y")
  57.     end
  58.     if data.position.z <= -followRange then
  59.       orient(2)
  60.       --checkBlocks("-z")
  61.     end
  62.     if data.position.z >= followRange then
  63.       orient(0)
  64.       --checkBlocks("z")
  65.     end
  66.   end
  67. --else
  68.   --print("Usage: follow <orientation>")
  69. --end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement