Advertisement
guitarplayer616

AutoCook Backup 2 Abridged

May 27th, 2015
287
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. local tArgs = {...}
  2. local file = fs.open("RecipeList/"..tArgs[1].."/path1","r")
  3. local data = file.readAll()
  4. file.close()
  5. local path1 = textutils.unserialize(data)
  6.  
  7. local item = nil
  8. local amount = 0
  9. local count = 0
  10. for i,v in pairs(path1) do
  11. count = count + 1
  12. end
  13. print(data)
  14.  
  15. local craftingGrid = {1,2,3,5,6,7,9,10,11}
  16.  
  17. function clearInv(n,p)
  18. local s = 1
  19. if p == nil then
  20. p = 1
  21. elseif math.abs(p)~=p then
  22. s = n
  23. n = 1
  24. end
  25. for i=s,n,p do
  26. turtle.select(i)
  27. turtle.dropDown()
  28. end
  29. end
  30.  
  31. function buffer()
  32. turtle.select(16)
  33. while amount~=count and turtle.suck() do
  34. item = turtle.getItemDetail()
  35. for i,v in pairs(path1) do
  36. if v == item.name then
  37. if turtle.transferTo(i,1) then
  38. amount = amount + 1
  39. end
  40. end
  41. end
  42. if turtle.getItemCount() > 0 then
  43. turtle.dropDown()
  44. end
  45. end
  46. end
  47.  
  48. function craft()
  49. if not turtle.craft() then
  50. textutils.slowPrint("Error: Insufficient Ingredients")
  51. clearInv(15,-1)
  52. error()
  53. else
  54. if turtle.getSelectedSlot() ~= 16 then
  55. turtle.select(16)
  56. end
  57. turtle.dropUp()
  58. clearInv(15,-1)
  59. end
  60. end
  61.  
  62. function run()
  63. buffer()
  64. craft()
  65. end
  66.  
  67. buffer()
  68. craft()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement