Advertisement
kssr3951

colorful sheep farm

Apr 11th, 2015
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.09 KB | None | 0 0
  1. -- --------
  2. -- colorful sheep farm
  3. -- --------
  4. local f = function() while not turtle.forward() do end end
  5. local b = function() while not turtle.back() do end end
  6. local l = turtle.turnLeft
  7. local r = turtle.turnRight
  8. local u = function() while not turtle.up() do end end
  9. local d = function() while not turtle.down() do end end
  10. local function exec(funcs)
  11.   for i, f in ipairs(funcs) do
  12.     f()
  13.   end
  14. end
  15. local sel = turtle.select
  16. local cut = function() sel(1) turtle.place() end
  17. -- --------
  18. -- main
  19. -- --------
  20. while true do
  21.   local shearsCnt = 12
  22.   for h = 1, shearsCnt do
  23.     print("fuel = " .. tostring(turtle.getFuelLevel()))
  24.     exec({f,r,f,f,f,f,f,f,f,f,f,f,f,r,f,f,l,f})
  25.     cut()
  26.     for i = 1, 6 do
  27.       exec({b,r,f,f,l,f})
  28.       cut()
  29.     end
  30.     exec({b,l,f,l,f})
  31.     cut()
  32.     for i = 1, 5 do
  33.       exec({b,r,f,f,l,f})
  34.       cut()
  35.     end
  36.     exec({b,r,f,f,f,l})
  37.     exec({f,f,f,f,f,f,f,f,f,f,f})
  38.     exec({l,f,f})
  39.     for i = 2, 16 do
  40.       sel(i)
  41.       turtle.dropDown()
  42.     end
  43.     exec({r,r,f,f,r,f,f,f,f,f,r,f,f,f,l,f})
  44.     for i = 1, 5 do
  45.       cut()
  46.       exec({b,r,f,f,l,f})
  47.     end
  48.     cut()
  49.     exec({l,l,f,f})
  50.     for i = 1, 5 do
  51.       cut()
  52.       exec({b,r,f,f,l,f})
  53.     end
  54.     cut()
  55.     exec({b,r,f,f,f,l,f,f,f,f,f,l,f,f})
  56.     for i = 2, 16 do
  57.       sel(i)
  58.       if 0 < turtle.getItemCount(i) then
  59.         local rslt = turtle.dropDown()
  60.         if false == rslt then
  61.           exec({l,l,f})
  62.           error("wool chest is full!!")
  63.         end
  64.       end
  65.     end
  66.     if h == shearsCnt then
  67.       sel(1)
  68.       turtle.dropDown()
  69.       exec({f,r})
  70.       turtle.suck()
  71.       if 0 == turtle.getItemCount() then
  72.         exec({r,f,f})
  73.         error("no shears!! please set shears at slot1.")
  74.       end
  75.       exec({r,f,l})
  76.     else
  77.       exec({r})
  78.     end
  79.     sel(16)
  80.     if turtle.getFuelLevel() <= 20000 - 160 then
  81.       turtle.suck(2)
  82.       turtle.refuel()
  83.     end
  84.     sel(1)
  85.     exec({r,f})
  86.     term.write("sleep : ")
  87.     for i = 12, 1, -1 do
  88.       term.write(tostring(i).." ")
  89.       os.sleep(6)
  90.     end
  91.     print("go!")
  92.   end
  93. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement