Advertisement
endertr1ks

Untitled

Jul 30th, 2014
240
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.04 KB | None | 0 0
  1. local x = 0
  2. local y = 0    
  3. local enderchest = 14
  4. local charbon  = 15
  5. local torche = 16
  6. local slot = 0
  7. local cycletorche = 0
  8. local xrecharge = -2
  9. local yrecharge = -2
  10. local savex = 0
  11. local savey = 0
  12. local saveo = 0
  13. local orientation = 0
  14. local nbtunnel = 0
  15. local lgtunnel = 0
  16. local validation = 0
  17. local avancement = 0
  18. local tunnelcourant = 0
  19.      
  20. function choix()
  21. term.clear()
  22. term.setCursorPos(1,1)
  23. print("bonjour ami mineur")
  24. write("longueur tunnel desiree : ")
  25. lgtunnel = tonumber(read())
  26. write("nombre de tunnel desiree : ")
  27. nbtunnel = tonumber(read())
  28. print("longueur des tunnels choisi : "..(lgtunnel))
  29. print("nombres de couloirs choisi : "..(nbtunnel))
  30. print("es-ce correct ? oui = 1    non = 0")
  31. validation = tonumber(read())
  32. end
  33.  
  34. function viragegauche()
  35. turtle.turnLeft()
  36. orientation = orientation - 1
  37. if orientation == -1 then
  38. orientation = 3
  39. end
  40. end
  41.  
  42. function  viragedroite()
  43. turtle.turnRight()
  44. orientation = orientation + 1
  45. if orientation == 4 then
  46. orientation = 0
  47. end
  48. end
  49.  
  50. function forward()
  51. turtle.dig()
  52. vidage()
  53. turtle.forward()
  54. turtle.digUp()
  55. vidage()
  56. refuel()
  57. if orientation == 0 then
  58. x = x + 1
  59. elseif orientation == 1 then
  60. y = y + 1
  61. elseif orientation == 2 then
  62. x = x - 1
  63. elseif orientation == 3 then
  64. y = y - 1
  65. end
  66. end
  67.  
  68.   function forwardrecharge()
  69.   turtle.dig()
  70. vidage()
  71. turtle.forward()
  72. vidage()
  73. refuel()
  74. if orientation == 0 then
  75. x = x + 1
  76. elseif orientation == 1 then
  77. y = y + 1
  78. elseif orientation == 2 then
  79. x = x - 1
  80. elseif orientation == 3 then
  81. y = y - 1
  82. end
  83. end
  84.  
  85. function back()
  86. turtle.back()
  87. refuel()
  88. if orientation == 0 then
  89. x = x - 1
  90. elseif orientation == 1 then
  91. y = y - 1
  92. elseif orientation == 2 then
  93. x = x + 1
  94. elseif orientation == 3 then
  95. y = y + 1  
  96. end
  97. end
  98.  
  99.  
  100. function recharge()
  101. savex = x
  102. savey = y
  103. saveo = orientation
  104. print("en cours de rechargement")
  105.  
  106. while y ~= 0 do
  107. while orientation ~= 3 do
  108. viragedroite()
  109. end
  110. forward()
  111. if turtle.getFuelLevel() < 50 then
  112. turtle.select(charbon)
  113. turtle.refuel(2)
  114. turtle.select(1)
  115. end
  116. end
  117.  
  118. while x ~= 0 do
  119. while orientation ~= 2 do
  120. viragegauche()
  121. end
  122. forwardrecharge()
  123. if turtle.getFuelLevel() < 50 then
  124. turtle.select(charbon)
  125. turtle.refuel(2)
  126. turtle.select(1)
  127. end
  128. end
  129.  
  130. turtle.select(charbon)
  131. turtle.suckDown()
  132. viragedroite()
  133. turtle.forward()
  134. turtle.select(torche)
  135. turtle.suckDown()
  136. turtle.select(1)
  137. print("rechargement termine, retour au travail")
  138.  
  139. while x ~= savex do
  140. while orientation ~= 0 do
  141. viragegauche()
  142. end
  143. forwardrecharge()
  144. end
  145.  
  146. while y ~= savey do
  147. while orientation ~= 1 do
  148. viragedroite()
  149. end
  150. forwardrecharge()
  151. end
  152.  
  153. while saveo ~= orientation do
  154. viragedroite()
  155. end
  156. savex = 0
  157. savey = 0
  158. saveo = 0
  159. end
  160.  
  161. function torchage()
  162. if turtle.getItemCount(torche) == 1 then
  163. recharge()
  164. end
  165. cycletorche = cycletorche + 1
  166. if cycletorche == 10 then
  167. turtle.dig()
  168. turtle.forward()
  169. turtle.digUp()
  170. turtle.back()
  171. turtle.select(torche)
  172. turtle.placeUp()
  173. turtle.select(1)
  174. cycletorche = 0
  175. end
  176. end
  177.    
  178. function refuel()
  179. if turtle.getItemCount(charbon) <= 4 then
  180. recharge()
  181. end
  182. if turtle.getFuelLevel() <= 50 then
  183. turtle.select(charbon)
  184. turtle.refuel(2)
  185. turtle.select(1)
  186. end
  187. end
  188.    
  189. function tunnel()
  190. while avancement ~= lgtunnel do
  191. forward()
  192. avancement = avancement + 1
  193. refuel()
  194. vidage()
  195. torchage()
  196. end
  197. avancement = 0
  198. sauttunnel()
  199. tunnelcourant = tunnelcourant + 1
  200. end
  201.    
  202. function sauttunnel()
  203. if orientation == 2 then
  204. turtle.dig()
  205. turtle.forward()
  206. turtle.digUp()
  207. viragegauche()
  208. forward()
  209. forward()
  210. turtle.dig()
  211. turtle.forward()
  212. turtle.digUp()
  213. turtle.back()
  214. turtle.select(torche)
  215. turtle.placeUp()
  216. turtle.select(1)
  217. forward()
  218. viragegauche()
  219. elseif orientation == 0 then
  220. viragedroite()
  221. forward()
  222. forward()
  223. turtle.dig()
  224. turtle.forward()
  225. turtle.digUp()
  226. turtle.back()
  227. turtle.select(torche)
  228. turtle.placeUp()
  229. turtle.select(1)
  230. forward()
  231. viragedroite()
  232. end
  233. end
  234.  
  235. function happybot()
  236. turtle.up()
  237. turtle. turnLeft()
  238. turtle. turnLeft()
  239. turtle. turnLeft()
  240. turtle. turnLeft()
  241. turtle.turnRight()
  242. turtle.turnRight()
  243. turtle.turnRight()
  244. turtle.turnRight()
  245. turtle.down()
  246. end
  247.    
  248. function retour()
  249. print("je vous emmerde, et je rentre a ma maison!! ")
  250. while x ~= 0 do
  251. while orientation ~= 2 do
  252. viragegauche()
  253. end
  254. forwardrecharge()
  255. if fuellevel < 50 then
  256. turtle.select(charbon)
  257. turtle.refuel(2)
  258. turtle.select(1)
  259. end
  260. end
  261. while y ~= 0 do
  262. while orientation ~= 3 do
  263. viragedroite()
  264. end
  265. forwardrecharge()
  266. end
  267. end
  268.    
  269. function vidage()
  270. if turtle.getItemCount(13) > 0 then
  271. turtle.dig()
  272. turtle.forward()
  273. turtle.digUp()
  274. turtle.back()
  275. turtle.select(enderchest)
  276. turtle.place()
  277. for slot=1,13 do
  278. turtle.select(slot)
  279. while turtle.getItemCount(slot)  > 0 do
  280. turtle.drop(turtle.getItemCount(slot))
  281. if turtle.getItemCount(slot) > 0 then
  282. sleep(1)
  283. end
  284. end
  285. end
  286. end
  287. turtle.select(enderchest)
  288. turtle.dig()
  289. turtle.select(1)
  290. end
  291.  
  292. while validation ~= 1 do
  293. choix()
  294. end
  295. term.clear()
  296. term.setCursorPos(1,1)
  297. print("tache aquise, travail en cours ")
  298.  
  299. while tunnelcourant ~= nbtunnel do
  300. tunnel()
  301. end
  302. retour()
  303. happybot()
  304. print("travail termine")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement