Advertisement
bcash8

Chickens 1.0

Nov 30th, 2022 (edited)
902
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.10 KB | None | 0 0
  1. local breederName = "chickens:breeder"
  2. local chickenChest = peripheral.wrap("front")
  3. local lightPos = "front"
  4. function cleanAllButNest()
  5.     local nest = 1
  6.     for i = 1, 16 do
  7.         local d = turtle.getItemDetail(i)
  8.  
  9.         if d then
  10.             if d.name ~= breederName then
  11.                 turtle.select(i)
  12.                 turtle.dropDown()
  13.             else
  14.                 nest = i
  15.             end
  16.         end
  17.     end
  18.  
  19.     turtle.select(nest)
  20.     turtle.transferTo(1)
  21.     turtle.select(1)
  22. end
  23.  
  24. function flashLight(n)
  25.     for i=1,n do
  26.         rs.setOutput(lightPos, false)
  27.         sleep(0.3)
  28.         rs.setOutput(lightPos, true)
  29.         sleep(0.3)
  30.     end
  31.     rs.setOutput(lightPos, false)
  32. end
  33.  
  34. local slot = 15
  35. local generations = 0
  36. term.clear()
  37. term.setCursorPos(1,1)
  38. term.write("Generation: " .. generations)
  39.  
  40. flashLight(5)
  41.  
  42. while true do
  43.    
  44.     turtle.select(slot)
  45.  
  46.     if turtle.suckDown() then
  47.         if slot == 16 then
  48.             turtle.drop()
  49.             turtle.select(15)
  50.             turtle.drop()
  51.  
  52.             turtle.select(1)
  53.             turtle.digDown()
  54.  
  55.             cleanAllButNest()
  56.             sleep(2)
  57.             turtle.placeDown()
  58.  
  59.  
  60.             turtle.suckUp(2)
  61.             turtle.dropDown(2)
  62.  
  63.             local chest = chickenChest.getItemDetail(1)
  64.  
  65.             if chest.count == 1 then
  66.                 chickenChest.pushItems("bottom", 1, 1, 1)
  67.                 chickenChest.pushItems("bottom", 2, 1, 2)
  68.             else
  69.                 chickenChest.pushItems("bottom", 1, 1, 1)
  70.                 chickenChest.pushItems("bottom", 1, 1, 2)
  71.             end
  72.  
  73.             slot = 15
  74.             generations = generations + 1
  75.             term.clear()
  76.             term.setCursorPos(1,1)
  77.             term.write("Generation: " .. generations)
  78.  
  79.             if generations >= 6 then
  80.                 flashLight(3)
  81.                 rs.setOutput(lightPos, true)
  82.             else
  83.                 rs.setOutput(lightPos, false)
  84.             end
  85.         else
  86.             slot = 16
  87.         end
  88.  
  89.         sleep(45)
  90.     else
  91.         sleep(2)
  92.     end  
  93. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement