Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function round(num, numOfDecimalPlaces)
- return(string.format("%." ..(numOfDecimalPlaces or 0).. "f", num))
- end
- monitor = peripheral.wrap("top")
- term.redirect(monitor)
- c=0
- dif=0
- maxdif=0
- sum=0
- tickspeed = 0
- while true do
- t=os.epoch("utc")
- sleep(0.05)
- dif=os.epoch("utc")-t
- sum=sum+dif
- if (dif>maxdif) then
- maxdif=dif
- end
- c=c+1
- if(c==20) then
- tickspeed = (round(1000/(sum/20), 2))
- tkspdnum = tonumber(tickspeed)
- if (tkspdnum <=20.5 and tkspdnum >=19.5 ) then
- term.setTextColor(colors.green)
- end
- if (tkspdnum >20.5 and tkspdnum <= 22.5) then
- term.setTextColor(colors.yellow)
- end
- if (tkspdnum >22.5) then
- term.setTextColor(colors.red)
- end
- if (tkspdnum < 19.5 and tkspdnum >= 17.5) then
- term.setTextColor(colors.yellow)
- end
- if (tkspdnum <17.5) then
- term.setTextColor(colors.red)
- end
- print("tps:" .. tickspeed .. " longest tick:" .. maxdif .. "ms")
- c=0
- sum=0
- maxdif=0
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement