Advertisement
ladyDia

Grey Goo Type Stuff

Dec 28th, 2020 (edited)
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 20.50 KB | None | 0 0
  1. inventory = {}
  2. inventoryCount = {}
  3. for i = 1, 16 do
  4. inventory[i] = " "
  5. inventoryCount[i] = 0
  6. end
  7.  
  8. function findItem(item)
  9. for i = 1, 16 do
  10. print("Test")
  11. if inventory[i] == item then
  12. print(i)
  13. return i
  14. end
  15. end
  16. return 0
  17. end
  18.  
  19. function getChestDown()
  20. local slot = findItem("minecraft:chest")
  21. turtle.select(slot)
  22. turtle.placeDown()
  23. end
  24.  
  25. function updateInventory()
  26. for i = 1, 16 do
  27. if turtle.getItemCount(i)>0 then
  28. inventory[i] = turtle.getItemDetail(i).name
  29. inventoryCount[i] = turtle.getItemCount(i)
  30. end
  31. end
  32. end
  33.  
  34. function crafting(item)
  35. updateInventory()
  36. if item == "diamond_Pickaxe" then
  37. if (inventoryCount[findItem("minecraft:diamond")]>2) and (inventoryCount[findItem("minecraft:stick")]>1) then
  38. getChestDown()
  39. for i = 1, 16 do
  40. if inventory[i] ~= "minecraft:diamond" or inventory[i] ~= "minecraft:stick" then
  41. turtle.dropDown()
  42. end
  43. end
  44. updateInventory()
  45. turtle.select(findItem("minecraft:diamond"))
  46. turtle.transferTo(15)
  47. turtle.select(findItem("minecraft:stick"))
  48. turtle.transferTo(16)
  49. updateInventory()
  50. --Crafting begins
  51. turtle.select(15)
  52. turtle.transferTo(1,1)
  53. turtle.transferTo(2,1)
  54. turtle.transferTo(3,1)
  55. turtle.select(16)
  56. turtle.transferTo(6,1)
  57. turtle.transferTo(10,1)
  58. turtle.select(15)
  59. turtle.dropDown()
  60. turtle.select(16)
  61. turtle.dropDown()
  62. turtle.craft()
  63. --The item should be crafted, now to grab the inventory back
  64. for i = 1, 16 do
  65. turtle.select(i)
  66. turtle.suckDown()
  67. end
  68. updateInventory()
  69. turtle.digDown()
  70. else
  71. if inventoryCount[findItem("minecraft:stick")]<2 then
  72. crafting("stick")
  73. updateInventory()
  74. if inventoryCount[findItem("minecraft:stick")]>1 then
  75. crafting("diamond_Pickaxe")
  76. end
  77. end
  78. if inventoryCount[findItem("minecraft:diamond")]<3 then
  79. print("Not enough diamonds")
  80. end
  81. end
  82. end
  83. if item == "stick" then
  84. if (inventoryCount[findItem("minecraft:planks")]>1) then
  85. getChestDown()
  86. for i = 1, 16 do
  87. if inventory[i] ~= "minecraft:planks" then
  88. turtle.dropDown()
  89. end
  90. end
  91. updateInventory()
  92. turtle.select(findItem("minecraft:planks"))
  93. turtle.transferTo(16)
  94. updateInventory()
  95. --Crafting begins
  96. turtle.transferTo(1,1)
  97. turtle.transferTo(5,1)
  98. turtle.select(16)
  99. turtle.dropDown()
  100. turtle.craft()
  101. --The item should be crafted, now to grab the inventory back
  102. for i = 1, 16 do
  103. turtle.select(i)
  104. turtle.suckDown()
  105. end
  106. updateInventory()
  107. turtle.digDown()
  108. else
  109. if inventoryCount[findItem("minecraft:planks")]<2 then
  110. crafting("planks")
  111. updateInventory()
  112. if inventoryCount[findItem("minecraft:planks")]>1 then
  113. crafting("stick")
  114. end
  115. end
  116. end
  117. end
  118. if item == "planks" then
  119. if (inventoryCount[findItem("minecraft:log")]>0) then
  120. getChestDown()
  121. for i = 1, 16 do
  122. if inventory[i] ~= "minecraft:log" then
  123. turtle.dropDown()
  124. end
  125. end
  126. updateInventory()
  127. turtle.select(findItem("minecraft:log"))
  128. turtle.transferTo(16)
  129. updateInventory()
  130. --Crafting begins
  131. turtle.select(16)
  132. turtle.transferTo(1,1)
  133. turtle.select(16)
  134. turtle.dropDown()
  135. turtle.craft()
  136. --The item should be crafted, now to grab the inventory back
  137. for i = 1, 16 do
  138. turtle.select(i)
  139. turtle.suckDown()
  140. end
  141. updateInventory()
  142. turtle.digDown()
  143. else
  144. print("Not enough logs")
  145. end
  146. end
  147. if item == "chest" then
  148. if (inventoryCount[findItem("minecraft:planks")]>7) then
  149. getChestDown()
  150. for i = 1, 16 do
  151. if inventory[i] ~= "planks" then
  152. turtle.dropDown()
  153. end
  154. end
  155. updateInventory()
  156. turtle.select(findItem("minecraft:planks"))
  157. turtle.transferTo(16)
  158. updateInventory()
  159. --Crafting begins
  160. turtle.select(16)
  161. turtle.transferTo(1,1)
  162. turtle.transferTo(2,1)
  163. turtle.transferTo(3,1)
  164. turtle.transferTo(5,1)
  165. turtle.transferTo(7,1)
  166. turtle.transferTo(9,1)
  167. turtle.transferTo(10,1)
  168. turtle.transferTo(11,1)
  169. turtle.select(16)
  170. turtle.dropDown()
  171. turtle.craft()
  172. --The item should be crafted, now to grab the inventory back
  173. for i = 1, 16 do
  174. turtle.select(i)
  175. turtle.suckDown()
  176. end
  177. updateInventory()
  178. turtle.digDown()
  179. else
  180. if inventoryCount[findItem("minecraft:planks")]<8 then
  181. crafting("planks")
  182. updateInventory()
  183. if inventoryCount[findItem("minecraft:planks")]>7 then
  184. crafting("chest")
  185. else
  186. print("Not enough resources")
  187. end
  188. end
  189. end
  190. end
  191. if item == "crafting_Table" then
  192. if (inventoryCount[findItem("minecraft:planks")]>3) then
  193. getChestDown()
  194. for i = 1, 16 do
  195. if inventory[i] ~= "minecraft:planks" then
  196. turtle.dropDown()
  197. end
  198. end
  199. updateInventory()
  200. turtle.select(findItem("minecraft:planks"))
  201. turtle.transferTo(16)
  202. updateInventory()
  203. --Crafting begins
  204. turtle.select(16)
  205. turtle.transferTo(1,1)
  206. turtle.transferTo(2,1)
  207. turtle.transferTo(5,1)
  208. turtle.transferTo(6,1)
  209. turtle.select(16)
  210. turtle.dropDown()
  211. turtle.craft()
  212. --The item should be crafted, now to grab the inventory back
  213. for i = 1, 16 do
  214. turtle.select(i)
  215. turtle.suckDown()
  216. end
  217. updateInventory()
  218. turtle.digDown()
  219. else
  220. if inventoryCount[findItem("minecraft:planks")]<8 then
  221. crafting("planks")
  222. updateInventory()
  223. if inventoryCount[findItem("minecraft:planks")]>7 then
  224. crafting("crafting_Table")
  225. else
  226. print("Not enough resources")
  227. end
  228. end
  229. end
  230. end
  231. if item == "glass_pane" then
  232. if (inventoryCount[findItem("minecraft:glass")]>5) then
  233. getChestDown()
  234. for i = 1, 16 do
  235. if inventory[i] ~= "minecraft:glass" then
  236. turtle.dropDown()
  237. end
  238. end
  239. updateInventory()
  240. turtle.select(findItem("minecraft:glass"))
  241. turtle.transferTo(16)
  242. updateInventory()
  243. --Crafting begins
  244. turtle.select(16)
  245. turtle.transferTo(1,1)
  246. turtle.transferTo(2,1)
  247. turtle.transferTo(3,1)
  248. turtle.transferTo(5,1)
  249. turtle.transferTo(6,1)
  250. turtle.transferTo(7,1)
  251. turtle.select(16)
  252. turtle.dropDown()
  253. turtle.craft()
  254. --The item should be crafted, now to grab the inventory back
  255. for i = 1, 16 do
  256. turtle.select(i)
  257. turtle.suckDown()
  258. end
  259. updateInventory()
  260. turtle.digDown()
  261. else
  262. print("Not enough glass")
  263. end
  264. end
  265. if item == "ComputerCraft:CC-Computer" then
  266. if (inventoryCount[findItem("minecraft:stone")]>6) and (inventoryCount[findItem("minecraft:glass_pane")]>0) and(inventoryCount[findItem("minecraft:redstone")]>0) then
  267. getChestDown()
  268. for i = 1, 16 do
  269. if inventory[i] ~= "minecraft:glass_pane" or inventory[i] ~= "minecraft:stone" or inventory[i] ~= "minecraft:redstone" then
  270. turtle.dropDown()
  271. end
  272. end
  273. updateInventory()
  274. turtle.select(findItem("minecraft:glass_pane"))
  275. turtle.transferTo(14)
  276. turtle.select(findItem("minecraft:stone"))
  277. turtle.transferTo(15)
  278. turtle.select(findItem("minecraft:redstone"))
  279. turtle.transferTo(16)
  280. updateInventory()
  281. --Crafting begins
  282. turtle.select(15)
  283. turtle.transferTo(1,1)
  284. turtle.transferTo(2,1)
  285. turtle.transferTo(3,1)
  286. turtle.transferTo(5,1)
  287. turtle.transferTo(7,1)
  288. turtle.transferTo(9,1)
  289. turtle.transferTo(11,1)
  290. turtle.dropDown()
  291. turtle.select(14)
  292. turtle.transferTo(10,1)
  293. turtle.dropDown()
  294. turtle.select(16)
  295. turtle.transferTo(6,1)
  296. turtle.dropDown()
  297. turtle.craft()
  298. --The item should be crafted, now to grab the inventory back
  299. for i = 1, 16 do
  300. turtle.select(i)
  301. turtle.suckDown()
  302. end
  303. updateInventory()
  304. turtle.digDown()
  305. else
  306. if inventoryCount[findItem("minecraft:stone")]<7 then
  307. print("Not enough stone")
  308. end
  309. if inventoryCount[findItem("minecraft:glass_pane")]<1 then
  310. crafting("glass_pane")
  311. updateInventory()
  312. if inventoryCount[findItem("minecraft:glass_pane")]>0 then
  313. crafting("ComputerCraft:CC-Computer")
  314. else
  315. print("Not enough resources")
  316. end
  317. end
  318. if inventoryCount[findItem("minecraft:redstone")]<1 then
  319. print("Not enough redstone")
  320. end
  321. end
  322. end
  323. if item == "ComputerCraft:CC-Turtle" then
  324. if (inventoryCount[findItem("minecraft:iron")]>6) and (inventoryCount[findItem("minecraft:chest")]>0) and(inventoryCount[findItem("ComputerCraft:CC-Computer")]>0) then
  325. getChestDown()
  326. for i = 1, 16 do
  327. if inventory[i] ~= "minecraft:chest" or inventory[i] ~= "minecraft:stone" or inventory[i] ~= "ComputerCraft:CC-Computer" then
  328. turtle.dropDown()
  329. end
  330. end
  331. updateInventory()
  332. turtle.select(findItem("minecraft:chest"))
  333. turtle.transferTo(14)
  334. turtle.select(findItem("minecraft:iron"))
  335. turtle.transferTo(15)
  336. turtle.select(findItem("ComputerCraft:CC-Computer"))
  337. turtle.transferTo(16)
  338. updateInventory()
  339. --Crafting begins
  340. turtle.select(15)
  341. turtle.transferTo(1,1)
  342. turtle.transferTo(2,1)
  343. turtle.transferTo(3,1)
  344. turtle.transferTo(5,1)
  345. turtle.transferTo(7,1)
  346. turtle.transferTo(9,1)
  347. turtle.transferTo(11,1)
  348. turtle.dropDown()
  349. turtle.select(14)
  350. turtle.transferTo(10,1)
  351. turtle.dropDown()
  352. turtle.select(16)
  353. turtle.transferTo(6,1)
  354. turtle.dropDown()
  355. turtle.craft()
  356. --The item should be crafted, now to grab the inventory back
  357. for i = 1, 16 do
  358. turtle.select(i)
  359. turtle.suckDown()
  360. end
  361. updateInventory()
  362. turtle.digDown()
  363. else
  364. if inventoryCount[findItem("minecraft:chest")]<1 then
  365. crafting("chest")
  366. updateInventory()
  367. if inventoryCount[findItem("minecraft:chest")]>0 then
  368. crafting("ComputerCraft:CC-Turtle")
  369. else
  370. print("Not enough resources")
  371. end
  372. end
  373. if inventoryCount[findItem("ComputerCraft:CC-Computer")]<1 then
  374. crafting("ComputerCraft:CC-Computer")
  375. updateInventory()
  376. if inventoryCount[findItem("ComputerCraft:CC-Computer")]>0 then
  377. crafting("ComputerCraft:CC-Turtle")
  378. else
  379. print("Not enough resources")
  380. end
  381. end
  382. if inventoryCount[findItem("minecraft:iron")]<7 then
  383. print("Not enough resironources")
  384. end
  385. end
  386. end
  387. if item == "ComputerCraft:CC-Turtle:1" then
  388. if (inventoryCount[findItem("minecraft:diamond_Pickaxe")]>0) and(inventoryCount[findItem("ComputerCraft:CC-Turtle")]>0) then
  389. getChestDown()
  390. for i = 1, 16 do
  391. if inventory[i] ~= "minecraft:diamond_Pickaxe" or inventory[i] ~= "ComputerCraft:CC-Turtle" then
  392. turtle.dropDown()
  393. end
  394. end
  395. updateInventory()
  396. turtle.select(findItem("minecraft:diamond_Pickaxe"))
  397. turtle.transferTo(15)
  398. turtle.select(findItem("ComputerCraft:CC-Turtle"))
  399. turtle.transferTo(16)
  400. updateInventory()
  401. --Crafting begins
  402. turtle.select(15)
  403. turtle.transferTo(7,1)
  404. turtle.dropDown()
  405. turtle.select(16)
  406. turtle.transferTo(6,1)
  407. turtle.dropDown()
  408. turtle.craft()
  409. --The item should be crafted, now to grab the inventory back
  410. for i = 1, 16 do
  411. turtle.select(i)
  412. turtle.suckDown()
  413. end
  414. updateInventory()
  415. turtle.digDown()
  416. else
  417. if inventoryCount[findItem("minecraft:diamond_Pickaxe")]<1 then
  418. crafting("diamond_Pickaxe")
  419. updateInventory()
  420. if inventoryCount[findItem("minecraft:diamond_Pickaxe")]>0 then
  421. crafting("ComputerCraft:CC-Turtle:1")
  422. else
  423. print("Not enough resources")
  424. end
  425. end
  426. if inventoryCount[findItem("ComputerCraft:CC-Turtle")]<1 then
  427. crafting("ComputerCraft:CC-Turtle")
  428. updateInventory()
  429. if inventoryCount[findItem("ComputerCraft:CC-Turtle")]>0 then
  430. crafting("ComputerCraft:CC-Turtle:1")
  431. else
  432. print("Not enough resources")
  433. end
  434. end
  435. end
  436. end
  437. if item == "CraftyMiningTurtle" then --Change me to proper id
  438. if (inventoryCount[findItem("cminecraft:rafting_Table")]>0) and(inventoryCount[findItem("ComputerCraft:CC-Turtle:1")]>0) then
  439. getChestDown()
  440. for i = 1, 16 do
  441. if inventory[i] ~= "minecraft:crafting_Table" or inventory[i] ~= "ComputerCraft:CC-Turtle:1" then
  442. turtle.dropDown()
  443. end
  444. end
  445. updateInventory()
  446. turtle.select(findItem("minecraft:crafting_Table"))
  447. turtle.transferTo(15)
  448. turtle.select(findItem("ComputerCraft:CC-Turtle:1"))
  449. turtle.transferTo(16)
  450. updateInventory()
  451. --Crafting begins
  452. turtle.select(15)
  453. turtle.transferTo(5,1)
  454. turtle.dropDown()
  455. turtle.select(16)
  456. turtle.transferTo(6,1)
  457. turtle.dropDown()
  458. turtle.craft()
  459. --The item should be crafted, now to grab the inventory back
  460. for i = 1, 16 do
  461. turtle.select(i)
  462. turtle.suckDown()
  463. end
  464. updateInventory()
  465. turtle.digDown()
  466. else
  467. if inventoryCount[findItem("minecraft:crafting_Table")]<1 then
  468. crafting("crafting_Table")
  469. updateInventory()
  470. if inventoryCount[findItem("minecraft:crafting_Table")]>0 then
  471. crafting("CraftyMiningTurtle")
  472. else
  473. print("Not enough resources")
  474. end
  475. end
  476. if inventoryCount[findItem("ComputerCraft:CC-Turtle:1")]<1 then
  477. crafting("ComputerCraft:CC-Turtle:1")
  478. updateInventory()
  479. if inventoryCount[findItem("ComputerCraft:CC-Turtle:1")]>0 then
  480. crafting("CraftyMiningTurtle")
  481. else
  482. print("Not enough resources")
  483. end
  484. end
  485. end
  486. end
  487. if item == "minecraft:paper" then
  488. if (inventoryCount[findItem("minecraft:reeds")]>2) then
  489. getChestDown()
  490. for i = 1, 16 do
  491. if inventory[i] ~= "minecraft:reeds" then
  492. turtle.dropDown()
  493. end
  494. end
  495. updateInventory()
  496. turtle.select(findItem("minecraft:reeds"))
  497. turtle.transferTo(16)
  498. updateInventory()
  499. --Crafting begins
  500. turtle.select(16)
  501. turtle.transferTo(1,1)
  502. turtle.transferTo(2,1)
  503. turtle.transferTo(3,1)
  504. turtle.dropDown()
  505. turtle.craft()
  506. --The item should be crafted, now to grab the inventory back
  507. for i = 1, 16 do
  508. turtle.select(i)
  509. turtle.suckDown()
  510. end
  511. updateInventory()
  512. turtle.digDown()
  513. else
  514. print("Not enough resources")
  515. end
  516. end
  517. if item == "computercraft:disk" then
  518. if (inventoryCount[findItem("minecraft:paper")]>0) and (inventoryCount[findItem("minecraft:restone")]>0) then
  519. getChestDown()
  520. for i = 1, 16 do
  521. if inventory[i] ~= "minecraft:paper" or inventory[i] ~= "minecraft:redstone" then
  522. turtle.dropDown()
  523. end
  524. end
  525. updateInventory()
  526. turtle.select(findItem("minecraft:redstone"))
  527. turtle.transferTo(15)
  528. turtle.select(findItem("minecraft:paper"))
  529. turtle.transferTo(16)
  530. updateInventory()
  531. --Crafting begins
  532. turtle.select(15)
  533. turtle.transferTo(2,1)
  534. turtle.dropDown()
  535. turtle.select(16)
  536. turtle.transferTo(6,1)
  537. turtle.dropDown()
  538. turtle.craft()
  539. --The item should be crafted, now to grab the inventory back
  540. for i = 1, 16 do
  541. turtle.select(i)
  542. turtle.suckDown()
  543. end
  544. updateInventory()
  545. turtle.digDown()
  546. else
  547. if inventoryCount[findItem("minecraft:restone")]<1 then
  548. print("Not enough restone")
  549. end
  550. if inventoryCount[findItem("minecraft:paper")]<1 then
  551. crafting("minecraft:paper")
  552. updateInventory()
  553. if inventoryCount[findItem("minecraft:paper")]>0 then
  554. crafting("computercraft:disk")
  555. else
  556. print("Not enough resources")
  557. end
  558. end
  559. end
  560. end
  561. if item == "ComputerCraft:CC-Peripheral" then
  562. if (inventoryCount[findItem("minecraft:stone")]>6) and(inventoryCount[findItem("minecraft:redstone")]>1) then
  563. getChestDown()
  564. for i = 1, 16 do
  565. if inventory[i] ~= "minecraft:stone" or inventory[i] ~= "minecraft:redstone" then
  566. turtle.dropDown()
  567. end
  568. end
  569. updateInventory()
  570. turtle.select(findItem("minecraft:stone"))
  571. turtle.transferTo(15)
  572. turtle.select(findItem("minecraft:redstone"))
  573. turtle.transferTo(16)
  574. updateInventory()
  575. --Crafting begins
  576. turtle.select(15)
  577. turtle.transferTo(1,1)
  578. turtle.transferTo(2,1)
  579. turtle.transferTo(3,1)
  580. turtle.transferTo(5,1)
  581. turtle.transferTo(7,1)
  582. turtle.transferTo(9,1)
  583. turtle.transferTo(11,1)
  584. turtle.dropDown()
  585. turtle.select(16)
  586. turtle.transferTo(10,1)
  587. turtle.transferTo(6,1)
  588. turtle.dropDown()
  589. turtle.craft()
  590. --The item should be crafted, now to grab the inventory back
  591. for i = 1, 16 do
  592. turtle.select(i)
  593. turtle.suckDown()
  594. end
  595. updateInventory()
  596. turtle.digDown()
  597. else
  598. if inventoryCount[findItem("minecraft:stone")]<7 then
  599. print("Not enough stone")
  600. end
  601. if inventoryCount[findItem("minecraft:redstone")]<2 then
  602. print("Not enough redstone")
  603. end
  604. end
  605. end
  606. end
  607.  
  608. function reproduce()
  609. local turtleSlot = findItem("CraftyMiningTurtle") --Please change me to the real thing
  610. local driveSlot = findItem("ComputerCraft:CC-Peripheral")
  611. local diskSlot = findItem("ComputerCraft:CC-Peripheral")
  612. local coalSlot = findItem("coal")
  613. if (turtleSlot>0) and (driveSlot>0) and (diskSlot>0) and(coalSlot>0) then
  614. turtle.select(driveSlot)
  615. turtle.place()
  616. turtle.select(diskSlot)
  617. turtle.drop()
  618. fs.copy("startup","disk\startup")
  619. turtle.up()
  620. turtle.select(turtleSlot)
  621. turtle.place()
  622. peripheral.call("front","turnOn")
  623. turtle.select(coalSlot)
  624. for i = 1, 5 do
  625. turtle.drop()
  626. end
  627. sleep(2)
  628. turtle.down()
  629. turtle.suck()
  630. turtle.dig()
  631. end
  632. end
  633.  
  634. if(disk.isPresent("down"))then
  635. fs.copy("disk\startup","startup")
  636. end
  637.  
  638. while 1==1 do
  639. crafting("diamond_Pickaxe")
  640. sleep(1)
  641. end
  642.  
  643. --To Do
  644.  
  645. --Mine for fuel, turn trees into fuel
  646. --Mine for replication resources
  647. --Build structures to help facilitate the program
  648. --Have an information storage location
  649. --Item storage location
  650. --Refuel location for turtles to return to
  651. --Keep track of turtle population
  652.  
  653. --Build city?
  654. --Scale of structures?
  655. --Strip mining or mine everything?
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement