Advertisement
fishermedders

New Smithernet

Jun 8th, 2016
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.90 KB | None | 0 0
  1. size = {term.getSize()}
  2. function loadUI()
  3. term.setBackgroundColor(colors.white)
  4. term.clear()
  5. term.setCursorPos(1,1)
  6. term.setBackgroundColor(colors.lightGray)
  7. function grayBar()
  8. for i = 1,size[1]-1 do
  9. term.write(" ")
  10. end
  11. print(" ")
  12. end
  13. for i = 1,3 do
  14. grayBar()
  15. end
  16. title = "Smithernet Explorer 1.0"
  17. term.setTextColor(colors.lightBlue)
  18. term.setCursorPos((size[1]/2)-(#title/2),1)
  19. term.write(title)
  20. term.setCursorPos(2,2)
  21. term.setBackgroundColor(colors.gray)
  22. term.write(" Home ")
  23. term.setBackgroundColor(colors.lightGray)
  24. term.write(" ")
  25. term.setBackgroundColor(colors.gray)
  26. term.write(" ")
  27. term.setBackgroundColor(colors.lightGray)
  28. term.write(" ")
  29. term.setBackgroundColor(colors.gray)
  30. term.write(" Refresh ")
  31. term.setCursorPos(1,4)
  32. end
  33.  
  34. if term.isColor() then
  35. term.setBackgroundColor(colors.lightBlue)
  36. term.clear()
  37. term.setCursorPos(1,1)
  38. else
  39. term.clear()
  40. term.setCursorPos(1,1)
  41. end
  42.  
  43. if not fs.exists("smithernetexplorer/cfg/config.cfg") then
  44. fs.makeDir("smithernetexplorer/cfg/")
  45. print("Thank you for purchasing your SMITHNET SERVER!")
  46. print("You will now be guided through the installation")
  47. size = {term.getSize()}
  48. for i = 1,size[1]-1 do
  49. term.write("-")
  50. end
  51. print("-")
  52. term.write("What side is the modem on? :: ")
  53. side = read()
  54. term.write("What number is the house?")
  55. housenumber = read()
  56. print("Thank you for configuring the SMITHNET SERVER!")
  57. file = fs.open("smithernetexplorer/cfg/config.cfg","w")
  58. t = {}
  59. t["side"] = side
  60. t["housenumber"] = tonumber(housenumber)
  61. file.write(textutils.serialize(t))
  62. file.close()
  63. end
  64.  
  65.  
  66. --Main Program loop
  67. config = fs.open("smithernetexplorer/cfg/config.cfg","r")
  68. tbl = textutils.unserialize(config.readAll())
  69. config.close()
  70. loadUI()
  71. while true do
  72. evnt = {os.pullEvent()}
  73. if evnt[1] == "mouse_click" then
  74. if evnt[4] == 2 then
  75. if evnt[3] > 8 and evnt[3] < 41 then
  76. term.setCursorPos(9,2)
  77. input = read()
  78. cont = http.get("https://raw.githubusercontent.com/fishermedders/cc/master/sites/"..input)
  79. if cont ~= nil then
  80. cont = cont.readAll()
  81. else
  82. cont = http.get("https://raw.githubusercontent.com/fishermedders/cc/master/sites/404.epage").readAll()
  83. end
  84. term.setCursorPos(1,4)
  85. term.setBackgroundColor(colors.white)
  86. for i = 1,size[2]-4 do
  87. for i = 1,size[1]-1 do
  88. term.write(" ")
  89. end
  90. print(" ")
  91. end
  92. term.setCursorPos(1,4)
  93. args = {}
  94. if string.match(cont,"\n") then
  95. for word in string.gmatch(cont, '(.-)\\n') do
  96. table.insert(args,word)
  97. end
  98. else
  99. args[1] = cont
  100. end
  101. for i = 1,#args do
  102. print(args[i])
  103. end
  104. end
  105. end
  106. end
  107. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement