Advertisement
lego11

BorsaTyrianChioscoNEW

Dec 15th, 2020 (edited)
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.45 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. clear()
  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. term.setCursorPos(1, 2)
  73. sfondo(colours.lightGrey)
  74. print("|-----------------------------------|")
  75. print("| VAI A INDIRIZZO.... |")
  76. print("| |")
  77. print("| ln:// |")
  78. print("| |")
  79. print("| |")
  80. print("|Premere Enter per navigare |")
  81. print("|-----------------------------------|")
  82. fineSfondo()
  83. term.setCursorPos(8, 5)
  84. url = read()
  85. vai_a_url(url)
  86. term.setCursorPos(1, 19)
  87. term.write("Premere G per andare ad un indirizzo, Q per uscire")
  88. while true do
  89. event, key = os.pullEvent("key")
  90. if key == keys.g then
  91. vai_a()
  92. end
  93. end
  94. end
  95.  
  96.  
  97. --inizio pagina
  98.  
  99. colore(colours.black)
  100. sfondo(colours.yellow)
  101. print("BORSA DI TYRIAN - TRADING ONLINE")
  102. fineSfondo()
  103. fineColore()
  104. colore(colours.lightBlue)
  105. print(" ______ ___ _______ ______ _ ")
  106. print("|_ _ \\ .' '.|_ __ \\ .' ____ \\ / \\ ")
  107. print(" | |_) |/ .-. \\ | |__) || (___ \\_| / _ \\ ")
  108. print(" | __'.| | | | | __ / _.____'. / ___ \\ ")
  109. print(" _| |__) \\ '-' /_| | \\ \\| \\____) | _/ / \\ \\_ ")
  110. print("|_______/ '.___.'|____| |___\\______.'|____| |____| ")
  111. fineColore()
  112. print("\n")
  113. print("Benvenuti sul sito della Borsa di Tyrian.")
  114. print("")
  115. print("")
  116. link()
  117. print("Informazioni")
  118. print("Come si usa")
  119. print("Quotazioni")
  120. print("Area riservata")
  121. fineLink()
  122.  
  123. -- Fine pagina
  124. term.setCursorPos(1, 19)
  125. term.write("Premere G per andare ad un indirizzo, Q per uscire")
  126.  
  127. --Eventi per i link
  128. while true do
  129. event, key, x, y = os.pullEvent()
  130. if event == "mouse_click" and y == 13 then
  131. vai_a_url("borsatyrian/info")
  132. elseif event == "mouse_click" and y == 14 then
  133. vai_a_url("borsatyrian/uso")
  134. elseif event == "mouse_click" and y == 15 then
  135. vai_a_url("borsatyrian/quotazioni")
  136. elseif event == "mouse_click" and y == 16 then
  137. vai_a_url("borsatyrian/areariservata")
  138. elseif event == "key" then
  139. if key == keys.g then
  140. vai_a()
  141. elseif key == keys.q then
  142. os.reboot()
  143. end
  144. end
  145. end
  146.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement