Allomancer

Chicken Breeder for Roost 1.12.2

May 7th, 2023
1,109
1
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.61 KB | Source Code | 1 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 false
  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.   if not select_item('chickens:breeder') then
  59.     select_item('roost:breeder')
  60.   end
  61.   while not PLACE() do sleep() end
  62.   select_seeds()
  63.   DROP()
  64.   for i = 1,2 do
  65.     if not select_item('chickens:chicken_item') then
  66.         select_item('roost:chicken')
  67.     end
  68.     DROP()--math.ceil(turtle.getItemDetail().count / 2))
  69.   end
  70. --   drop_in_slot_2()
  71.   while select_item('chickens:chicken_item') do
  72.     DROP()
  73.     DUMP()
  74.   end
  75.   while select_item('roost:chicken') do
  76.     DROP()
  77.     DUMP()
  78.   end
  79. end
  80.  
  81. -- function drop_in_slot_2()
  82. --   if not DETECT() then
  83. --     print('Waiting for storage device on side: ' .. STORAGE_SIDE)
  84. --     repeat sleep() until DETECT()
  85. --  STORAGE = peripheral.wrap(STORAGE_SIDE)
  86. --     print('Resuming')
  87. --   end
  88. --   DETECT()
  89. --   STORE()
  90. --   STORAGE.pushItems(BREEDER_SIDE, 1, 16, 2)
  91. -- end
  92.  
  93. function select_item(name)
  94.   for i = 1, 16, 1 do
  95.     if turtle.getItemDetail(i) then
  96.       if turtle.getItemDetail(i).name == name then
  97.         turtle.select(i)
  98.         return i
  99.       end
  100.     end
  101.   end
  102.   return false
  103. end
  104.  
  105. function select_seeds()
  106.   select_item('minecraft:wheat_seeds')
  107.   select_item('minecraft:pumpkin_seeds')
  108.   select_item('minecraft:melon_seeds')
  109.   select_item('minecraft:beetroot_seeds')
  110.   select_item('immersiveengineering:seed')
  111.   select_item('farmersdelight:cabbage_seeds')
  112.   select_item('farmersdelight:tomato_seeds')
  113.   select_item('supplementaries:flax_seeds')
  114.   select_item('farmersdelight:rice')
  115.   select_item('ars_nouveau:magebloom_crop')
  116. end
  117.  
  118. function sleep()
  119.   os.sleep(0.05)
  120. end
  121.  
  122. -- assign directional turtle functions
  123. if BREEDER_SIDE == 'top' then
  124.   DROP = turtle.dropUp
  125.   PLACE = turtle.placeUp
  126.   DIG = turtle.digUp
  127.   SUCK = turtle.suckUp
  128. elseif BREEDER_SIDE == 'bottom' then
  129.   DROP = turtle.dropDown
  130.   PLACE = turtle.placeDown
  131.   DIG = turtle.digDown
  132.   SUCK = turtle.suckDown
  133. else
  134.   DROP = turtle.drop
  135.   PLACE = turtle.place
  136.   DIG = turtle.dig
  137.   SUCK = turtle.suck
  138. end
  139. if DUMP_SIDE == 'top' then
  140.   DUMP = turtle.dropUp
  141. elseif DUMP_SIDE == 'bottom' then
  142.   DUMP = turtle.dropDown
  143. else DUMP = turtle.drop
  144. end
  145. if STORAGE_SIDE == 'top' then
  146.   STORE = turtle.dropUp
  147.   DETECT = turtle.detectUp
  148. elseif STORAGE_SIDE == 'bottom' then
  149.   STORE = turtle.dropDown
  150.   DETECT = turtle.detectDown
  151. else
  152.   STORE = turtle.drop
  153.   DETECT = turtle.detect
  154. end
  155.  
  156. main()
  157.  
  158.  
Advertisement
Add Comment
Please, Sign In to add comment