Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if recpipes == nil then recipes = {} end
- function find(list,item)
- for k,v in pairs(list) do
- if k == item then return true end
- end
- return false
- end
- function add(result)
- recipes[result] = {}
- for i= 1, 11 do
- if i ~= 4 and i ~= 8 then
- local data = turtle.getItemDetail(i)
- if data ~= nil then
- if recipes[result][data.name] == nil then recipes[result][data.name] = {{},'empty'} end
- table.insert(recipes[result][data.name][1],i)
- end
- end
- end
- for k,v in pairs(recipes[result]) do
- local count = 0
- for o in pairs(v[1]) do count = count + 1
- recipes[result][k][2] = count
- end
- end
- function search(direction,item)
- inv = peripheral.wrap(direction)
- local list = inv.list()
- for i=1, inv.size() do
- if list[i].name == item then return i,list[i].count end
- end
- return nil,-1
- end
- end
- function craft(result,ammount)
- for i=1, ammount do
- if not find(recipes,result) then return false
- for item, info in pairs(recipes[item]) do
- slot,count = search('top',item)
- if count < ammount then
- if not craft(item,ammount-count) then return false
- end
- else
- chest.pushItems('down',slot,ammount)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement