Advertisement
ecco7777

Turtle Autocraft one Chest

Oct 25th, 2015
279
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. i=peripheral.wrap("right")
  2. side=2
  3. s=peripheral.wrap("bottom")
  4. subCraftId={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}
  5. recipeList={
  6. 5,"wood planks",
  7. 17,0,0,
  8. 0,0,0,
  9. 0,0,0,
  10. 280,"sticks",
  11. 5,0,0,
  12. 5,0,0,
  13. 0,0,0,
  14. 54,"wooden chest",
  15. 5,5,5,
  16. 5,0,5,
  17. 5,5,5,
  18. 58,"crafting table",
  19. 5,5,0,
  20. 5,5,0,
  21. 0,0,0,
  22. 61,"furnace",
  23. 4,4,4,
  24. 4,0,4,
  25. 4,4,4,
  26. 102,"glass pane",
  27. 20,20,20,
  28. 20,20,20,
  29. 0,0,0,
  30. 257,"iron pickaxe",
  31. 265,265,265,
  32. 0,280,0,
  33. 0,280,0,
  34. 512,"mining well",
  35. 265,331,265,
  36. 265,4058,265,
  37. 265,257,265,
  38. 518,"tank",
  39. 20,20,20,
  40. 20,0,20,
  41. 20,20,20,
  42. 515,"pump",
  43. 518,0,0,
  44. 512,0,0,
  45. 0,0,0,
  46. 12249,"plastic sheets",
  47. 12250,12250,0,
  48. 12250,12250,0,
  49. 0,0,0,
  50. 1227,"turtle",
  51. 265,265,265,
  52. 265,1225,265,
  53. 265,54,265,
  54. 1225,"computer",
  55. 1,1,1,
  56. 1,331,1,
  57. 1,102,1,
  58. 12259,"factory machine block",
  59. 12249,12249,12249,
  60. 1,1,1,
  61. 0,0,0,
  62. 363579,"bio generator",
  63. 12249,12249,12249,
  64. 33,61,33,
  65. 369,12259,369,
  66. 4056,"wooden gear",
  67. 0,280,0,
  68. 280,0,280,
  69. 0,280,0,
  70. 4057,"stone gear",
  71. 0,4,0,
  72. 4,4056,4,
  73. 0,4,0,
  74. 4058,"iron gear",
  75. 0,265,0,
  76. 265,4057,265,
  77. 0,265,0,
  78. 4059,"golden gear",
  79. 0,266,0,
  80. 266,4058,265,
  81. 0,266,0,
  82. 4060,"diamond gear",
  83. 0,264,0,
  84. 264,4059,264,
  85. 0,264,0,
  86. 33,"piston",
  87. 5,5,5,
  88. 4,265,4,
  89. 4,331,4,
  90. 33274,"stirling engine",
  91. 4,4,4,
  92. 0,20,0,
  93. 4057,33,4057,
  94. 506,"redstone engine",
  95. 5,5,5,
  96. 0,20,0,
  97. 4056,33,4056,
  98. 30184,"copper wire isolated",
  99. 30216,30216,30216,
  100. 169107,169107,169107,
  101. 30216,30216,30216,
  102. 30191,"electronic circut",
  103. 30184,30184,30184,
  104. 331,30249,331,
  105. 30184,30184,30184,
  106. 30190,"advanced circuit",
  107. 331,348,331,
  108. 131423,30191,131423,
  109. 331,348,331,
  110. 33385,"iron furnace",
  111. 0,265,0,
  112. 265,0,265,
  113. 265,61,265,
  114. 30239,"battery",
  115. 0,30184,0,
  116. 30247,331,30247,
  117. 30247,331,30247,
  118. 617,"machine block",
  119. 30249,30249,30249,
  120. 30249,0,30249,
  121. 30249,30249,30249,
  122. 611,"generator",
  123. 30239,0,0,
  124. 617,0,0,
  125. 61,0,0,
  126. 356,"redstone repeater",
  127. 76,331,76,
  128. 1,1,1,
  129. 0,0,0,
  130. 76,"redstone torch",
  131. 331,0,0,
  132. 280,0,0,
  133. 0,0,0,
  134. 50,"torch",
  135. 263,0,0,
  136. 280,0,0,
  137. 0,0,0,
  138. 278,"diamond pickaxe",
  139. 264,264,264,
  140. 0,280,0,
  141. 0,280,0,
  142. 507,"filler",
  143. 351,511,351,
  144. 360799,58,360799,
  145. 4059,54,4059,
  146. 511,"place marker",
  147. 131423,0,0,
  148. 76,0,0,
  149. 0,0,0,
  150. 66153,"electric furnace",
  151. 0,30191,0,
  152. 331,33385,331,
  153. 0,0,0,
  154. 1200,"enderchest",
  155. 369,35,369,
  156. 49,54,49,
  157. 369,368,369,
  158. 380,"couldron",
  159. 265,0,265,
  160. 265,0,265,
  161. 265,265,265,
  162. 134218928,"ender tank",
  163. 369,35,369,
  164. 49,380,49,
  165. 369,368,369,
  166. 608,"bat box",
  167. 5,30184,5,
  168. 30239,30239,30239,
  169. 5,5,5,
  170. 882209,"energy crystal",
  171. 331,331,331,
  172. 331,5267,331,
  173. 331,331,331,
  174. 882177,"jetpack",
  175. 30249,30190,30249,
  176. 30249,608,30249,
  177. 348,0,348,
  178. 2850,"energy bridge",
  179. 266,331,266,
  180. 20,264,20,
  181. 266,331,266
  182.  
  183.  
  184.  
  185. }
  186.  
  187. function getItem(id,amount)
  188. gotItem=false
  189. x=0
  190. if s.list(side)~=nil then
  191. if s.list(side)[id]~=nil then
  192. if s.list(side)[id]>=amount then
  193. s.extract(side,id,1,amount)
  194. gotItem=true
  195. else
  196. if s.list(side)[id]>0 then
  197. amount=amount-s.list(side)[id]
  198. s.extract(side,id,1,s.list(side)[id])
  199. end
  200. end
  201. end
  202. end
  203. x=x+1
  204. end
  205.  
  206.  
  207. function craftItem(id,amount,craftId)
  208. recipe=1
  209. print(craftId)
  210. subCraftId[craftId]=id
  211. dumb()
  212. turtle.select(1)
  213. while recipeList[recipe]~=id and recipeList[recipe]~=nil do
  214. recipe=recipe+11
  215. end
  216. if recipeList[recipe]~=id then
  217. gotRecipe=false
  218. else
  219. gotRecipe=true
  220. craftProcess=0
  221. while craftProcess<9 do
  222. if recipeList[recipe+craftProcess+2]~=0 then
  223. getItem(recipeList[recipe+craftProcess+2],amount)
  224. end
  225. if gotItem==false and recipeList[recipe+craftProcess+2]~=0 and recipeList[recipe+craftProcess+1]~=nil then
  226. print("crafte "..recipeList[recipe+craftProcess+2])
  227. craftItem(recipeList[recipe+craftProcess+2],1,craftId+1)
  228. dumb()
  229. else
  230. turtle.select(1)
  231. i.dropUp(craftProcess,amount)
  232. craftProcess=craftProcess+1
  233. end
  234. end
  235. end
  236. if gotItem==true then
  237. c=peripheral.wrap("top")
  238. c.setPattern(0,1,2,3,4,5,6,7,8)
  239. amount2=amount
  240. while amount2>=0 do
  241. c.craft(17)
  242. amount2=amount2-1
  243. end
  244. turtle.suckUp()
  245. if craftId>=1 then
  246. print("craft ferig "..craftId)
  247. craftItem(subCraftId[craftId-1],1,craftId-1)
  248. end
  249. end
  250. return(craftId)
  251. end
  252.  
  253. function dumb()
  254. x=1
  255. while x<=9 do
  256. turtle.suckUp()
  257. slotAmount=turtle.getItemCount(1)
  258. turtle.dropDown()
  259. s.sort(side,slotAmount)
  260. x=x+1
  261. end
  262. turtle.dropDown()
  263. s.sort(side,slotAmount)
  264. turtle.select(1)
  265. end
  266.  
  267. --Terminal
  268.  
  269. x=1
  270. y=0
  271. while true do
  272. x=0
  273. term.clear()
  274. while x<=13 do
  275. if x==1 then term.setCursorPos(1,1) term.write(">") end
  276. term.setCursorPos(2,x)
  277. term.write(recipeList[x*11+2+11*y])
  278. x=x+1
  279. end
  280. event, key, isHeld = os.pullEvent("key")
  281. if key==208 then y=y+1 end
  282. if key==200 then y=y-1 end
  283. if key==28 then
  284. craftItem(recipeList[1+11*(y+1)],1,1)
  285. end
  286. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement