Advertisement
OJPAE

Untitled

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