Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local c = rednet.lookup('link','craft') or 'self'
- local m = rednet.lookup('link','machine') or 'self'
- local dictionary = run(c,craftAPI.getDict())
- for k,v in pairs(run(m,machineAPI.getDict())) do dictionary[k] = v end
- local input = {...}
- rednet.host('link','computer')
- function run(id,code)
- if id == self then loadstring('return '..code)
- else
- rednet.send(id,code)
- local temp = {rednet.receive()}
- return temp[2]
- end
- end
- function request(count,item,damage)
- if dictionary[item] then
- item = dictionary[item].name
- damage = dictionary[item].damage
- end
- damage = damage or 0
- local tempInfo = 'nil'
- local search = run(c,search(run(craftAPI.getChest()).dir,item,damage))
- if search then
- if search.count == count then return true
- else request(count-search.count,item,damage) end
- end
- if run(c,craftAPI.searchRecipes(item,damage)) then
- tempInfo = run(c,craftAPI.craft(count,item,damage))
- if tempInfo.bool then return true
- else request(tempInfo.count,tempInfo.item,tempInfo.damage) end
- else if run(m,machineAPI.searchRecipes(item,damage)) then
- tempInfo = run(m,machineAPI.craft(count,item,damage))
- if tempInfo.bool then return true
- else request(tempInfo.count,tempInfo.item,tempInfo.damage) end
- else return count,item,damage end
- end
- end
- print(request(input[1],input[2],input[3]))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement