Sivarias

CC_turtle_L-tunnel

Oct 10th, 2013
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.26 KB | None | 0 0
  1. --L-tunnel
  2. --This code will create a tunnel directly down and then in straight across in the direction it is facing, placing whatever is in slot one along the way, if it runs out of items in slot one, it moves to slot two, then slot three.. etc.
  3. print("What's my y-coordinate boss?")
  4. yi=read()
  5. print("What's my goal y-coordinate boss?")
  6. yf=read()
  7. print("Am I facing North/South/East/West? (N/S/E/W)")
  8. dir=read()
  9. print("What's my coordinate in the direction I'm facing?")
  10. xi=read()
  11. print("What's my goal coordinate in the direction I'm facing?")
  12. xf=read()
  13. z=1
  14. deltay=yi-yf
  15. for k=1, deltay do
  16. t.down()
  17. turtle.select(z)
  18. turtle.placeUp()
  19. if turtle.getItemCount(z)==0 then
  20. z=z+1
  21. end
  22. end
  23. deltax=math.abs(xi-xf)
  24. if dir=="N" or dir=="W" then
  25. for j=1, deltax do
  26. t.forward()
  27. turtle.select(z)
  28. t.right()
  29. t.right()
  30. turtle.place()
  31. t.right()
  32. t.right()
  33. if turtle.getItemCount(z)==0 then
  34. z=z+1
  35. end
  36. end
  37. end
  38. deltax=math.abs(xi-xf)
  39. if dir=="S" or dir=="E" then
  40. for j=1, deltax do
  41. t.forward()
  42. turtle.select(z)
  43. t.right()
  44. t.right()
  45. turtle.place()
  46. t.right()
  47. t.right()
  48. if turtle.getItemCount(z)==0 then
  49. z=z+1
  50. end
  51. end
  52. end
  53. modem.transmit(channel, 128, "Minion "..os.getComputerLabel().." has finished L-tunnel")
Advertisement
Add Comment
Please, Sign In to add comment