lucas_csantos

GoTo

Nov 25th, 2012
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. local tArgs = {...}
  2. tx = tArgs[1]
  3. tx = tonumber(tx)
  4. ty = tArgs[2]
  5. ty = tonumber(ty)
  6. tz = tArgs[3]
  7. tz = tonumber(tz)
  8.  
  9. --Go to target Z position
  10. if z < tz then
  11. shell.run("setFacing","0")
  12. while z < tz do
  13. if not turtle.detect() then --check if there is a block ahead
  14. shell.run("forward")
  15. else
  16. if not turtle.detectUp() then --if there is a block ahead, check if there is a block above
  17. shell.run("up")
  18. end
  19. end
  20. end
  21.  
  22. else
  23.  
  24. if z > tz then
  25. shell.run("setFacing","2")
  26. while z > tz do
  27. if not turtle.detect() then
  28. shell.run("forward")
  29. else
  30. if not turtle.detectUp() then
  31. shell.run("up")
  32. end
  33. end
  34. end
  35. end
  36.  
  37. end
  38.  
  39. if x > tx then
  40. shell.run("setFacing","1")
  41. while x > tx do
  42. if not turtle.detect() then
  43. shell.run("forward")
  44. else
  45. if not turtle.detectUp() then
  46. shell.run("up")
  47. end
  48. end
  49. end
  50.  
  51. else
  52.  
  53. if x < tx then
  54. shell.run("setFacing","3")
  55. while x < tx do
  56. if not turtle.detect() then
  57. shell.run("forward")
  58. else
  59. if not turtle.detectUp() then
  60. shell.run("up")
  61. end
  62. end
  63. end
  64. end
  65.  
  66. end
  67.  
  68. while y > ty do shell.run("down") end
  69. while y < ty do shell.run("up") end
Advertisement
Add Comment
Please, Sign In to add comment