Advertisement
chopstyix

Untitled

Nov 12th, 2014
235
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.26 KB | None | 0 0
  1. -- ____ ____ _ _ ____ _ _ ____ ____ ____ ____
  2. -- [__ |___ | | |___ |\ | [__ |___ |__| [__ ____ ____ ____ ___ ____ __ _ ___ ____ ____
  3. -- ___] |___ \/ |___ | \| ___] |___ | | ___] |___ [__] |--< |--' |--| | \| |__> |___ [__]
  4. --
  5. --
  6. -- NOTES :
  7. -- This program must achieve the following.
  8. -- 1) Maintain the ability to dig a straight tunnel without fail.
  9. -- 2) Lighting the tunnel in order on maintain a safe work environment.
  10. -- 3) Return to a drop off point when the turtle detects a full load.
  11. --
  12.  
  13. -- VARIABLES --
  14. interval = 100 -- User input.
  15. loop = 0
  16. turtleDetect = turtle.detect()
  17. turtleDirection = 1 -- 1 is forward; 0 is left; 2 is right.
  18. turtlePosition = 0 -- 0 is defined as lower position whereas 1 is defined as the higher position.
  19.  
  20. -- FUNCTIONS --
  21. function checkInventory(x)
  22. turtle.select(16)
  23. if (turtle.getItemCount() > 0) then
  24. if (turtleDirection == 0) then
  25. turtle.turnLeft()
  26. elseif (turtleDirection == 1) then
  27. turtle.turnLeft()
  28. turtle.turnLeft()
  29. elseif (turtleDirection == 2) then
  30. turtle.turnRight()
  31. end
  32. for i=0,x do
  33. turtle.forward()
  34. end
  35. turtle.turnLeft()
  36. turtle.turnLeft()
  37. exit()
  38. else
  39. turtle.select(1)
  40. end
  41. end
  42.  
  43. function turtleDig(x)
  44. turtle.dig()
  45. checkInventory(x)
  46. sleep(.15)
  47. if (turtleDetect == true) then
  48. turtle.dig()
  49. end
  50. end
  51.  
  52. function turtleDigRow(x)
  53. turtle.turnRight()
  54. turtleDirection = 2
  55. turtleDig(x)
  56. turtle.turnLeft()
  57. turtleDirection = 1
  58. turtleDig(x)
  59. turtle.turnLeft()
  60. turtleDirection = 0
  61. turtleDig(x)
  62. turtle.turnRight()
  63. turtleDirection = 1
  64. end
  65.  
  66. function turtleDigFunction(x)
  67. if (turtlePosition == 0) then
  68. turtleDigRow(x)
  69. turtle.digUp()
  70. turtle.up()
  71. turtlePosition = 1
  72. elseif (turtlePosition == 1) then
  73. turtleDigRow(x)
  74. turtle.digUp()
  75. turtle.up()
  76. turtlePosition = 2
  77. elseif (turtlePosition == 2) then
  78. turtleDigRow(x)
  79. turtle.forward()
  80. turtle.digDown()
  81. turtle.down()
  82. turtle.digDown()
  83. turtle.down()
  84. turtlePosition = 0
  85. end
  86. end
  87.  
  88. -- // MAIN SCRIPT //
  89. while (loop < interval) do
  90. turtleDigFunction(loop)
  91. loop = loop + 1
  92. end
  93. turtle.turnRight()
  94. turtle.turnRight()
  95. for i=0, interval do
  96. turtle.forward()
  97. turtle.turnRight()
  98. turtle.turnRight()
  99. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement