Advertisement
Nokiyen

eventFlat2

May 2nd, 2014
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.54 KB | None | 0 0
  1. --[[
  2. ***********
  3. * event
  4. *
  5. **********
  6. ]]
  7.  
  8.  
  9.  
  10. -- get arguments.
  11.  
  12. --define functions.
  13. function dig(dir)
  14.  
  15. local currentDig = turtle.dig
  16. local currentDetect = turtle.detect
  17. if dir == 'up' then
  18. currentDig = turtle.digUp
  19. currentDetect = turtle.detectUp
  20. elseif dir == 'down' then
  21. currentDig = turtle.digDown
  22. currentDetect = turtle.detectDown
  23. end
  24.  
  25. local times = 0
  26. while currentDetect() do
  27. currentDig()
  28. times = times + 1
  29. if times == 15 then
  30. print("cant' dig!")
  31. exit() -- dare to cause error.
  32. break
  33. end
  34. sleep(1)
  35. end
  36.  
  37. end
  38.  
  39. function move(dir)
  40.  
  41. local currentAttack = turtle.attack
  42. local currentMove = turtle.forward
  43. if dir == 'up' then
  44. currentAttack = turtle.attackUp
  45. currentMove = turtle.up
  46. elseif dir == 'down' then
  47. currentAttack = turtle.attackDown
  48. currentMove = turtle.down
  49. end
  50.  
  51. local times = 0
  52. while currentMove() == false do
  53. currentAttack()
  54. times = times + 1
  55. if times == 30 then
  56. print("Can't move!")
  57. exit() -- dare to cause error.
  58. end
  59. end
  60.  
  61. end
  62.  
  63. function digSt(dist)
  64. for i=1, dist, 1 do
  65. dig('up')
  66. dig('down')
  67.  
  68. turtle.turnLeft()
  69. dig('front')
  70. turtle.turnRight()
  71. turtle.turnRight()
  72. dig('front')
  73.  
  74. turtle.turnLeft()
  75. dig('front')
  76. move('front')
  77. end
  78. end
  79.  
  80. function digE(dir, dist)
  81. for i=1, dist, 1 do
  82. dig('front')
  83. turtle.turnLeft()
  84. dig('front')
  85. turtle.turnLeft()
  86. dig('front')
  87. turtle.turnLeft()
  88. dig('front')
  89. turtle.turnLeft()
  90.  
  91. dig(dir)
  92. move(dir)
  93. end
  94. end
  95.  
  96. function dropStone()
  97. for i=2, 16, 1 do
  98. turtle.select(i)
  99. if turtle.compateTo(1) then
  100. turtle.drop()
  101. end
  102. end
  103. end
  104.  
  105. turtle.turnRight()
  106. dig('front')
  107. move('front')
  108. dig('front')
  109. move('front')
  110. dig('front')
  111. move('front')
  112. turtle.turnLeft()
  113. digSt(50)
  114.  
  115. turtle.turnRight()
  116. dig('front')
  117. move('front')
  118. dig('front')
  119. move('front')
  120. dig('front')
  121. move('front')
  122. turtle.turnRight()
  123. digSt(50)
  124.  
  125. turtle.turnLeft()
  126. dig('front')
  127. move('front')
  128. dig('front')
  129. move('front')
  130. dig('front')
  131. move('front')
  132. turtle.turnLeft()
  133. digSt(50)
  134.  
  135. turtle.turnRight()
  136. dig('front')
  137. move('front')
  138. dig('front')
  139. move('front')
  140. dig('front')
  141. move('front')
  142. turtle.turnRight()
  143. digSt(50)
  144.  
  145. turtle.turnRight()
  146. dig('front')
  147. move('front')
  148. dig('front')
  149. move('front')
  150. dig('front')
  151. move('front')
  152. dig('front')
  153. move('front')
  154. dig('front')
  155. move('front')
  156. dig('front')
  157. move('front')
  158. dig('front')
  159. move('front')
  160. dig('front')
  161. move('front')
  162. dig('front')
  163. move('front')
  164. dig('front')
  165. move('front')
  166. dig('front')
  167. move('front')
  168. dig('front')
  169. move('front')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement