Advertisement
OJPAE

Untitled

Jun 24th, 2019
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.70 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 resetS()
  222.  
  223. TS = larg
  224.  
  225. end
  226.  
  227. local function reset()
  228.  
  229. TF = long
  230. TB = long
  231. TS = larg
  232. TSB = larg
  233. sens = way
  234.  
  235. end
  236.  
  237.  
  238. local function sol()
  239.  
  240. repeat
  241.  
  242. repeat
  243.  
  244. if turtle.detect() then
  245.  
  246. turtle.dig()
  247.  
  248. end
  249.  
  250. if turtle.detectDown() then
  251.  
  252. turtle.digDown()
  253.  
  254. end
  255.  
  256. turtle.placeDown()
  257.  
  258. if turtle.forward() then
  259.  
  260. TF = TF - 1
  261.  
  262. end
  263.  
  264. if turtle.getItemCount(1)<10 then
  265.  
  266. turtle.select(2)
  267. if turtle.detectDown() then
  268. turtle.digDown()
  269. end
  270. turtle.placeDown()
  271. turtle.select(1)
  272. turtle.suckDown(53)
  273. turtle.select(2)
  274. turtle.digDown()
  275. turtle.select(1)
  276.  
  277. end
  278.  
  279. until TF == 1
  280.  
  281. turn()
  282. TS = TS - 1
  283. resetF()
  284.  
  285. until TF == 1 and TS == 0
  286.  
  287. end
  288.  
  289.  
  290. local function forwardM()
  291.  
  292. repeat
  293.  
  294. if turtle.detect() then
  295.  
  296. turtle.dig()
  297.  
  298. end
  299.  
  300. if turtle.detectDown() then
  301.  
  302. turtle.digDown()
  303.  
  304. end
  305.  
  306. turtle.placeDown()
  307.  
  308. if turtle.forward() then
  309.  
  310. TS = TS - 1
  311.  
  312. end
  313.  
  314. until TS == 0
  315.  
  316. end
  317.  
  318.  
  319.  
  320. local function start()
  321.  
  322. if mode == 0 then
  323.  
  324. repeat
  325.  
  326. repeat
  327.  
  328. forward()
  329. turn()
  330. resetF()
  331.  
  332. until TF == 1 and TS == 0
  333.  
  334. recall()
  335. haut = haut - 1
  336. reset()
  337.  
  338. until haut == 0
  339.  
  340. os.shutdown()
  341.  
  342.  
  343. end
  344.  
  345. if mode == 1 then
  346.  
  347. sol()
  348. recall()
  349. reset()
  350. haut = haut - 1
  351.  
  352. repeat
  353.  
  354. resetS()
  355. resetF()
  356. forward()
  357. if way == 0 then
  358. turtle.turnLeft()
  359. else
  360. turtle.turnRight()
  361. end
  362. forwardM()
  363. if way == 0 then
  364. turtle.turnLeft()
  365. else
  366. turtle.turnRight()
  367. end
  368. x = x + 1
  369. if x == 2 then
  370. if turtle.detectUp() then
  371. turtle.digUp()
  372. end
  373. turtle.up()
  374. haut = haut - 1
  375. x = 0
  376. end
  377.  
  378. until haut == 1
  379.  
  380. reset()
  381. sol()
  382. recall()
  383.  
  384. os.shutdown()
  385.  
  386. end
  387.  
  388. if mode == 2 then
  389.  
  390. if turtle.detectUp() then
  391.  
  392. turtle.digUp()
  393.  
  394. end
  395.  
  396. turtle.up()
  397.  
  398. repeat
  399.  
  400. resetS()
  401. resetF()
  402. forward()
  403. if way == 0 then
  404. turtle.turnLeft()
  405. else
  406. turtle.turnRight()
  407. end
  408. forwardM()
  409. if way == 0 then
  410. turtle.turnLeft()
  411. else
  412. turtle.turnRight()
  413. end
  414. x = x + 1
  415. if x == 2 then
  416. if turtle.detectUp() then
  417. turtle.digUp()
  418. end
  419. turtle.up()
  420. haut = haut - 1
  421. x = 0
  422. end
  423.  
  424. until haut == 0
  425.  
  426. os.shutdown()
  427.  
  428. end
  429.  
  430. end
  431.  
  432.  
  433. --Start--
  434. print("Entrez le mode de build :")
  435. print("0 = Cube plein // 1 = Cube vide // 2 = Murs")
  436. input = io.read()
  437. mode = tonumber(input)
  438. print("Entrez la longueur :")
  439. input2 = io.read()
  440. long = tonumber(input2)
  441. print("Entrez la largeur :")
  442. input3 = io.read()
  443. larg = tonumber(input3)
  444. print("Entrez la hauteur :")
  445. input5 = io.read()
  446. haut = tonumber(input5)
  447. print("Poser dans quelle direction ?")
  448. print("0 = Gauche // 1 = Droite")
  449. input4 = io.read()
  450. way = tonumber(input4)
  451. TF = long
  452. TB = long
  453. TS = larg
  454. TSB = larg
  455. sens = way
  456. turtle.select(1)
  457. if turtle.detectUp then
  458.  
  459. turtle.digUp()
  460.  
  461. end
  462. turtle.up()
  463. start()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement