lego11

Untitled

May 1st, 2020
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.43 KB | None | 0 0
  1. --Header
  2. function clear()
  3. term.clear()
  4. term.setCursorPos(1, 1)
  5. term.setBackgroundColour(colours.black)
  6. term.setTextColor( colors.white )
  7. end
  8. function link()
  9. term.setTextColour(colours.yellow)
  10. end
  11. function fineLink()
  12. term.setTextColour(colours.white)
  13. end
  14. function colore(sfumatura)
  15. term.setTextColour(sfumatura)
  16. end
  17. function fineColore()
  18. term.setTextColour(colours.white)
  19. end
  20. function sfondo(sfumaturaSfondo)
  21. term.setBackgroundColour(sfumaturaSfondo)
  22. end
  23. function fineSfondo()
  24. term.setBackgroundColour(colours.black)
  25. end
  26. function errore()
  27. while true do
  28. clear()
  29. colore(colours.red)
  30. sfondo(colours.yellow)
  31. print("Errore!")
  32. fineSfondo()
  33. print("")
  34. print("Errore: Impossibile caricare la pagina!")
  35. fineColore()
  36. print("")
  37. print("Cause comuni:")
  38. print("")
  39. print("- Nessuna connessione a LeNet")
  40. print("- Pagina inesistente")
  41. print("- Errore di digitazione dell'indirizzo")
  42. print("- Link errato o obsoleto.")
  43. print("")
  44. print("Premere G per navigare ad un'altra pagina")
  45. print("Premere Q per uscire da LeNet")
  46. event, key = os.pullEvent("key")
  47. if key == keys.g then
  48. vai_a()
  49. elseif key == keys.q then
  50. os.reboot()
  51. end
  52. end
  53. end
  54.  
  55. function vai_a_url(url)
  56. clear()
  57. ln = http.get("http://172.16.20.220/luanet/"..url..".lua")
  58. if ln == nil or ln == '' then
  59. errore()
  60. end
  61. pagina = loadstring(ln.readAll())
  62. ln.close()
  63. pagina()
  64. if key == keys.g then
  65. vai_a()
  66. end
  67. end
  68.  
  69. function vai_a()
  70. sleep(0.2)
  71. term.setCursorPos(1, 2)
  72. sfondo(colours.lightGrey)
  73. print("|-----------------------------------|")
  74. print("| VAI A INDIRIZZO.... |")
  75. print("| |")
  76. print("| ln:// |")
  77. print("| |")
  78. print("| |")
  79. print("|Premere Enter per navigare |")
  80. print("|-----------------------------------|")
  81. fineSfondo()
  82. term.setCursorPos(8, 5)
  83. url = read()
  84. vai_a_url(url)
  85. term.setCursorPos(1, 19)
  86. term.write("Premere G per andare ad un indirizzo, Q per uscire")
  87. while true do
  88. event, key = os.pullEvent("key")
  89. if key == keys.g then
  90. vai_a()
  91. end
  92. end
  93. end
  94.  
  95.  
  96. --inizio pagina
  97.  
  98. colore(colours.black)
  99. sfondo(colours.yellow)
  100. print("BORSA DI NEW RADEON - TRADING ONLINE")
  101. fineSfondo()
  102. fineColore()
  103. colore(colours.purple)
  104. print(" ______ ___ _______ ______ _ ")
  105. print("|_ _ \\ .' '.|_ __ \\ .' ____ \\ / \\ ")
  106. print(" | |_) |/ .-. \\ | |__) || (___ \\_| / _ \\ ")
  107. print(" | __'.| | | | | __ / _.____'. / ___ \\ ")
  108. print(" _| |__) \\ '-' /_| | \\ \\| \\____) | _/ / \\ \\_ ")
  109. print("|_______/ '.___.'|____| |___\\______.'|____| |____| ")
  110. fineColore()
  111. print("\n")
  112. print("Benvenuti sul sito della Borsa di New Radeon.")
  113. print("")
  114. print("")
  115. link()
  116. print("Informazioni")
  117. print("Come si usa")
  118. print("Quotazioni")
  119. print("Area riservata")
  120. fineLink()
  121.  
  122. -- Fine pagina
  123. term.setCursorPos(1, 19)
  124. term.write("Premere G per andare ad un indirizzo, Q per uscire")
  125.  
  126. --Eventi per i link
  127. while true do
  128. event, key, x, y = os.pullEvent()
  129. if event == "mouse_click" and y == 13 then
  130. vai_a_url("borsanr/info")
  131. elseif event == "mouse_click" and y == 14 then
  132. vai_a_url("borsanr/uso")
  133. elseif event == "mouse_click" and y == 15 then
  134. vai_a_url("borsanr/quotazioni")
  135. elseif event == "mouse_click" and y == 16 then
  136. vai_a_url("borsanr/areariservata")
  137. elseif event == "key" then
  138. if key == keys.g then
  139. vai_a()
  140. elseif key == keys.q then
  141. os.reboot()
  142. end
  143. end
  144. end
Add Comment
Please, Sign In to add comment