robocyclone

Turtle hay craft

Feb 27th, 2016
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.25 KB | None | 0 0
  1. function suck()
  2.     local s, i = turtle.inspect()
  3.     if s then
  4.         if i.name == "minecraft:chest" or i.name == "ironchest:BlockIronChest" then
  5.             for i = 1, 9 do turtle.suck() end
  6.             return
  7.         end
  8.     end
  9.     print("No chest infront of turtle")
  10. end
  11.  
  12. function check64()
  13.     local wheatNum = 0
  14.     for i = 1, 16 do
  15.         turtle.select(i)
  16.         wheatNum = wheatNum + turtle.getItemCount()
  17.     end
  18.     print(wheatNum)
  19.     if wheatNum == 576 then
  20.         print(wheatNum .. " >= 576")
  21.         return true
  22.     else print(wheatNum .. " < 576") return false end
  23. end
  24.  
  25. function craftFail()
  26.     print("Craft failed")
  27.     for i = 1, 16 do
  28.         turtle.select(i)
  29.         if turtle.getItemDetail() then print("Item exists") if turtle.getItemDetail().name == "minecraft:wheat" then print("Item is wheat")
  30.             turtle.drop() end
  31.         end
  32.     end
  33. end
  34.  
  35. function sort()
  36.     turtle.select(4)
  37.     turtle.transferTo(10, 64)
  38.     turtle.select(8)
  39.     turtle.transferTo(11, 64)
  40. end
  41.  
  42. function craftSucc()
  43.     for i = 1, 2 do turtle.turnRight() end
  44.     turtle.drop()
  45.     for i = 1, 2 do turtle.turnRight() end
  46. end
  47.  
  48. function craftHay()
  49.     sort()
  50.     if check64 then
  51.         sort()
  52.         print("Enough wheat for hay bales")
  53.         turtle.craft(64)
  54.         craftSucc()
  55.     else
  56.         print("Not enough wheat")
  57.         craftFail()
  58.     end
  59. end
  60.  
  61. while true do
  62.     craftHay()
  63.     sleep(300)
  64. end
Advertisement
Add Comment
Please, Sign In to add comment