asteroidsteam icon

Browser

asteroidsteam | PRO | 09/06/18 09:40:47 PM UTC | 0 ⭐ | 377 👁️ | Never ⏰ | []
Lua |

1.31 KB

|

None

|

0 👍

/

0 👎

local sides = {
"top",
"bottem",
"left",
"right",
"back",
"front"
}
isPrsnt = false
for i=1,#sides do
  if (peripheral.getType(sides[i]) == "modem") then
    --Open Router.
    isPrsnt = true
    rednet.open(sides[i])
    break
  else
    --Do Nothing.  
  end
end
if (isPrsnt) then
  --Do something
  term.clear()
  term.setCursorPos(1,1)
  write("Enter Web Adress: ")
  link = read()
  rednet.send(1,link)
  while true do
    local id,message = rednet.receive(5)
    if (message == nil) then
      printError("Error: The DNS Indexing server you are trying to connect to is currently down!")
      break
    end
    if (id == 1) then
      if(message == "false") then
        printError("Error: Unknown domain address!")
        break
      else
        rednet.send(message,"/20%80")
        local id, resp = rednet.receive(3)
        if (id == message) then
          local tempfile = fs.open(".temp", "w")
          tempfile.write(resp)
          tempfile.close()
          term.clear()
          term.setCursorPos(1,1)
          dofile(".temp")
          fs.delete(".temp")
        else
          printError("The website you are trying to connect to is not responding at the moment!")
        end
        break
      end
    end 
  end
else
  printError("Error: No modem found!")
end

Comments