Advertisement
asteroidsteam

Browser

Sep 6th, 2018
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.31 KB | None | 0 0
  1. local sides = {
  2. "top",
  3. "bottem",
  4. "left",
  5. "right",
  6. "back",
  7. "front"
  8. }
  9. isPrsnt = false
  10. for i=1,#sides do
  11.   if (peripheral.getType(sides[i]) == "modem") then
  12.     --Open Router.
  13.     isPrsnt = true
  14.     rednet.open(sides[i])
  15.     break
  16.   else
  17.     --Do Nothing.  
  18.   end
  19. end
  20. if (isPrsnt) then
  21.   --Do something
  22.   term.clear()
  23.   term.setCursorPos(1,1)
  24.   write("Enter Web Adress: ")
  25.   link = read()
  26.   rednet.send(1,link)
  27.   while true do
  28.     local id,message = rednet.receive(5)
  29.     if (message == nil) then
  30.       printError("Error: The DNS Indexing server you are trying to connect to is currently down!")
  31.       break
  32.     end
  33.     if (id == 1) then
  34.       if(message == "false") then
  35.         printError("Error: Unknown domain address!")
  36.         break
  37.       else
  38.         rednet.send(message,"/20%80")
  39.         local id, resp = rednet.receive(3)
  40.         if (id == message) then
  41.           local tempfile = fs.open(".temp", "w")
  42.           tempfile.write(resp)
  43.           tempfile.close()
  44.           term.clear()
  45.           term.setCursorPos(1,1)
  46.           dofile(".temp")
  47.           fs.delete(".temp")
  48.         else
  49.           printError("The website you are trying to connect to is not responding at the moment!")
  50.         end
  51.         break
  52.       end
  53.     end
  54.   end
  55. else
  56.   printError("Error: No modem found!")
  57. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement