Advertisement
OJPAE

Untitled

Jun 24th, 2019
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.21 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. local function start()
  319.  
  320. if mode == 0 then
  321.  
  322. repeat
  323.  
  324. repeat
  325.  
  326. forward()
  327. turn()
  328. resetF()
  329.  
  330. until TF == 1 and TS == 0
  331.  
  332. recall()
  333. haut = haut - 1
  334. reset()
  335.  
  336. until haut == 0
  337.  
  338. os.shutdown()
  339.  
  340.  
  341. end
  342.  
  343. if mode == 1 then
  344.  
  345. sol()
  346. recall()
  347. reset()
  348. haut = haut - 1
  349.  
  350. repeat
  351.  
  352. resetS()
  353. resetF()
  354. forward()
  355. if way == 0 then
  356. turtle.turnLeft()
  357. else
  358. turtle.turnRight()
  359. end
  360. forwardM()
  361. if way == 0 then
  362. turtle.turnLeft()
  363. else
  364. turtle.turnRight()
  365. end
  366. haut = haut - 1
  367. x = x + 1
  368. if x == 2 then
  369. if turtle.detectUp() then
  370. turtle.digUp()
  371. end
  372. turtle.up()
  373. x = 0
  374. end
  375. print(x)
  376.  
  377. until haut == 1 --A tester--
  378.  
  379. --Place pour le plafond--
  380.  
  381. os.shutdown()
  382.  
  383. end
  384.  
  385. if mode == 2 then
  386.  
  387.  
  388.  
  389. end
  390.  
  391. end
  392.  
  393.  
  394. --Start--
  395. print("Entrez le mode de build :")
  396. print("0 = Cube plein // 1 = Cube vide // 2 = Murs")
  397. input = io.read()
  398. mode = tonumber(input)
  399. print("Entrez la longueur :")
  400. input2 = io.read()
  401. long = tonumber(input2)
  402. print("Entrez la largeur :")
  403. input3 = io.read()
  404. larg = tonumber(input3)
  405. print("Entrez la hauteur :")
  406. input5 = io.read()
  407. haut = tonumber(input5)
  408. print("Poser dans quelle direction ?")
  409. print("0 = Gauche // 1 = Droite")
  410. input4 = io.read()
  411. way = tonumber(input4)
  412. TF = long
  413. TB = long
  414. TS = larg
  415. TSB = larg
  416. sens = way
  417. turtle.select(1)
  418. if turtle.detectUp then
  419.  
  420. turtle.digUp()
  421.  
  422. end
  423. turtle.up()
  424. start()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement