Advertisement
Esbenmine

Internet Browser

Jul 26th, 2014
248
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.88 KB | None | 0 0
  1. --Made by Esbenmine
  2. term.clear()
  3. term.setCursorPos(1,1)
  4. Start = true
  5. ButtonWidth = 19
  6. ButtonHeight = 0
  7. ButtonX = 6
  8. ButtonY = 1
  9. MyID = os.getComputerID()
  10. ServerID = 1
  11. URL = " "
  12. Download = false
  13. monX, monY = term.getSize()
  14. rednet.open("top")
  15. Button = function()
  16.   for x = ButtonX, ButtonX+ButtonWidth do
  17.     for y = ButtonY, ButtonY+ButtonHeight do
  18.       term.setCursorPos(x,y)
  19.       term.setBackgroundColor(colors.red)
  20.       print(" ")
  21.     end
  22.   end
  23.   sleep(0.1)
  24. end
  25.  
  26. Click = function()
  27.   local event, button, xPos, yPos = os.pullEvent("mouse_click")
  28.   if xPos >= ButtonX and xPos <= (ButtonX+ButtonWidth) and yPos >= ButtonY and yPos <= (ButtonY+ButtonHeight) then
  29.     URL = " "
  30.     ReloadTopBar()
  31.     term.setCursorPos(6,1)
  32.     URL = read()
  33.     rednet.send(ServerID, URL)
  34.     id, ConF = rednet.receive()
  35.    
  36.     if ConF == "ConnectionF" then
  37.       term.setBackgroundColor(colors.black)
  38.       term.setCursorPos(12,15)
  39.       print("Connection to the website failed")
  40.       sleep(1)
  41.     else
  42.       term.setBackgroundColor(colors.black)
  43.       WebsiteW = fs.open("Website", "w")
  44.       WebsiteW.write('Website = function()\n')
  45.       id, Line = rednet.receive()
  46.       WebsiteW.write("  ")
  47.       WebsiteW.write(Line)
  48.       WebsiteW.write('\n')
  49.       WebsiteW.write('shell.run("Browser")')
  50.       WebsiteW.write('end\n')
  51.       WebsiteW.write('parallel.waitForAll(Website)\n')
  52.       WebsiteW.close()
  53.       Start = false
  54.       shell.run("Website")
  55.     end
  56.   end
  57. end
  58.  
  59. AndreTing = function()
  60.   ReloadTopBar()
  61. end
  62.  
  63. ReloadTopBar = function()
  64.   term.setBackgroundColor(colors.black)
  65.   term.clear()
  66.   for i = 1, monX do
  67.     term.setBackgroundColor(colors.red)  
  68.     term.setCursorPos(i,1)
  69.     print(" ")
  70.   end
  71.   term.setCursorPos(1,1)
  72.   print("URL: ",URL)
  73. end
  74.  
  75. repeat
  76.   term.setTextColor(1)
  77.   parallel.waitForAll(Click, Button, AndreTing)
  78. until Start == false
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement