Advertisement
FoxWorn3365

LeNet2

Dec 4th, 2021 (edited)
1,288
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.     shell.run("desktop")
  127.     elseif key == keys.h then
  128.     home()
  129. end
  130.     end
  131. end
  132. end
  133.  
  134. function errore()
  135. while true do
  136. clear()
  137. colore(colours.red)
  138. sfondo(colours.yellow)
  139. print("Errore!")
  140. fineSfondo()
  141. print("")
  142. print("Errore: Impossibile caricare la pagina!")
  143. fineColore()
  144. print("")
  145. print("Cause comuni:")
  146. print("")
  147. print("- Nessuna connessione a LeNet")
  148. print("- Pagina inesistente")
  149. print("- Errore di digitazione dell'indirizzo")
  150. print("- Link errato o obsoleto.")
  151. print("")
  152. print("Premere G per navigare ad un'altra pagina")
  153. print("Premere H per ritornare alla pagina iniziale")
  154. print("Premere Q per uscire da LeNet")
  155. event, key = os.pullEvent("key")
  156. if key == keys.g then
  157.     vai_a()
  158. elseif key == keys.q then
  159.     shell.run("desktop")
  160. elseif key == keys.h then
  161.     home()
  162. end
  163. end
  164. end
  165. --Controlla il terminale
  166. if term.isColour == false then
  167. error("Errore: Scheda grafica del computer non supportata")
  168. end
  169. clear()
  170. home()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement