Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- modem1 = 6565
- modem2 = 6566
- modem3 = 6567
- modem4 = 6568
- local channel = 3000
- if fs.exists(".channel") then
- local f = fs.open(".channel","r")
- local n = f.readLine()
- if not tonumber(n) then error("contents of .channel is not a number") end
- channel = tonumber(n)
- f.close()
- end
- os.setComputerLabel("Hopper [VERT] | "..channel)
- local modems = {peripheral.find("modem")}
- if #modems == 0 then error("no modems attached") end
- local modem = modems[1]
- modem.open(channel)
- while turtle.up() do end
- function normalOperation()
- while true do
- local e,side,chnl,rChnl,msg,dist = os.pullEvent("modem_message")
- if chnl == channel then
- while turtle.down() do end
- local b,insp = turtle.inspectDown()
- if b and (insp.name == "minecraft:chest" or insp.name == "minecraft:trapped_chest") then
- while turtle.suckDown() and turtle.getItemCount(16) == 0 do turtle.select(1) end
- end
- while turtle.up() do end
- for slot = 1,16 do
- if turtle.getItemCount(slot) ~= 0 then
- turtle.select(slot)
- turtle.dropUp()
- end
- end
- end
- end
- end
- function modemListener()
- while true do
- local e,side,chnl,rChnl,msg,dist = os.pullEvent("modem_message")
- if chnl == modem1 then
- local x,y,z = gps.locate()
- local inv = {}
- for slot = 1,16 do
- local detail = turtle.getItemDetail(slot)
- if detail == nil then
- inv[slot] = {}
- else
- inv[slot] = detail
- end
- end
- modem.transmit(rChnl,chnl,{type="infoHopperResponse",fuel=turtle.getFuelLevel(),location={x=x,y=y,z=z},inventory=inv,channel=channel})
- print("Sent info")
- end
- end
- end
- modem.open(modem1)
- parallel.waitForAny(normalOperation,modemListener)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement