Advertisement
DraMic

Супер карьер от VladWinner

Nov 18th, 2021
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.75 KB | None | 0 0
  1. print ("**********************************")
  2. print ("* AVTOR PROGRAMMY *")
  3. print ("* VladWinner *")
  4. print ("**********************************")
  5.  
  6. storona = 1
  7. rjad = 0
  8. laer = 0
  9. local params = "vladparams"
  10. local location = "vladlocation"
  11. local backup = 0
  12. x = 0
  13. xdom = 0
  14. xvoz = 0
  15. y = 0
  16. ydom = 0
  17. yvoz = 0
  18. z = 0
  19. zdom = 0
  20. zvoz = 0
  21. file = 0
  22. -- FUNCTIONS
  23.  
  24. function dig()
  25. if turtle.detect() then
  26. while turtle.detect() do
  27. turtle.dig()
  28. sleep (0.5)
  29. end
  30. elseif isto4nik == 1 then
  31. turtle.select(16)
  32. while not turtle.place() do
  33. turtle.attack()
  34. end
  35. turtle.dig()
  36. end
  37. prov()
  38. end
  39.  
  40. function comup(a)
  41. turtle.select(a)
  42. if turtle.compareUp() then
  43. return true
  44. else
  45. return nil
  46. end
  47. end
  48.  
  49. function comdown(a)
  50. turtle.select(a)
  51. if turtle.compareDown() then
  52. return true
  53. else
  54. return nil
  55. end
  56. end
  57.  
  58. function digup()
  59. if turtle.detectUp() then
  60. if iskl == 1 then
  61. if comup(14) == nil and comup(15) == nil then
  62. while turtle.detectUp() do
  63. turtle.digUp()
  64. sleep (0.5)
  65. end
  66. end
  67. else
  68. while turtle.detectUp() do
  69. turtle.digUp()
  70. sleep (0.5)
  71. end
  72. end
  73. elseif isto4nik == 1 then
  74. turtle.select(16)
  75. while not turtle.placeUp() do
  76. turtle.attackUp()
  77. end
  78. turtle.digUp()
  79. end
  80. prov()
  81. end
  82.  
  83. function digdown()
  84. if turtle.detectDown() then
  85. if iskl == 1 then
  86. if comdown(14) == nil and comdown(15) == nil then
  87. turtle.digDown()
  88. end
  89. else
  90. turtle.digDown()
  91. end
  92. elseif isto4nik == 1 then
  93. turtle.select(16)
  94. while not turtle.placeDown() do
  95. turtle.attackDown()
  96. end
  97. turtle.digDown()
  98. end
  99. prov()
  100. end
  101.  
  102. function down()
  103. if turtle.detectDown() then
  104. turtle.digDown()
  105. end
  106. while not turtle.down() do
  107. turtle.attackDown()
  108. end
  109. end
  110.  
  111. function up()
  112. if turtle.detectUp() then
  113. while turtle.digUp() do
  114. sleep (0.5)
  115. end
  116. end
  117. while not turtle.up() do
  118. turtle.attackUp()
  119. end
  120. end
  121.  
  122. function forward()
  123. if turtle.detect() then
  124. while turtle.dig() do
  125. sleep (0.5)
  126. end
  127. end
  128. while not turtle.forward() do
  129. turtle.attack()
  130. turtle.dig()
  131. end
  132. end
  133.  
  134. function prov()
  135. base = 2
  136. for i = 1, col do
  137. if turtle.getItemCount(i) == 0 then
  138. base = base - 1
  139. end
  140. end
  141. if cobble == 0 and isto4nik == 0 then
  142. if turtle.getItemCount(16) == 0 then
  143. base = base - 1
  144. end
  145. end
  146. if base > 1 then
  147. if cobble == 1 then
  148. turtle.select(16)
  149. for i = 1, col do
  150. if turtle.compareTo(i) == true then
  151. turtle.select(i)
  152. turtle.drop()
  153. base = base - 1
  154. turtle.select(16)
  155. end
  156. end
  157. if base < 1 then
  158. sortirovka = 0
  159. for i = 1, col do
  160. if turtle.getItemCount(i) > 0 then
  161. sortirovka = sortirovka + 1
  162. end
  163. end
  164. for i = col, sortirovka, -1 do
  165. if turtle.getItemCount(i) > 0 then
  166. turtle.select(i)
  167. sorti = 1
  168. while not turtle.transferTo(sorti) and sorti <= sortirovka do
  169. sorti = sorti + 1
  170. end
  171. end
  172. end
  173. turtle.select(16)
  174. end
  175. end
  176. if base > 0 then
  177. zdom = z
  178. ydom = y
  179. xdom = x
  180. zvoz = z
  181. yvoz = y
  182. xvoz = x
  183. savelocation()
  184. dom()
  185. vozvrat()
  186. end
  187. turtle.select(16)
  188. end
  189. end
  190.  
  191. function saveparams()
  192. local a = io.open (params, "w")
  193. a:write ("xdl = ".. xdl.. "\n")
  194. a:write ("col = ".. col.. "\n")
  195. a:write ("file = ".. file.. "\n")
  196. a:write ("zdl = ".. zdl.. "\n")
  197. a:write ("iskl = ".. iskl.. "\n")
  198. a:write ("cobble = ".. cobble.. "\n")
  199. a:write ("isto4nik = ".. isto4nik.. "\n")
  200. a:close()
  201. end
  202.  
  203. function savelocation()
  204. local a = io.open (location, "w")
  205. a:write ("yd = ".. yd.. "\n")
  206. a:write ("x = ".. x.. "\n")
  207. a:write ("y = ".. y.. "\n")
  208. a:write ("z = ".. z.. "\n")
  209. a:write ("xvoz = ".. xvoz.. "\n")
  210. a:write ("yvoz = ".. yvoz.. "\n")
  211. a:write ("zvoz = ".. zvoz.. "\n")
  212. a:write ("xdom = ".. xdom.. "\n")
  213. a:write ("ydom = ".. ydom.. "\n")
  214. a:write ("zdom = ".. zdom.. "\n")
  215. a:write ("xdla = ".. xdla.. "\n")
  216. a:write ("zdla = ".. zdla.. "\n")
  217. a:write ("ydla = ".. ydla.. "\n")
  218. a:write ("storona = ".. storona.. "\n")
  219. a:write ("rjad = ".. rjad.. "\n")
  220. a:write ("laer = ".. laer.. "\n")
  221. a:write ("ydl = ".. ydl.. "\n")
  222. a:close ()
  223. end
  224.  
  225. function turn(a)
  226. if a - storona == 2 or a - storona == -2 then
  227. turtle.turnRight()
  228. turtle.turnRight()
  229. elseif a - storona == -1 or a - storona == 3 then
  230. turtle.turnLeft()
  231. elseif a - storona == 1 or a - storona == -3 then
  232. turtle.turnRight()
  233. elseif a - storona ~= 0 then
  234. print ("ERROR turn")
  235. return
  236. end
  237. storona = a
  238. savelocation()
  239. end
  240.  
  241. function clearforward()
  242. while xdla > 1 do
  243. dig()
  244. if ydl > 1 then
  245. digup()
  246. if ydl > 2 then
  247. digdown()
  248. end
  249. end
  250. forward()
  251. xdla = xdla - 1
  252. if laer == 0 then
  253. if rjad == 0 then
  254. x = x + 1
  255. else
  256. x = x - 1
  257. end
  258. else
  259. if rjad == 0 then
  260. x = x - 1
  261. else
  262. x = x + 1
  263. end
  264. end
  265. savelocation()
  266. end
  267. if ydl > 1 then
  268. digup()
  269. if ydl > 2 then
  270. digdown()
  271. end
  272. end
  273. xdla = xdl
  274. end
  275.  
  276. function clearlaer()
  277. if laer == 0 then
  278. while zdla > 1 do
  279. if rjad == 0 then
  280. turn(1)
  281. clearforward()
  282. turn(2)
  283. dig()
  284. turn(2)
  285. forward()
  286. rjad = 1
  287. zdla = zdla - 1
  288. z = z + 1
  289. savelocation()
  290. turn(3)
  291. else
  292. turn(3)
  293. clearforward()
  294. turn(2)
  295. dig()
  296. turn(2)
  297. forward()
  298. rjad = 0
  299. zdla = zdla - 1
  300. z = z + 1
  301. savelocation()
  302. turn(1)
  303. end
  304. end
  305. clearforward()
  306. if rjad == 0 then
  307. turn(3)
  308. else
  309. turn(1)
  310. end
  311. else
  312. while zdla > 1 do
  313. if rjad == 0 then
  314. turn(3)
  315. clearforward()
  316. turn(4)
  317. dig()
  318. turn(4)
  319. forward()
  320. rjad = 1
  321. zdla = zdla - 1
  322. z = z - 1
  323. savelocation()
  324. turn(1)
  325. else
  326. turn(1)
  327. clearforward()
  328. turn(4)
  329. dig()
  330. turn(4)
  331. forward()
  332. rjad = 0
  333. zdla = zdla - 1
  334. z = z - 1
  335. savelocation()
  336. turn(3)
  337. end
  338. end
  339. clearforward()
  340. if rjad == 0 then
  341. turn(1)
  342. else
  343. turn(3)
  344. end
  345. end
  346. end
  347.  
  348. function dom()
  349. if laer == 1 then
  350. for i = 1, 3 do
  351. down()
  352. ydom = ydom + 1
  353. savelocation()
  354. end
  355. end
  356. turn(4)
  357. while zdom > 0 do
  358. forward()
  359. zdom = zdom - 1
  360. savelocation()
  361. end
  362. turn(3)
  363. while xdom > 0 do
  364. forward()
  365. xdom = xdom - 1
  366. savelocation()
  367. end
  368. if ydom > 0 then
  369. while ydom > 0 do
  370. up()
  371. ydom = ydom - 1
  372. savelocation()
  373. end
  374. elseif ydom < 0 then
  375. while ydom < 0 do
  376. down()
  377. ydom = ydom + 1
  378. savelocation()
  379. end
  380. end
  381. for i = 1, col do
  382. turtle.select(i)
  383. turtle.drop()
  384. end
  385. turtle.select(16)
  386. end
  387.  
  388. function vozvrat()
  389. if yvoz > 0 then
  390. while yvoz > 0 do
  391. down()
  392. yvoz = yvoz - 1
  393. savelocation()
  394. end
  395. elseif yvoz < 0 then
  396. while yvoz < 0 do
  397. up()
  398. yvoz = yvoz + 1
  399. savelocation()
  400. end
  401. end
  402. if laer == 1 then
  403. while yvoz > -3 do
  404. down()
  405. yvoz = yvoz - 1
  406. savelocation()
  407. end
  408. end
  409. turn(1)
  410. while xvoz > 0 do
  411. forward()
  412. xvoz = xvoz - 1
  413. savelocation()
  414. end
  415. turn(2)
  416. while zvoz > 0 do
  417. forward()
  418. zvoz = zvoz - 1
  419. savelocation()
  420. end
  421. if laer == 0 then
  422. if rjad == 0 then
  423. turn(1)
  424. else
  425. turn(3)
  426. end
  427. else
  428. while yvoz < 0 do
  429. up()
  430. yvoz = yvoz + 1
  431. savelocation()
  432. end
  433. if rjad == 0 then
  434. turn(3)
  435. else
  436. turn(1)
  437. end
  438. end
  439. end
  440.  
  441. function provback()
  442. local a = io.open (params, "r")
  443. local b = io.open (location, "r")
  444. if (io.open (params, "r") ~= nil) and (io.open (location, "r") ~= nil) then
  445. dofile (params)
  446. a:close()
  447. b:close()
  448. end
  449. if file == 1 then
  450. return true
  451. else
  452. return false
  453. end
  454. end
  455.  
  456. function clearfile()
  457. local a = io.open (params, "w")
  458. local b = io.open (location, "w")
  459. a:close()
  460. b:close()
  461. end
  462.  
  463. -- POL'ZOVATEL' VVODIT DANNYE
  464.  
  465. if provback() == true then
  466. print ("est' sohranenija raboty. zhelaete vosstanovit'?")
  467. print ("0 - net")
  468. print ("1 - da")
  469. backup = tonumber (read())
  470. if backup < 0 or backup > 1 then
  471. print ("Nuzhno vybrat' 0 ili 1")
  472. return
  473. elseif backup == 1 then
  474. dofile (params)
  475. dofile (location)
  476. end
  477. end
  478.  
  479.  
  480. if backup == 0 then
  481. clearfile()
  482. print ("Vvedite skol'ko kopat' vniz")
  483. yd = tonumber(read())
  484.  
  485. print ("Vvedite vysotu kopanija")
  486. ydl = tonumber(read())
  487. ydla = ydl
  488. if ydl < 1 then
  489. print ("Ne mozhet byt' men'he 1")
  490. return
  491. end
  492.  
  493. print ("Vvedite skol'ko kopat' vpered")
  494. xdl = tonumber(read())
  495. xdla = xdl
  496. if xdl < 2 then
  497. print ("Ne mozhet byt' men'he 2")
  498. return
  499. end
  500.  
  501. print ("Vvedite skol'ko kopat' vpravo")
  502. zdl = tonumber(read())
  503. zdla = zdl
  504. if zdl < 2 then
  505. print ("Ne mozhet byt' men'he 2")
  506. return
  507. end
  508.  
  509. print ("Hotite uni4tozhat' cobblestone?")
  510. print ("0 - net")
  511. print ("1 - da")
  512. cobble = tonumber(read())
  513. if cobble < 0 or cobble > 1 then
  514. print ("Nuzhno vybrat' 0 ili 1")
  515. return
  516. end
  517.  
  518. print ("Ubirat' isto4niki lavy i vody?")
  519. print ("0 - net (bystree)")
  520. print ("1 - da (4ishe)")
  521. isto4nik = tonumber(read())
  522. if isto4nik < 0 or isto4nik > 1 then
  523. print ("Nuzhno vybrat' 0 ili 1")
  524. return
  525. end
  526.  
  527. print("Hotite dobavit' 2 bloka isklju4enija?")
  528. print ("0 - net ")
  529. print ("1 - da ")
  530. iskl = tonumber(read())
  531. if iskl < 0 or iskl > 1 then
  532. print ("Nuzhno vybrat' 0 ili 1")
  533. return
  534. end
  535.  
  536. if iskl == 1 then
  537. col = 13
  538. else
  539. col = 15
  540. end
  541.  
  542. file = 1
  543.  
  544. saveparams()
  545. end
  546.  
  547. if iskl == 1 then
  548. while turtle.getItemCount(15) < 1 or turtle.getItemCount(14) < 1 do
  549. print ("Polozhite bloki isklju4enija v 14 i 15 sloty")
  550. sleep(10)
  551. end
  552. end
  553.  
  554. if cobble == 1 or isto4nik == 1 then
  555. while turtle.getItemCount(16) < 1 do
  556. print ("Polozhite cobblestone v samuj poslednij slot")
  557. sleep(10)
  558. end
  559. end
  560.  
  561. -- MAIN
  562.  
  563. if xdom ~= 0 or ydom ~= 0 or zdom ~= 0 then
  564. dom()
  565. end
  566.  
  567. if xvoz ~= 0 or yvoz ~= 0 or zvoz ~= 0 then
  568. vozvrat()
  569. end
  570.  
  571. while ydl > 0 do
  572. if ydl > 2 then
  573. if yd > y + 1 then
  574. while y < yd - 1 do
  575. down()
  576. y = y + 1
  577. savelocation()
  578. end
  579. end
  580. if yd < y + 1 then
  581. while y > yd - 1 do
  582. up()
  583. y = y - 1
  584. savelocation()
  585. end
  586. end
  587. else
  588. if yd > y + 1 then
  589. while y < yd do
  590. down()
  591. y = y + 1
  592. savelocation()
  593. end
  594. end
  595. if yd < y + 1 then
  596. while y > yd do
  597. up()
  598. y = y - 1
  599. savelocation()
  600. end
  601. end
  602. end
  603. clearlaer()
  604. zdla = zdl
  605. if ydl > 2 then
  606. ydl = ydl - 3
  607. yd = yd - 3
  608. else
  609. ydl = 0
  610. yd = 0
  611. end
  612. if ydl > 0 then
  613. if laer == 0 then
  614. laer = 1
  615. else
  616. laer = 0
  617. end
  618. end
  619. savelocation()
  620. end
  621. zdom = z
  622. ydom = y
  623. xdom = x
  624. savelocation()
  625. dom()
  626. clearfile()
  627. print ("*************************************")
  628. print ("* finish! *")
  629. print ("* nash kanal na youtube: *")
  630. print ("* www.youtube.com/user/ *")
  631. print ("* VladWinnerGamePortal *")
  632. print ("*************************************")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement