Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --v 0.3
- rednet.open("right")
- function dropAll()
- for i = 1, 16 do
- turtle.select(i)
- turtle.dropUp()
- end
- end
- function craft(t, count)
- assert(#t == 9, "error recept")
- local i = 1
- local craftSlot = {
- [1] = 1, [2] = 2, [3] = 3,
- [4] = 5, [5] = 6, [6] = 7,
- [7] = 9, [8] = 10, [9] = 11
- }
- turtle.select(4)
- while turtle.suckUp() do
- local item = turtle.getItemDetail()
- for i = 1, 9 do
- if item.name == t[i] then
- turtle.transferTo(craftSlot[i], count)
- end
- end
- end
- turtle.craft()
- dropAll()
- end
- function read()
- local craftSlot = {
- [1] = 1, [2] = 2, [3] = 3,
- [4] = 5, [5] = 6, [6] = 7,
- [7] = 9, [8] = 10, [9] = 11
- }
- local slots = {}
- for i, numSlot in pairs(craftSlot) do
- turtle.select(numSlot)
- local item = turtle.getItemDetail()
- if item then
- table.insert(slots, item.name)
- else
- table.insert(slots, "air")
- end
- end
- return slots
- end
- while true do
- local id, recept = rednet.receive()
- if type(recept) == "table" and recept.type == "crafting" then
- craft(recept.slots, recept.count or 1)
- elseif recept == "read" then
- local bench = read()
- --try to craft
- turtle.select(4)
- if turtle.craft() then
- local anItem = turtle.getItemDetail()
- rednet.send(id, {craft = bench, result=anItem.name})
- else
- rednet.send(id, false)
- end
- end
- end
Add Comment
Please, Sign In to add comment