Advertisement
Link712011

bakery

Nov 20th, 2015
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.49 KB | None | 0 0
  1. function select_fuel()
  2.     local slot = 1
  3.     local data = turtle.getItemDetail(slot)
  4.     while slot <= 16 do
  5.         if data and (data.name == "minecraft:lava_bucket" or data.name == "minecraft:coal" or data.name == "minecraft:planks" or data.name == "minecraft:log") then
  6.             break
  7.         end
  8.         slot = slot + 1
  9.         if slot <= 16 then
  10.             turtle.select(slot)
  11.             data = turtle.getItemDetail(slot)
  12.         end
  13.     end
  14.     if (slot > 16) then
  15.         print("Refuel me sempaiiiiii !")
  16.         sleep(5)
  17.         os.shutdown()
  18.     end
  19.     turtle.select(slot)
  20. end
  21.  
  22. function check_fuel()
  23.     if turtle.getFuelLevel() < 10 then
  24.         select_fuel()
  25.         if turtle.refuel(1) == false then
  26.             print("Refuel me sempaiiiiii !")
  27.             os.shutdown()
  28.         end
  29.     end
  30. end
  31.  
  32. function select_seed()
  33.     local slot = 1
  34.     while slot <= 16 do
  35.         local data = turtle.getItemDetail(slot)
  36.         if data and data.name == "minecraft:wheat_seeds" then
  37.             turtle.select(slot)
  38.             return true
  39.         end
  40.         slot = slot + 1
  41.     end
  42.     return false
  43. end
  44.  
  45. function ble_mature()
  46.     local success, data = turtle.inspect()
  47.     if success and data.name == "minecraft:wheat" and data.metadata == 7 then return true else return false end
  48. end
  49.  
  50. function craft_bread()
  51.     local slot = 1
  52.     while slot <= 16 and turtle.getItemDetail(slot) do
  53.         slot = slot + 1
  54.     end
  55.     if slot <= 16 then
  56.         turtle.select(slot)
  57.         turtle.craft()
  58.     end
  59.     turtle.select(1)
  60. end
  61.  
  62. function put_product_in_chest()
  63.     local slot = 1
  64.     local flag = false
  65.     while slot <= 16 do
  66.         local data = turtle.getItemDetail(slot)
  67.         if data and (data.name == "minecraft:bread" or (data.name == "minecraft:wheat_seeds" and flag == true)) then
  68.             turtle.select(slot)
  69.             turtle.drop()
  70.         elseif data and data.name == "minecraft:wheat_seeds" then
  71.             flag = true
  72.         end
  73.         slot = slot + 1
  74.     end
  75. end
  76.  
  77. while true do
  78.     local x = 0
  79.     while x < 6 do
  80.         check_fuel()
  81.         if ble_mature() then turtle.dig() end
  82.         if select_seed() then turtle.place() end
  83.         turtle.turnLeft()
  84.         turtle.forward()
  85.         turtle.turnRight()
  86.         x = x + 1
  87.     end
  88.     if ble_mature() then turtle.dig() end
  89.     if select_seed() then turtle.place() end
  90.     turtle.turnLeft()
  91.     turtle.turnLeft()
  92.     while x > 0 do
  93.         check_fuel()
  94.         if ble_mature() then turtle.dig() end
  95.         if select_seed() then turtle.place() end
  96.         turtle.turnLeft()
  97.         turtle.forward()
  98.         turtle.turnRight()
  99.         x = x - 1
  100.     end
  101.     check_fuel()
  102.     turtle.forward()
  103.     craft_bread()
  104.     put_product_in_chest()
  105.     craft_bread()
  106.     put_product_in_chest()
  107.     turtle.turnRight()
  108.     turtle.turnRight()
  109.     turtle.forward()
  110.     sleep(400)
  111. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement