Advertisement
denesik

craft_max

Nov 17th, 2012
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.70 KB | None | 0 0
  1. dofile("denesik_lib.lua")
  2.  
  3. --listSide={"front","top","down",
  4. --          "left","right","back"}
  5. --  1 2 3 4 5
  6. ct={1,2,3,4,5}
  7. cd={6,7,8,9,10}
  8.  
  9. craft={ct[1],ct[1],ct[1],
  10.        ct[1],ct[1],ct[1],
  11.        ct[1],ct[1],ct[1]}
  12. slotItemCount=64
  13. slotFuel=cd[5]
  14.  
  15. function isRecipe()
  16.   for i=1,9 do
  17.     if(craft[i]~=0)then
  18.       if(turtle.getItemCount(numCraftToSlot(i))==0)then
  19.         return false
  20.       end
  21.     end
  22.   end
  23.   return true
  24. end
  25.  
  26. function forward()
  27.   for i=1,5 do
  28.     turtle.forward()
  29.   end
  30. end
  31.  
  32. function _suckUp(n)
  33.   for i=1,9 do
  34.     slot=numCraftToSlot(i)
  35.     if(craft[i]==n and turtle.getItemCount(slot)==0)then
  36.       while(turtle.getItemCount(slot)==0)do
  37.         suckUp(slot,slotItemCount)
  38.       end
  39.     end
  40.   end
  41. end
  42.  
  43. function _suckDown(n)
  44.   for i=1,9 do
  45.     slot=numCraftToSlot(i)
  46.     if(craft[i]==n and turtle.getItemCount(slot)==0)then
  47.       while(turtle.getItemCount(slot)==0)do
  48.         suckDown(slot,slotItemCount)
  49.       end
  50.     end
  51.   end
  52. end
  53.  
  54. function refuel()
  55.   if(turtle.getFuelLevel()<=20)then
  56.     chest=slotFuel
  57.     if(slotFuel>5)then
  58.       chest=slotFuel-5
  59.     end
  60.     for i=1,chest-1 do
  61.       turtle.back()
  62.     end
  63.     turtle.select(8)
  64.     while(turtle.getFuelLevel()<=20)do
  65.       if(slotFuel>5)then
  66.         turtle.suckDown()
  67.       else
  68.         turtle.suckUp()
  69.       end
  70.       turtle.refuel()
  71.     end
  72.     forward()
  73.   end
  74. end
  75.  
  76. forward()
  77.  
  78. while true do
  79.   refuel()
  80.   for i=1,5 do
  81.     _suckUp(ct[i])
  82.     _suckDown(cd[i])
  83.     if(isRecipe())then
  84.       break
  85.     end
  86.     turtle.back()
  87.   end
  88.   forward()
  89.   turtle.select(4)
  90.   while(isRecipe())do
  91.     turtle.craft()
  92.     while(turtle.getItemCount(4)~=0)do
  93.       turtle.drop()
  94.     end
  95.   end
  96.  
  97. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement