lego11

LeNet

Jun 21st, 2018
517
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. sfumatura = "white"
  2. sfumaturaSfondo = "black"
  3.  
  4. function clear()
  5. term.clear()
  6. term.setCursorPos(1, 1)
  7. term.setBackgroundColour(colours.black)
  8. term.setTextColor( colors.white )
  9. end
  10.  
  11. function link()
  12. term.setTextColour(colours.yellow)
  13. end
  14.  
  15. function fineLink()
  16. term.setTextColour(colours.white)
  17. end
  18.  
  19. function colore(sfumatura)
  20. term.setTextColour(sfumatura)
  21. end
  22.  
  23. function fineColore()
  24. term.setTextColour(colours.white)
  25. end
  26.  
  27. function sfondo(sfumaturaSfondo)
  28. term.setBackgroundColour(sfumaturaSfondo)
  29. end
  30.  
  31. function fineSfondo()
  32. term.setBackgroundColour(colours.black)
  33. end
  34.  
  35. function vai_a_url(url)
  36. clear()
  37. ln = http.get("http://172.16.20.220/luanet/"..url..".lua")
  38. if ln == nil or ln == '' then
  39. errore()
  40. end
  41. pagina = loadstring(ln.readAll())
  42. ln.close()
  43. pagina()
  44. if key == keys.g then
  45.     vai_a()
  46. end
  47. end
  48.  
  49. function vai_a()
  50. sleep(0.2)
  51. term.setCursorPos(1, 2)
  52. sfondo(colours.lightGrey)
  53. print("|-----------------------------------|")
  54. print("|        VAI A INDIRIZZO....        |")
  55. print("|                                   |")
  56. print("| ln://                             |")
  57. print("|                                   |")
  58. print("|                                   |")
  59. print("|Premere Enter per navigare         |")
  60. print("|-----------------------------------|")
  61. fineSfondo()
  62. term.setCursorPos(8, 5)
  63. url = read()
  64. vai_a_url(url)
  65. term.setCursorPos(1, 19)
  66. term.write("Premere G per andare ad un indirizzo, Q per uscire")
  67. while true do
  68. event, key = os.pullEvent("key")
  69. if key == keys.g then
  70.     vai_a()
  71. end
  72. end
  73. end
  74.  
  75.  
  76. function home()
  77. while true do
  78. clear()
  79. colore(colours.lime)
  80. print(" ____  ____  ____  ____  ____ ")
  81. print("||L ||||e ||||N ||||e ||||t ||")
  82. print("||__||||__||||__||||__||||__||")
  83. print("|/__\\||/__\\||/__\\||/__\\||/__\\|   (c) lego11")
  84. fineColore()
  85. print("")
  86. print("")                            
  87. print("COMANDI:")
  88. print("")
  89. print("Q: Esce dal programma")
  90. print("G: Inserisce un URL")
  91. print("")
  92. print("")
  93. term.write("Clicca su un link ")
  94. link()
  95. term.write("come questo")
  96. fineLink()
  97. term.write(" per andare alla")
  98. print("\ndestinazione del link\n")
  99. term.write("Clicca ")
  100. link()
  101. term.write("qui")
  102. fineLink()
  103. term.write(" per andare al portale LeNet")
  104.  
  105.  
  106. event, key, x, y = os.pullEvent()
  107. if event == "mouse_click" and x >= 19 and x <= 29 and y == 13 then
  108.     term.setCursorPos(1, 2)
  109.     sfondo(colours.lightGrey)
  110.     print("|-----------------------------------|")
  111.     print("|              AVVISO               |")
  112.     print("|                                   |")
  113.     print("| Hai aperto un link!               |")
  114.     print("|                                   |")
  115.     print("|Premere un tasto qualsiasi         |")
  116.     print("|-----------------------------------|")
  117.     fineSfondo()
  118.     os.pullEvent( "key" )
  119.     home()
  120.     elseif event == "mouse_click" and x >= 7 and x <= 10 and y == 16 then
  121.     vai_a_url("lenet")
  122.     elseif event == "key" then
  123.     if key == keys.g then
  124.     vai_a()
  125.     elseif key == keys.q then
  126.     sleep(0.3)
  127.     os.reboot()
  128.     elseif key == keys.h then
  129.     home()
  130. end
  131.     end
  132. end
  133. end
  134.  
  135. function errore()
  136. while true do
  137. clear()
  138. colore(colours.red)
  139. sfondo(colours.yellow)
  140. print("Errore!")
  141. fineSfondo()
  142. print("")
  143. print("Errore: Impossibile caricare la pagina!")
  144. fineColore()
  145. print("")
  146. print("Cause comuni:")
  147. print("")
  148. print("- Nessuna connessione a LeNet")
  149. print("- Pagina inesistente")
  150. print("- Errore di digitazione dell'indirizzo")
  151. print("- Link errato o obsoleto.")
  152. print("")
  153. print("Premere G per navigare ad un'altra pagina")
  154. print("Premere H per ritornare alla pagina iniziale")
  155. print("Premere Q per uscire da LeNet")
  156. event, key = os.pullEvent("key")
  157. if key == keys.g then
  158.     vai_a()
  159. elseif key == keys.q then
  160.     return
  161. elseif key == keys.h then
  162.     home()
  163. end
  164. end
  165. end
  166. --Controlla il terminale
  167. if term.isColour == false then
  168. error("Errore: Scheda grafica del computer non supportata")
  169. end
  170. clear()
  171. home()
Add Comment
Please, Sign In to add comment