Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- pastebin run 1EQLZfSR
- local timeConstant = 1 -- обновление тпс
- local admins = {"mrWhiskass"} -- заприватить пк
- local computer = require("computer")
- local event = require("event")
- local fs = require('filesystem')
- local com = require('component')
- local gpu = com.gpu
- local leftX = 5
- local topY = 14
- local realTimeOld = 0
- local realTimeNew = 0
- local realTimeDiff = 0
- local w, h = gpu.getResolution()
- for i = 1,#admins do
- computer.addUser(admins[i])
- admins[admins[i]] = true
- end
- local function time()
- io.open('/tmp/clock.dt','w'):write(''):close()
- return(fs.lastModified("/tmp/clock.dt"))
- end
- local TPS = {}
- local avgTPS = 0
- for tSlot = 1,10 do
- TPS[tSlot] = 0
- end
- local function getColor(tps)
- local H, rP, gP, bP, X = tps*12-120, 0, 0, 0, 0
- if H<0 then H=0 end
- X = (1-math.abs((H/60)%2-1))
- if H<60 then
- rP = 1
- gP = X
- bP = 0
- elseif H<120 then
- rP = X
- gP = 1
- bP = 0
- elseif H<180 then
- rP = 0
- gP = 1
- bP = X
- elseif H<240 then
- rP = 0
- gP = X
- bP = 1
- elseif H<300 then
- rP = X
- gP = 0
- bP = 1
- else
- rP = 1
- gP = 0
- bP = X
- end
- return(math.floor((rP)*255)*65536+math.floor((gP)*255)*256+math.floor((bP)*255))
- end
- local function histoPlot(tabVal,leftX, topY,step)
- local height = math.floor(tabVal[step]/2)+1
- if height>11 then height=11 end
- gpu.setBackground(0xB4B4B4)
- gpu.fill(3*step+leftX-2, topY-2, 2, 13," ")
- gpu.fill(leftX-1,topY+10,33,1," ")
- gpu.setBackground(getColor(tabVal[step]))
- gpu.fill(3*step+leftX-2, topY-height+10, 2, height," ")
- gpu.setBackground(0x0064FF)
- gpu.fill(leftX+step*3-2,topY+10,2,1," ")
- gpu.setBackground(0x000000)
- end
- function event.shouldInterrupt() return false end
- gpu.setResolution(38, 25)
- gpu.setBackground(0x000000)
- os.execute("cls")
- gpu.setForeground(0xFF9200)
- gpu.set(12,3,"[ TPS сервера ]")
- gpu.setBackground(0xB4B4B4)
- gpu.setForeground(0xFFFFFF)
- gpu.fill(leftX-1,topY-2,33,13," ")
- for i = 1,#TPS do
- local height = math.floor(TPS[i]/2)+1
- gpu.setBackground(getColor(TPS[i]))
- gpu.fill(3*i+leftX-2, topY-height+10, 2, height," ")
- end
- gpu.setBackground(0x000000)
- gpu.set(8,6,"Текущий 00.0000 тик/сек")
- gpu.set(8,9,"Средний 00.0000 тик/сек")
- gpu.set(18,11,"T/s")
- gpu.set(1,12,"20")
- gpu.set(1,17,"10")
- gpu.set(1,22," 0")
- gpu.setForeground(0x00FFFF)
- while true do
- for tSlot = 1,10 do
- realTimeOld = time()
- local e = {event.pull(timeConstant,"key_down")}
- if admins[e[5]] and e[4] == 29 then
- gpu.setResolution(80,25)
- gpu.setBackground(0x000000)
- gpu.setForeground(0xffffff)
- os.execute("cls")
- os.exit()
- end
- realTimeNew = time()
- realTimeDiff = realTimeNew-realTimeOld
- TPS[tSlot] = 20000*timeConstant/realTimeDiff
- if TPS[tSlot] > 20 then
- TPS[tSlot] = 20.0000
- end
- gpu.set(16,6,string.sub(tostring(TPS[tSlot])..".0000",1,7))
- avgTPS = (TPS[1]+TPS[2]+TPS[3]+TPS[4]+TPS[5]+TPS[6]+TPS[7]+TPS[8]+TPS[9]+TPS[10])/10
- gpu.set(16,9,string.sub(tostring(avgTPS)..".0000",1,7))
- histoPlot(TPS,leftX,topY,tSlot)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement