--receiver
currenthost = ""
local function openRednet()
for _,side in ipairs({"top", "bottom", "front", "left", "right", "back"}) do
if peripheral.isPresent(side) and peripheral.getType(side) == "modem" then
rednet.open(side)
return side
end
end
print("no modem present")
end
side = openRednet()
if side == nil then
print("no modem found")
else
while true do
event, id, message, distance = os.pullEvent("rednet_message")
if message == "newhost" then
rednet.send(id,"pairing")
end
if string.sub(message,1,string.len("connected"))=="connected" then
currenthost = string.sub(message,10)
print("New host: " .. currenthost)
end
end
print(message)
shell.switchTab(shell.openTab(message))
shell.exit()
end
Comments