Advertisement
lego11

ergb chiosco

Jun 21st, 2018
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.80 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. clear()
  9. function link()
  10. term.setTextColour(colours.yellow)
  11. end
  12. function fineLink()
  13. term.setTextColour(colours.white)
  14. end
  15. function colore(sfumatura)
  16. term.setTextColour(sfumatura)
  17. end
  18. function fineColore()
  19. term.setTextColour(colours.white)
  20. end
  21. function sfondo(sfumaturaSfondo)
  22. term.setBackgroundColour(sfumaturaSfondo)
  23. end
  24. function fineSfondo()
  25. term.setBackgroundColour(colours.black)
  26. end
  27. function errore()
  28. while true do
  29. clear()
  30. colore(colours.red)
  31. sfondo(colours.yellow)
  32. print("Errore!")
  33. fineSfondo()
  34. print("")
  35. print("Errore: Impossibile caricare la pagina!")
  36. fineColore()
  37. print("")
  38. print("Cause comuni:")
  39. print("")
  40. print("- Nessuna connessione a LeNet")
  41. print("- Pagina inesistente")
  42. print("- Errore di digitazione dell'indirizzo")
  43. print("- Link errato o obsoleto.")
  44. print("")
  45. print("Premere G per navigare ad un'altra pagina")
  46. print("Premere Q per uscire da LeNet")
  47. event, key = os.pullEvent("key")
  48. if key == keys.g then
  49. vai_a()
  50. elseif key == keys.q then
  51. os.reboot()
  52. end
  53. end
  54. end
  55.  
  56. function vai_a_url(url)
  57. clear()
  58. ln = http.get("http://172.16.20.220/luanet/"..url..".lua")
  59. if ln == nil or ln == '' then
  60. errore()
  61. end
  62. pagina = loadstring(ln.readAll())
  63. ln.close()
  64. pagina()
  65. if key == keys.g then
  66. vai_a()
  67. end
  68. end
  69.  
  70. function vai_a()
  71. sleep(0.2)
  72. end
  73.  
  74.  
  75. --inizio pagina
  76.  
  77. colore(colours.black)
  78. sfondo(colours.yellow)
  79. print("Compagnia Elettrica eRGB")
  80. fineSfondo()
  81. fineColore()
  82. print("")
  83. term.write("e")
  84. colore(colours.red)
  85. term.write("R")
  86. colore(colours.lime)
  87. term.write("G")
  88. colore(colours.lightBlue)
  89. term.write("B")
  90. fineColore()
  91. print("\n")
  92. print("Benvenuti sul sito di eRGB. Siamo la più grande")
  93. print("compagnia elettrica di tutta la Nazione.")
  94. print("")
  95. print("Operiamo in oltre 20 città e comunità rurali e")
  96. print("pensiamo sempre al futuro e all'innovazione.")
  97. print("")
  98. link()
  99. print("- Rete elettrica")
  100. fineLink()
  101. link()
  102. print("- Centrali elettriche")
  103. fineLink()
  104. link()
  105. print("- Contratti")
  106. fineLink()
  107. link()
  108. print("- Tariffe")
  109. fineLink()
  110. link()
  111. print("- Pagamenti")
  112. fineLink()
  113.  
  114. -- Fine pagina
  115. term.setCursorPos(1, 19)
  116. term.write("Premere G per andare ad un indirizzo, Q per uscire")
  117.  
  118. --Eventi per i link
  119. while true do
  120. event, key, x, y = os.pullEvent()
  121. if event == "mouse_click" and y == 11 then
  122. vai_a_url("ergb/rete")
  123. elseif event == "mouse_click" and y == 12 then
  124. vai_a_url("ergb/centrali")
  125. elseif event == "mouse_click" and y == 13 then
  126. vai_a_url("ergb/contratti")
  127. elseif event == "mouse_click" and y == 14 then
  128. vai_a_url("ergb/tariffe")
  129. elseif event == "mouse_click" and y == 15 then
  130. vai_a_url("ergb/pagamenti")
  131. elseif event == "key" then
  132. elseif key == keys.q then
  133. os.reboot()
  134. end
  135. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement