Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local tArgs = {...}
- local file = fs.open("RecipeList/"..tArgs[1].."/path1","r")
- local data = file.readAll()
- local item = 0
- local amount = {}
- local corners = {4,8,12,16,15,14,13}
- file.close()
- print(data)
- path1 = textutils.unserialize(data)
- local craftingGrid = {1,2,3,5,6,7,9,10,11}
- function clearInv(n)
- for i=1,n do
- turtle.select(i)
- turtle.drop()
- end
- end
- function sucknsort()
- for k=1,16 do
- turtle.select(k)
- if turtle.suck() then
- item = turtle.getItemDetail()
- for i,v in pairs(path1) do
- if v == item.name then
- turtle.dropUp()
- table.insert(amount,i,v)
- end
- end
- turtle.dropDown()
- else
- return "empty"
- end
- end
- end
- function switchTo(x)
- if not turtle.transferTo(x) then
- local s = turtle.getSelectedSlot()
- turtle.select(x)
- turtle.transferTo(16)
- turtle.select(s)
- turtle.transferTo(x)
- turtle.select(16)
- turtle.transferTo(s)
- turtle.select(s)
- end
- end
- function buffer()
- for i=1,16 do
- turtle.select(16)
- if turtle.suckUp() then
- item = turtle.getItemDetail()
- for i,v in pairs(path1) do
- if v == item.name then
- turtle.transferTo(i)
- end
- end
- if turtle.getItemCount() > 0 then
- turtle.drop()
- end
- end
- end
- end
- function sort()
- for n,s in ipairs(craftingGrid) do
- turtle.select(s)
- item = turtle.getItemDetail()
- if item and item.count > 1 then
- turtle.drop(item.count-1)
- end
- for k,v in pairs(path1) do
- if item and item.name==v and turtle.getSelectedSlot() ~= k then
- turtle.drop()
- end
- end
- end
- --if there are items that are not in the 3x3 grid then drop them up
- for i,v in ipairs(corners) do
- turtle.select(v)
- if turtle.getItemSpace()~=64 then
- turtle.drop()
- end
- end
- end
- function run()
- amount = {}
- turtle.turnRight()
- while sucknsort()~="empty" do end
- buffer()
- sort()
- turtle.select(16)
- if not turtle.craft() then
- textutils.slowPrint("Error: Insufficient Ingredients")
- clearInv(16)
- shell.run("go lt")
- error()
- else
- clearInv(15)
- turtle.turnLeft()
- turtle.turnLeft()
- turtle.select(16)
- turtle.drop()
- turtle.turnRight()
- end
- end
- run()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement