Allomancer

Chicken Breeder 101010

Dec 15th, 2022 (edited)
4,686
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.36 KB | Source Code | 0 0
  1. --[[
  2.   Chicken Breeder 101010
  3.   Author - u/MistbornKnives
  4.  
  5.   breeds a full stack of perfect chickens.
  6. --]]
  7.  
  8. OPTIONS = {'top', 'bottom', 'front'}
  9. -- configure block location here:
  10. local BREEDER_SIDE = 'top'
  11. local DUMP_SIDE = 'bottom'
  12. local STORAGE_SIDE = 'front'
  13.  
  14. local arg = { ... }
  15. for _,v in pairs(OPTIONS) do
  16.   if arg[1] == v then BREEDER_SIDE = v end
  17.   if arg[2] == v then DUMP_SIDE = v end
  18.   if arg[3] == v then STORAGE_SIDE = v end
  19. end
  20.  
  21. local function main()
  22.   init()
  23.   local seeds_used = 0
  24.   repeat
  25.     if BREEDER.getItemDetail(3) == nil then
  26.       print('Waiting for seeds')
  27.       while BREEDER.getItemDetail(3) == nil do
  28.         select_seeds()
  29.         DROP()
  30.         sleep()
  31.       end
  32.     end
  33.     turtle.select(1)
  34.     -- wait for new chicken
  35.     while not SUCK() do sleep() end
  36.     reset()
  37.     seeds_used = seeds_used + 1
  38.     print(seeds_used)
  39.     local slot_one = BREEDER.getItemDetail(1).count
  40.     local slot_two = BREEDER.getItemDetail(2).count
  41.   until slot_one + slot_two >= 16
  42.   DIG()
  43.   print('chickens finished')
  44. end
  45.  
  46. function init()
  47.   turtle.select(1)
  48.   while SUCK() do end
  49.   STORAGE = peripheral.wrap(STORAGE_SIDE)
  50.   reset()
  51.   reset()
  52.   BREEDER = peripheral.wrap(BREEDER_SIDE)
  53. end
  54.  
  55. function reset()
  56.   turtle.select(1)
  57.   DIG()
  58.   select_item('chickens:breeder')
  59.   while not PLACE() do sleep() end
  60.   select_seeds()
  61.   DROP()
  62.   select_item('chickens:chicken_item')
  63.   DROP(math.ceil(turtle.getItemDetail().count / 2))
  64.   drop_in_slot_2()
  65.   while select_item('chickens:chicken_item') do
  66.     DROP()
  67.     DUMP()
  68.   end
  69. end
  70.  
  71. function drop_in_slot_2()
  72.   if not DETECT() then
  73.     print('Waiting for storage device on side: ' .. STORAGE_SIDE)
  74.     repeat sleep() until DETECT()
  75.     STORAGE = peripheral.wrap(STORAGE_SIDE)
  76.     print('Resuming')
  77.   end
  78.   DETECT()
  79.   STORE()
  80.   STORAGE.pushItems(BREEDER_SIDE, 1, 16, 2)
  81. end
  82.  
  83. function select_item(name)
  84.   for i = 1, 16, 1 do
  85.     if turtle.getItemDetail(i) then
  86.       if turtle.getItemDetail(i).name == name then
  87.         turtle.select(i)
  88.         return i
  89.       end
  90.     end
  91.   end
  92.   return false
  93. end
  94.  
  95. function select_seeds()
  96.   select_item('minecraft:wheat_seeds')
  97.   select_item('minecraft:pumpkin_seeds')
  98.   select_item('minecraft:melon_seeds')
  99.   select_item('minecraft:beetroot_seeds')
  100.   select_item('immersiveengineering:seed')
  101.   select_item('farmersdelight:cabbage_seeds')
  102.   select_item('farmersdelight:tomato_seeds')
  103.   select_item('supplementaries:flax_seeds')
  104.   select_item('farmersdelight:rice')
  105.   select_item('ars_nouveau:magebloom_crop')
  106. end
  107.  
  108. function sleep()
  109.   os.sleep(0.05)
  110. end
  111.  
  112. -- assign directional turtle functions
  113. if BREEDER_SIDE == 'top' then
  114.   DROP = turtle.dropUp
  115.   PLACE = turtle.placeUp
  116.   DIG = turtle.digUp
  117.   SUCK = turtle.suckUp
  118. elseif BREEDER_SIDE == 'bottom' then
  119.   DROP = turtle.dropDown
  120.   PLACE = turtle.placeDown
  121.   DIG = turtle.digDown
  122.   SUCK = turtle.suckDown
  123. else
  124.   DROP = turtle.drop
  125.   PLACE = turtle.place
  126.   DIG = turtle.dig
  127.   SUCK = turtle.suck
  128. end
  129. if DUMP_SIDE == 'top' then
  130.   DUMP = turtle.dropUp
  131. elseif DUMP_SIDE == 'bottom' then
  132.   DUMP = turtle.dropDown
  133. else DUMP = turtle.drop
  134. end
  135. if STORAGE_SIDE == 'top' then
  136.   STORE = turtle.dropUp
  137.   DETECT = turtle.detectUp
  138. elseif STORAGE_SIDE == 'bottom' then
  139.   STORE = turtle.dropDown
  140.   DETECT = turtle.detectDown
  141. else
  142.   STORE = turtle.drop
  143.   DETECT = turtle.detect
  144. end
  145.  
  146. main()
Advertisement
Add Comment
Please, Sign In to add comment