Advertisement
OJPAE

Untitled

Jun 24th, 2019
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.05 KB | None | 0 0
  1. --Code Builder Block--
  2. local mode = 0
  3. local long = 0
  4. local larg = 0
  5. local haut = 0
  6. local way = 0
  7.  
  8.  
  9. local function forward()
  10.  
  11. repeat
  12.  
  13. if turtle.detect() then
  14.  
  15. turtle.dig()
  16.  
  17. end
  18.  
  19. if turtle.detectDown() then
  20.  
  21. turtle.digDown()
  22.  
  23. end
  24.  
  25. turtle.placeDown()
  26.  
  27. if turtle.forward() then
  28.  
  29. TF = TF - 1
  30.  
  31. end
  32.  
  33. if turtle.getItemCount(1)<10 then
  34.  
  35. turtle.select(2)
  36. if turtle.detectDown() then
  37. turtle.digDown()
  38. end
  39. turtle.placeDown()
  40. turtle.select(1)
  41. turtle.suckDown(53)
  42. turtle.select(2)
  43. turtle.digDown()
  44. turtle.select(1)
  45.  
  46. end
  47.  
  48. until TF == 1
  49.  
  50. TS = TS - 1
  51.  
  52. end
  53.  
  54. local function turn()
  55.  
  56. if sens == 0 then
  57.  
  58. turtle.turnLeft()
  59. if turtle.detectDown() then
  60.  
  61. turtle.digDown()
  62.  
  63. end
  64. turtle.placeDown()
  65. turtle.dig()
  66. turtle.forward()
  67. if turtle.detectDown() then
  68.  
  69. turtle.digDown()
  70.  
  71. end
  72.  
  73. turtle.turnLeft()
  74. sens = 1
  75.  
  76. else
  77.  
  78. turtle.turnRight()
  79. if turtle.detectDown() then
  80.  
  81. turtle.digDown()
  82.  
  83. end
  84. turtle.placeDown()
  85. turtle.dig()
  86. turtle.forward()
  87. if turtle.detectDown() then
  88.  
  89. turtle.digDown()
  90.  
  91. end
  92. turtle.turnRight()
  93. sens = 0
  94.  
  95. end
  96. end
  97.  
  98.  
  99. local function recall()
  100.  
  101. if way == 0 and sens == 1 then
  102.  
  103. turtle.turnLeft()
  104. repeat
  105.  
  106. turtle.forward()
  107. TSB = TSB - 1
  108.  
  109. until TSB == 0
  110.  
  111. turtle.turnRight()
  112.  
  113. repeat
  114.  
  115. turtle.forward()
  116. TB = TB - 1
  117.  
  118. until TB == 1
  119.  
  120. turtle.turnLeft()
  121. turtle.turnLeft()
  122.  
  123. if turtle.detectUp() then
  124.  
  125. turtle.digUp()
  126.  
  127. end
  128.  
  129. turtle.up()
  130.  
  131. end
  132.  
  133. if way == 0 and sens == 0 then
  134.  
  135. turtle.turnRight()
  136. repeat
  137.  
  138. turtle.forward()
  139. TSB = TSB - 1
  140.  
  141. until TSB == 0
  142.  
  143. turtle.turnLeft()
  144.  
  145. if turtle.detectUp() then
  146.  
  147. turtle.digUp()
  148.  
  149. end
  150.  
  151. turtle.up()
  152.  
  153. end
  154.  
  155. if way == 1 and sens == 0 then
  156.  
  157. turtle.turnRight()
  158. repeat
  159.  
  160. turtle.forward()
  161. TSB = TSB - 1
  162.  
  163. until TSB == 0
  164.  
  165. turtle.turnLeft()
  166. repeat
  167.  
  168. turtle.forward()
  169. TB = TB - 1
  170.  
  171. until TB == 1
  172.  
  173. turtle.turnRight()
  174. turtle.turnRight()
  175.  
  176. if turtle.detectUp() then
  177.  
  178. turtle.digUp()
  179.  
  180. end
  181.  
  182. turtle.up()
  183.  
  184. end
  185.  
  186. if way == 1 and sens == 1 then
  187.  
  188. turtle.turnLeft()
  189. repeat
  190.  
  191. turtle.forward()
  192. TSB = TSB - 1
  193.  
  194. until TSB == 0
  195.  
  196. turtle.turnRight()
  197.  
  198. if turtle.detectUp() then
  199.  
  200. turtle.digUp()
  201.  
  202. end
  203.  
  204. turtle.up()
  205.  
  206. end
  207.  
  208. end
  209.  
  210. local function resetF()
  211.  
  212. if TS ~= 0 then
  213.  
  214. TF = long
  215.  
  216. end
  217.  
  218. end
  219.  
  220. local function resetS()
  221.  
  222. TS = larg
  223.  
  224. end
  225.  
  226. local function reset()
  227.  
  228. TF = long
  229. TB = long
  230. TS = larg
  231. TSB = larg
  232. sens = way
  233.  
  234. end
  235.  
  236.  
  237. local function sol()
  238.  
  239. repeat
  240.  
  241. repeat
  242.  
  243. if turtle.detect() then
  244.  
  245. turtle.dig()
  246.  
  247. end
  248.  
  249. if turtle.detectDown() then
  250.  
  251. turtle.digDown()
  252.  
  253. end
  254.  
  255. turtle.placeDown()
  256.  
  257. if turtle.forward() then
  258.  
  259. TF = TF - 1
  260.  
  261. end
  262.  
  263. if turtle.getItemCount(1)<10 then
  264.  
  265. turtle.select(2)
  266. if turtle.detectDown() then
  267. turtle.digDown()
  268. end
  269. turtle.placeDown()
  270. turtle.select(1)
  271. turtle.suckDown(53)
  272. turtle.select(2)
  273. turtle.digDown()
  274. turtle.select(1)
  275.  
  276. end
  277.  
  278. until TF == 1
  279.  
  280. turn()
  281. TS = TS - 1
  282. resetF()
  283.  
  284. until TF == 1 and TS == 0
  285.  
  286. end
  287.  
  288.  
  289. local function forwardM()
  290.  
  291. repeat
  292.  
  293. if turtle.detect() then
  294.  
  295. turtle.dig()
  296.  
  297. end
  298.  
  299. if turtle.detectDown() then
  300.  
  301. turtle.digDown()
  302.  
  303. end
  304.  
  305. turtle.placeDown()
  306.  
  307. if turtle.forward() then
  308.  
  309. TS = TS - 1
  310.  
  311. end
  312.  
  313. until TS == 0
  314.  
  315. end
  316.  
  317. local function start()
  318.  
  319. if mode == 0 then
  320.  
  321. repeat
  322.  
  323. repeat
  324.  
  325. forward()
  326. turn()
  327. resetF()
  328.  
  329. until TF == 1 and TS == 0
  330.  
  331. recall()
  332. haut = haut - 1
  333. reset()
  334.  
  335. until haut == 0
  336.  
  337. os.shutdown()
  338.  
  339.  
  340. end
  341.  
  342. if mode == 1 then
  343.  
  344. sol()
  345. recall()
  346. reset()
  347. haut = haut - 1
  348.  
  349. repeat
  350.  
  351. resetS()
  352. resetF()
  353. forward()
  354. if way == 0 then
  355. turtle.turnLeft()
  356. else
  357. turtle.turnRight()
  358. end
  359. forwardM()
  360. if way == 0 then
  361. turtle.turnLeft()
  362. else
  363. turtle.turnRight()
  364. end
  365. haut = haut - 1
  366.  
  367. until haut == 1 --A tester--
  368.  
  369. --Place pour le plafond--
  370.  
  371. os.shutdown()
  372.  
  373. end
  374.  
  375. if mode == 2 then
  376.  
  377.  
  378.  
  379. end
  380.  
  381. end
  382.  
  383.  
  384. --Start--
  385. print("Entrez le mode de build :")
  386. print("0 = Cube plein // 1 = Cube vide // 2 = Murs")
  387. input = io.read()
  388. mode = tonumber(input)
  389. print("Entrez la longueur :")
  390. input2 = io.read()
  391. long = tonumber(input2)
  392. print("Entrez la largeur :")
  393. input3 = io.read()
  394. larg = tonumber(input3)
  395. print("Entrez la hauteur :")
  396. input5 = io.read()
  397. haut = tonumber(input5)
  398. print("Poser dans quelle direction ?")
  399. print("0 = Gauche // 1 = Droite")
  400. input4 = io.read()
  401. way = tonumber(input4)
  402. TF = long
  403. TB = long
  404. TS = larg
  405. TSB = larg
  406. sens = way
  407. turtle.select(1)
  408. if turtle.detectUp then
  409.  
  410. turtle.digUp()
  411.  
  412. end
  413. turtle.up()
  414. start()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement