Advertisement
OJPAE

Untitled

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