Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- rednet.open("right")
- recvID = 69
- scanned = false
- local af = peripheral.wrap("left") --Alchemical Furnace
- local afdirection = "west" -- Alchemical Furnace direction
- local delay = 0.8 --Refresh delay to check if beans are cooking
- local anDir = "down" --AspectAnalyzer position
- local aa = peripheral.wrap("bottom") --AspectAnalyzer
- c = peripheral.wrap("top") --Golden Chest for beans
- chestDir = "top" -- direction of the Golden CHest for beans
- local beans = {}
- function refillJar(asp, amo)
- print("Adding " .. amo .. " to " .. asp .. ".")
- if asp~=nil and amo > 0 then
- print("Refilling " .. asp)
- c.pushItem(anDir , beans[asp], amo)
- turtle.turnLeft()
- turtle.drop()
- turtle.turnRight()
- waitForBeans()
- print("Done Cooking " .. asp)
- rednet.send(recvID ,"refilled")
- end
- end
- function scanBeans()
- for i = 1, 51 do
- c.pushItem(anDir , i, 1)
- turtle.dropDown()
- if aa.hasItem() and aa.itemHasAspects() then
- beans[aa.getAspects()] = i
- print(aa.getAspects() .. ": " .. beans[aa.getAspects()])
- turtle.dropDown()
- end
- if aa.hasItem() then
- turtle.suckDown()
- turtle.drop()
- end
- end
- end
- function waitForBeans()
- sleep(2)
- local count = 0
- while count < 3 do
- if af.getStackInSlot(1) == nil then
- count = count + 1
- else
- count = 0
- end
- print("Waiting for beans to cook (" .. 3-count .. ")")
- sleep(delay)
- end
- end
- while true do
- id,msg = rednet.receive()
- print(msg)
- if msg == "scan" then
- if not scanned then
- scanBeans()
- scanned = true
- end
- rednet.send(recvID ,"scanned")
- elseif msg ~= null then
- local t = textutils.unserialize(msg)
- refillJar(t[1], t[2])
- end
- end
- rednet.close("right")
Advertisement
Add Comment
Please, Sign In to add comment