Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- os = require("os")
- event = require("event")
- term = require("term")
- keyboard = require("keyboard")
- com = require("component")
- fs = require("filesystem")
- w,h = com.gpu.getResolution()
- prog = true
- clearMon = false
- crop = 0.4
- tSlot = 1
- timeConstant = 2
- TPS = {}
- avgTPS = 0
- joke = 0
- logTps = 1
- logRow = 1
- ww = w*crop
- hh = h*crop
- com.gpu.setResolution(ww, hh)
- for tSlot=1,10 do
- TPS[tSlot]=0
- end;
- function minusTime(tc)
- if tc <= 1 then
- return tc
- else
- return tc - 1
- end;
- end;
- function plusTime(tc)
- if tc >= 20 then
- return tc
- else
- return tc + 1
- end;
- end;
- btn = {
- {
- x = ww-2,
- y = 1,
- action = function()
- event.ignore("touch", touch)
- prog = false
- clearMon = true
- end;
- },
- {
- x = 13,
- y = 3,
- action = function()
- timeConstant = minusTime(timeConstant)
- end;
- },
- {
- x = 21,
- y = 3,
- action = function()
- timeConstant = plusTime(timeConstant)
- end;
- }
- }
- function touch(_,_, x, y)
- for i = 1, #btn do
- 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
- btn[i].action()
- break
- end;
- end;
- end;
- function twenty(flt)
- if flt > 20 then
- return 20
- else
- return flt
- end;
- end;
- function time()
- local f = io.open("/tmp/timeFile","w")
- f:write("test")
- f:close()
- return(fs.lastModified("/tmp/timeFile"))
- end;
- while prog == true do
- realTimeOld = time()
- os.sleep(timeConstant/10)
- realTimeNew = time()
- realTimeDiff = realTimeNew-realTimeOld
- TPS[tSlot] = twenty(20000*(timeConstant/10)/realTimeDiff)
- avgTPS = (TPS[1]+TPS[2]+TPS[3]+TPS[4]+TPS[5]+TPS[6]+TPS[7]+TPS[8]+TPS[9]+TPS[10])/10
- event.listen("touch", touch)
- com.gpu.setForeground(0x222222)
- com.gpu.fill(1, 1, ww, hh-2, '█')
- com.gpu.setForeground(0x000080)
- com.gpu.fill(1, 1, ww, 1, '█')
- term.setCursor(1,1)
- com.gpu.setBackground(0x000080)
- com.gpu.setForeground(0xFFFFFF)
- print("roga122 tps checker")
- com.gpu.setForeground(0xff0000)
- com.gpu.fill(ww-2, 1, 3, 1, '█')
- term.setCursor(ww-1,1)
- com.gpu.setBackground(0xff0000)
- com.gpu.setForeground(0xffffff)
- print("X")
- term.setCursor(1,3)
- com.gpu.setForeground(0xffffff)
- com.gpu.setBackground(0x222222)
- print("Частота:", timeConstant/10)
- term.setCursor(1,4)
- com.gpu.setForeground(0xffffff)
- com.gpu.setBackground(0x222222)
- print("TPS сейчас:", string.format("%.2f",TPS[tSlot]))
- term.setCursor(1,5)
- com.gpu.setBackground(0x222222)
- print("TPS средний:", string.format("%.2f",avgTPS))
- term.setCursor(1,7)
- print("Плавность работы визуально:")
- term.setCursor(1,17)
- print("История тпс:")
- com.gpu.setForeground(0xcccccc)
- com.gpu.fill(13, 3, 3, 1, '█')
- com.gpu.setBackground(0xcccccc)
- com.gpu.setForeground(0xffffff)
- term.setCursor(14,3)
- print("-")
- com.gpu.setForeground(0xcccccc)
- com.gpu.fill(21, 3, 3, 1, '█')
- com.gpu.setBackground(0xcccccc)
- com.gpu.setForeground(0xffffff)
- term.setCursor(22,3)
- print("+")
- if joke < ww then
- if (avgTPS > 18) then
- com.gpu.setForeground(0x00FF00)
- elseif (avgTPS < 18 and avgTPS > 13) then
- com.gpu.setForeground(0xFFFF00)
- elseif (avgTPS < 13 and avgTPS > 8) then
- com.gpu.setForeground(0xFF9900)
- else
- com.gpu.setForeground(0xFF0000)
- end;
- com.gpu.fill(1, 9, joke, 7, '█')
- joke = joke + 1
- else
- if (avgTPS > 18) then
- com.gpu.setForeground(0x00FF00)
- elseif (avgTPS < 18 and avgTPS > 13) then
- com.gpu.setForeground(0xFFFF00)
- elseif (avgTPS < 13 and avgTPS > 8) then
- com.gpu.setForeground(0xFF9900)
- else
- com.gpu.setForeground(0xFF0000)
- end;
- com.gpu.fill(1, 9, ww, 7, '█')
- joke = 0
- end;
- if logTps < 11 then
- term.setCursor(logRow+3, hh-1)
- com.gpu.setForeground(0xffffff)
- com.gpu.setBackground(0x222222)
- print(string.format("%.1f",TPS[logTps]))
- term.setCursor(1, hh-2)
- com.gpu.setForeground(0x222222)
- com.gpu.fill(1, hh-2, ww, 1, '█')
- term.setCursor(logRow+2, hh-2)
- com.gpu.setForeground(0x000000)
- if (TPS[tSlot] > 18) then
- com.gpu.setBackground(0x00FF00)
- elseif (TPS[tSlot] < 18 and TPS[tSlot] > 13) then
- com.gpu.setBackground(0xFFFF00)
- elseif (TPS[tSlot] < 13 and TPS[tSlot] > 8) then
- com.gpu.setBackground(0xFF9900)
- else
- com.gpu.setBackground(0xFF0000)
- end;
- print("Сейчас")
- com.gpu.setForeground(0xffffff)
- com.gpu.setBackground(0x222222)
- logTps = logTps + 1
- logRow = logRow + 6
- end;
- if logTps == 11 then
- logTps = 1
- logRow = 1
- end;
- if tSlot == 10 then
- tSlot = 0
- end;
- tSlot = tSlot + 1
- if clearMon == true then
- term.setCursor(1, 1)
- term.clear()
- com.gpu.setBackground(0x000000)
- com.gpu.setForeground(0x000000)
- com.gpu.setResolution(w, h)
- com.gpu.fill(1, 1, w, h, '█')
- com.gpu.setForeground(0xFFFFFF)
- com.gpu.setBackground(0x000000)
- print("Выход...")
- end;
- end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement