Luit

Untitled

Oct 22nd, 2014
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.76 KB | None | 0 0
  1. local function openRednet()
  2. local listOfSides = rs.getSides()
  3. local listofPossibles = {}
  4. local counter1 = 0
  5. while true do
  6. counter1 = counter1 +1
  7.  
  8. if peripheral.isPresent(tostring(listOfSides[counter1])) and peripheral.getType(listOfSides[counter1]) == "modem" then
  9. table.insert(listofPossibles,tostring(listOfSides[counter1]))
  10. end
  11.  
  12. if counter1 == 6 and table.maxn(listofPossibles) == 0 then
  13. print("no wifi present")
  14. return nil
  15. end
  16.  
  17. if counter1 == 6 and table.maxn(listofPossibles) ~= 0 then
  18. rednet.open(listofPossibles[1])
  19. return listofPossibles[1]
  20. end
  21. end
  22. end
  23. modemOn = openRednet()
  24. local homepage = "home";
  25. local website = "home";
  26. local nw = "";
  27. local idd = os.computerID()
  28. local port1 = idd * 32
  29. local port2 = 0
  30. local port3 = port2 / 32
  31. local needport = 0
  32. local function cPrint(text)
  33. local x,y = term.getSize()
  34. local x2,y2 = term.getCursorPos()
  35. term.setCursorPos(math.ceil((x / 2) - (text:len() / 2)), y2)
  36. print(text)
  37. end
  38. function home()
  39. print("Welkom op Firefox Browser!")
  40. print("Een website kan gehost worden in het CC Datacenter!")
  41. print(" ")
  42. print("Modem is verplicht voor firefox om te kunnen functioneren.")
  43. needport = 0
  44. end
  45. function newsite2()
  46. cPrint("Firefox Site Manager")
  47. print("")
  48. print("Mensen kunnen naar deze site gaan via www." ..nw.. ".nl")
  49. print("Om te bewerken ga je naar www." ..nw.. ".nl/editor")
  50. print("Jouw poort is " ..port1)
  51. needport = 0
  52. end
  53. function drawEditor()
  54. print("Welkom op de site-editor! Typ wat tekst en het zal weergeven worden als mensen verbinding maken.")
  55. print("---")
  56. line1 = read()
  57. line2 = read()
  58. line3 = read()
  59. line4 = read()
  60. line5 = read()
  61. rednet.send(id, line1)
  62. rednet.send(id, line2)
  63. rednet.send(id, line3)
  64. rednet.send(id, line4)
  65. rednet.send(id, line5)
  66. print("---")
  67. print("Saved!")
  68. sleep(1)
  69. website = homepage
  70. drawScreen()
  71. end
  72. function loadwebpage()
  73. rednet.broadcast(website)
  74. print("Connecting...")
  75. id, message = rednet.receive()
  76. term.clear()
  77. term.setCursorPos(1,1)
  78. cPrint("Firefox Browser 1.0")
  79.  
  80. cPrint("http://"..website)
  81. print("")
  82. if message == "epanst" then
  83. drawEditor()
  84. else
  85. print(message)
  86. id, message = rednet.receive()
  87. print(message)
  88. id, message = rednet.receive()
  89. print(message)
  90. id, message = rednet.receive()
  91. print(message)
  92. id, message = rednet.receive()
  93. print(message)
  94.  
  95. print("")
  96.  
  97. write("URL:")
  98. address = io.read()
  99. website = address
  100. drawScreen()
  101. end
  102. end
  103. function drawScreen()
  104. term.clear()
  105. term.setCursorPos(1,1)
  106. cPrint("Firefox Browser 1.0")
  107.  
  108. cPrint("http://"..website)
  109. print("")
  110.  
  111. if website == "home" then
  112. home()
  113. end
  114.  
  115.  
  116. print("")
  117.  
  118. write("URL:")
  119. address = io.read()
  120. website = address
  121. needport = 1
  122. if website == "home" then
  123. drawScreen()
  124. else
  125. loadwebpage()
  126. end
  127. end
  128. drawScreen()
Advertisement
Add Comment
Please, Sign In to add comment