Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- os.loadAPI('apis.lua')
- local p
- local BEE_INO_SLOT = 3
- local BEE_RES_START_SLOT = 4
- local BEE_RES_END_SLOT = 9
- local BEE_FIN_SLOT = 10
- local SERUM_SLOT = 16
- local args = {...}
- returnOffset = tonumber(args[1])
- function refillSerum(slot)
- TL2.pathtofreely(0, 1+returnOffset, -1)
- turtle.select(slot)
- turtle.dropDown()
- TL2.pathtofreely(0, 0, -1)
- p = peripheral.wrap("bottom")
- end
- function ejectSerum(serum, slot)
- print("ejecting to slot " .. slot)
- p.pushItemIntoSlot("up", SERUM_SLOT, 1, slot)
- refillSerum(slot)
- end
- function getFinishedBees()
- local tslot = 0
- for i = 10, 15, 1 do
- bees = p.getStackInSlot(i)
- if bees then
- p.pushItemIntoSlot("up", i, bees.qty, tslot)
- tslot = tslot+1
- end
- end
- end
- function inoculate()
- TL2.pathto(0, 0, -1)
- p = peripheral.wrap("bottom")
- -- insert bees
- local slot = BEE_INO_SLOT
- for i = 1, 16, 1 do
- local qty = turtle.getItemCount(i)
- if qty > 0 then
- for k = BEE_RES_START_SLOT, BEE_RES_END_SLOT, 1 do
- if not p.getStackInSlot(k) then
- slot = k
- break
- end
- end
- print("pulling " .. i .. " to " .. slot)
- p.pullItemIntoSlot("up", i, qty, slot)
- end
- end
- -- process serums
- for i = 1, 16, 1 do
- if turtle.getItemCount(i) > 0 then
- -- insert serum
- print("inserting serum from slot " .. i)
- TL2.setHeading(0)
- p.pullItemIntoSlot("up", i, 1, SERUM_SLOT)
- -- Move bees back if already
- -- processed
- if not p.getStackInSlot(BEE_INO_SLOT) then
- for j = 15, 10, -1 do
- if p.getStackInSlot(j) then
- p.swapStacks(j, j-6)
- end
- end
- end
- while true do
- serum = p.getStackInSlot(SERUM_SLOT)
- if not p.getStackInSlot(BEE_INO_SLOT) then
- -- eject serum
- if serum then
- ejectSerum(serum, i)
- break
- end
- elseif serum and serum.dmg == 16 then
- --ender.broadcastMsg("beechat", "Reload " .. serum.name .. " when refilled")
- print('serum empty ' .. serum.name)
- ejectSerum(serum, i)
- end
- os.sleep(10)
- end
- end
- end
- --ender.broadcastMsg("beechat", "Finished inoculation")
- --getFinishedBees()
- TL2.pathto(0, 0, 0, 0)
- TL2.emptySlots(turtle.dropUp)
- end
- while true do
- os.sleep(5)
- if turtle.getItemCount(1) > 0 then
- os.sleep(5)
- inoculate()
- os.shutdown()
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement