Advertisement
ecco7777

CC Turtle Autocraft

Oct 22nd, 2015
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. i=peripheral.wrap("right")
  2. turtle.select(16)
  3. side=4
  4. pathLength=5
  5. recipeList={
  6. 5,
  7. 17,0,0,
  8. 0,0,0,
  9. 0,0,0,
  10. 280,
  11. 5,0,0,
  12. 5,0,0,
  13. 0,0,0,
  14. 54,
  15. 5,5,5,
  16. 5,0,5,
  17. 5,5,5,
  18. 61,
  19. 4,4,4,
  20. 4,0,4,
  21. 4,4,4,
  22. 4056,
  23. 0,280,0,
  24. 280,0,280,
  25. 0,280,0,
  26. 4057,
  27. 0,4,0,
  28. 4,4056,4,
  29. 0,4,0,
  30. 33,
  31. 5,5,5,
  32. 4,265,4,
  33. 4,331,4
  34.  
  35. }
  36.  
  37. function getItem(id,amount)
  38. gotItem=false
  39. x=0
  40. while gotItem==false and x<=pathLength do
  41. turtle.placeDown()
  42. s=peripheral.wrap("bottom")
  43. if s.list(side)~=nil then
  44. if s.list(side)[id]~=nil then
  45. if s.list(side)[id]>=amount then
  46. s.extract(side,id,1,amount)
  47. gotItem=true
  48. else
  49. if s.list(side)[id]>0 then
  50. amount=amount-s.list(side)[id]
  51. s.extract(side,id,1,s.list(side)[id])
  52. end
  53. end
  54. end
  55. end
  56. x=x+1
  57. turtle.digDown()
  58. turtle.back()
  59. end
  60. while x>=1 do
  61. turtle.forward()
  62. x=x-1
  63. end
  64. end
  65.  
  66. function craftItem(id,amount)
  67. recipe=1
  68. dumb()
  69. turtle.select(16)
  70. while recipeList[recipe]~=id and recipeList[recipe]~=nil do
  71. recipe=recipe+10
  72. end
  73. if recipeList[recipe]~=id then
  74. gotRecipe=false
  75. else
  76. gotRecipe=true
  77. craftProcess=0
  78. while craftProcess<9 do
  79. if recipeList[recipe+craftProcess+1]~=0 then
  80. getItem(recipeList[recipe+craftProcess+1],amount)
  81. end
  82. if gotItem==false then
  83. print("crafte"..recipeList[recipe+craftProcess+1])
  84. craftItem(recipeList[recipe+craftProcess+1],1)
  85. dumb()
  86. else
  87. turtle.select(1)
  88. i.dropUp(craftProcess,amount)
  89. turtle.select(16)
  90. craftProcess=craftProcess+1
  91. end
  92. end
  93. end
  94. if gotItem==true then
  95. c=peripheral.wrap("top")
  96. c.setPattern(0,1,2,3,4,5,6,7,8)
  97. amount2=amount
  98. while amount2>=0 do
  99. c.craft(17)
  100. amount2=amount2-1
  101. end
  102. turtle.suckUp()
  103. end
  104. end
  105.  
  106. function dumb()
  107. x=1
  108. while x<=9 do
  109. turtle.suckUp()
  110. x=x+1
  111. end
  112. x=1
  113. while x<=15 do
  114. turtle.select(x)
  115. turtle.drop()
  116. x=x+1
  117. end
  118. turtle.select(16)
  119. end
  120.  
  121. --Terminal
  122. while true do
  123. print("[ecco-Storage-System]")
  124. command=io.read()
  125. --Funktions Aufrufe
  126. if string.sub(command,1,3)=="get" then
  127. id=string.sub(command,5,string.find(command,",")-1) id=tonumber(id)
  128. amount=string.sub(command,string.find(command,",")+1) id=tonumber(id) amount=amount+0
  129. getItem(id,amount)
  130. if gotItem==false then print("Nicht genug von "..id.." vorhanden") end
  131. if gotItem==true then print(id.." vorhanden") end
  132. end
  133.  
  134. if string.sub(command,1,5)=="craft" then
  135. id=string.sub(command,7,string.find(command,",")-1) id=tonumber(id)
  136. amount=string.sub(command,string.find(command,",")+1) id=tonumber(id) amount=amount+0
  137. craftItem(id,amount)
  138. if gotItem==false then print("Nicht genug Items vorhanden") end
  139. if gotItem==true then print(id.." wurde gecraftet") end
  140. if gotRecipe==false then print("Kein Rezept für "..id.." gefunden") end
  141. end
  142.  
  143. if string.sub(command,1,4)=="dumb" then
  144. dumb()
  145. end
  146.  
  147. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement