Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- rednet.open("top")
- rednet.host("storage", tostring(os.getComputerID()))
- while true do
- -- wait for computer
- print("awaiting request")
- local from,id = rednet.receive("item_request_turtle")
- print("request for "..id)
- -- todo binary search / sorting?
- for i = 1, 16 do
- local item = turtle.getItemDetail(i)
- -- found correct id
- if (item ~= nil) and (item.name == id) then
- -- send server amount
- print("found ".. item.count .. " of " .. item.name)
- rednet.send(from, item.count, "item_request_turtle")
- -- get amount to extract from server
- local from,count = rednet.receive("item_request_turtle")
- -- drop items
- turtle.select(i)
- turtle.drop(count)
- end
- end
- -- terminate request
- rednet.send(from, 0, "item_request_turtle")
- end
- rednet.close("top")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement