Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local aspectController = 113
- local emptyer = 109
- local ECD = peripheral.wrap("left")
- local ECB = peripheral.wrap("bottom")
- rednet.open("right")
- local analyzer = peripheral.wrap("front")
- local furnace = peripheral.wrap("top")
- local mapSlot = {}
- local mapChest = {}
- function map(chest, direction, chestName)
- for i = 1, 27 do
- -- term.clear()
- term.setCursorPos(1,1)
- print("scanning "..i.."/27 ["..chestName.."]")
- local amnt = chest.pushItem(direction, i, 1, 1)
- if amnt ~= 0 then
- turtle.drop()
- local auram, aspect = analyzer.getAspects()
- turtle.suck()
- chest.pullItem(direction, 1, 1, i)
- rednet.send(emptyer, "emptyplz")
- if aspect == nil then
- aspect = auram
- elseif aspect == "auram" then
- aspect = auram
- end
- print("found "..aspect.." ")
- mapSlot[aspect] = i
- mapChest[aspect] = chestName
- end
- end
- end
- local start = os.time()
- map(ECD, "east", "left")
- map(ECB, "up", "bottom")
- print("turtle ready ! ("..(os.time() - start).."m)")
- while true do
- sender, message = rednet.receive()
- if sender == aspectController then
- local aspect = textutils.unserialize(message)
- local aspectName = string.lower(aspect["name"])
- local aspectCount = math.ceil(aspect["quantity"] / 2)
- local chest = mapChest[aspectName]
- print(aspectCount.." "..aspectName.." ("..chest..")")
- if chest == "bottom" then
- ECB.pushItem("up", mapSlot[aspectName], aspectCount, 1)
- elseif chest == "left" then
- ECD.pushItem("east", mapSlot[aspectName], aspectCount, 1)
- end
- turtle.turnRight()
- turtle.drop()
- turtle.turnLeft()
- sleep(1) -- let the time for the item to get in furnace
- while furnace.getStackInSlot(1) ~= nil do
- sleep(5)
- end
- end
- rednet.send(aspectController, "done")
- end
- rednet.close("right")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement