Advertisement
iekiekiek

autoproduce stew computecraft

Nov 17th, 2019
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.62 KB | None | 0 0
  1. --Made by iekiekiek for computercraft
  2. local info = turtle.getItemDetail()
  3. local count = turtle.getItemCount()
  4.  
  5.  
  6. local stew = "minecraft:mushroom_stew"
  7. local log = "minecraft:log"
  8. --local wood = "minecraft:planks"
  9. --local slab = "minecraft:wooden_slab"
  10. --local bowl = "minecraft:bowl"
  11.  
  12. --is the turtle clear of everything ?
  13. local function turtle_clear()
  14.    
  15.     local addition = 0
  16.     for i = 1,16,1 do
  17.         turtle.select(i)
  18.         local count = turtle.getItemCount()
  19.         addition = addition + count
  20.     end
  21.     turtle.select(1)
  22.     if addition == 0
  23.     then
  24.         return true
  25.     else
  26.         return false
  27.     end
  28. end
  29.  
  30. --crafts the bowls
  31. local function craft()
  32.     turtle.select(1)
  33.     turtle.suckDown(3)
  34.  
  35.     local info = turtle.getItemDetail()
  36.     local count = turtle.getItemCount()
  37.  
  38.     if count == 3 and info.name == log
  39.         then
  40.             turtle.craft() --so we have 12 planks in the slot 1
  41.             --we have to move and divide them for slabs
  42.             turtle.transferTo(2,4)
  43.             turtle.transferTo(3,4)
  44.             turtle.craft()-- so we have 24 slabs in the first slot
  45.             turtle.transferTo(3,8)
  46.             turtle.transferTo(6,8)
  47.             turtle.craft()-- so we have 32 bowls in the first slot
  48.         else
  49.         print("this is no wood or not enough")
  50.     end
  51.  
  52. end
  53.  
  54.  
  55. --dropUp the stews
  56. local function don()
  57.     turtle.select(1)
  58.     while turtle.getItemCount(1) > 1 and turtle.getItemCount(2) == 0 do --this is for avoid overflow and dropUp the stew
  59.         turtle.place()
  60.         turtle.select(2)
  61.         turtle.dropUp()
  62.         turtle.select(1)
  63.     end
  64.     if turtle.getItemCount(2) == 0 then --because the last stew will transform and stay in the slot 1
  65.         turtle.place()
  66.         turtle.dropUp()
  67.     end
  68. end
  69.  
  70. --main--
  71. while true do
  72.     if turtle_clear() == true
  73.         then
  74.             print("Thanks for using iekiekiek's delicious <autoproduce stew> code, master")
  75.             craft()
  76.             don()
  77.         else
  78.             turtle.select(2)
  79.             if turtle.getItemCount() > 0
  80.                 then
  81.                     local info = turtle.getItemDetail()
  82.                     if info.name == stew then
  83.                         turtle.dropUp()
  84.                     end
  85.             end
  86.             turtle.select(1)
  87.             if turtle.getItemCount() > 0
  88.                 then
  89.                     local info = turtle.getItemDetail()
  90.                     if info.name == stew then
  91.                         turtle.dropUp()
  92.                     end
  93.             end
  94.             don()
  95.             os.sleep(10)
  96.     end
  97. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement