lego11

CryptoXchange chiosco

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