roga122

http text

Nov 15th, 2021 (edited)
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.41 KB | None | 0 0
  1. i = require("internet")
  2. os = require("os")
  3. term = require("term")
  4. com = require("component")
  5. event = require("event")
  6.  
  7. url = 'https://allremind.ru/roga/'
  8.  
  9. dataRaw = ""
  10. tableScore = ""
  11. prog = true
  12. clearMon = false
  13.  
  14. w,h = com.gpu.getResolution()
  15.  
  16. crop = 0.25
  17. ww = 38
  18. hh = 15
  19.  
  20.  
  21. com.gpu.setResolution(ww, hh)
  22.  
  23. function internetRequest(url)
  24.     local success, response = pcall(com.internet.request, url)
  25.     if success then
  26.         local responseData = ""
  27.         while true do
  28.             local data, responseChunk = response.read()
  29.             if data then
  30.                 responseData = responseData .. data
  31.             else
  32.                 if responseChunk then
  33.                     return false
  34.                 else
  35.                     return responseData
  36.                 end
  37.             end
  38.         end
  39.     else
  40.         return false
  41.     end
  42. end
  43.  
  44. btn = {
  45.     {
  46.         x = ww-2,
  47.         y = 1,
  48.         action = function()
  49.             event.ignore("touch", touch)
  50.             prog = false
  51.             clearMon = true
  52.         end;
  53.     }
  54. }
  55.  
  56. function touch(_,_, x, y)
  57.     for i = 1, #btn do
  58.         if x == btn[i].x and y == btn[i].y or x >= btn[i].x + 1 and x < btn[i].x + 3 and y == btn[i].y then
  59.             btn[i].action()
  60.             break
  61.         end;
  62.     end;
  63. end;
  64.  
  65. while prog == true do
  66.     event.listen("touch", touch)
  67.     os.sleep(2)
  68.    
  69.     dataRaw = internetRequest(url)
  70.    
  71.     if (dataRaw) then
  72.         tableScore = dataRaw
  73.     else
  74.         tableScore = '\r\n\r\nИдёт получение данных...'
  75.     end;
  76.    
  77.     if tableScore ~= txt then
  78.             term.clear()
  79.             term.setCursor(1,1)
  80.        
  81.             com.gpu.setForeground(0x000080)
  82.             com.gpu.fill(1, 1, ww, 1, '█')
  83.        
  84.             com.gpu.setForeground(0xff0000)
  85.             com.gpu.fill(ww-2, 1, 3, 1, '█')
  86.        
  87.             term.setCursor(ww-1,1)
  88.             com.gpu.setBackground(0xff0000)
  89.             com.gpu.setForeground(0xffffff)
  90.             print("X")
  91.        
  92.             term.setCursor(1,1)
  93.             com.gpu.setBackground(0x000080)
  94.             print("ТАБЛИЦА РЕЗУЛЬТАТОВ SPLEEF НОЯБРЬ")
  95.        
  96.             term.setCursor(1,2)
  97.             com.gpu.setBackground(0x000000)
  98.        
  99.             print(tableScore)
  100.         end;
  101.         txt = tableScore
  102.         tableScore = ""
  103.    
  104.     if clearMon == true then
  105.         term.setCursor(1, 1)
  106.         term.clear()
  107.         com.gpu.setBackground(0x000000)
  108.         com.gpu.setForeground(0x000000)
  109.         com.gpu.setResolution(w, h)
  110.         com.gpu.fill(1, 1, w, h, '█')
  111.         com.gpu.setForeground(0xFFFFFF)
  112.         com.gpu.setBackground(0x000000)
  113.         print("Выход...")
  114.     end;
  115. end;
Add Comment
Please, Sign In to add comment