Advertisement
Guest User

Untitled

a guest
Oct 19th, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. function round(num, numOfDecimalPlaces)
  2. return(string.format("%." ..(numOfDecimalPlaces or 0).. "f", num))
  3. end
  4. monitor = peripheral.wrap("top")
  5. term.redirect(monitor)
  6. c=0
  7. dif=0
  8. maxdif=0
  9. sum=0
  10. tickspeed = 0
  11. while true do
  12. t=os.epoch("utc")
  13. sleep(0.05)
  14. dif=os.epoch("utc")-t
  15. sum=sum+dif
  16. if (dif>maxdif) then
  17. maxdif=dif
  18. end
  19. c=c+1
  20. if(c==20) then
  21. tickspeed = (round(1000/(sum/20), 2))
  22. tkspdnum = tonumber(tickspeed)
  23. if (tkspdnum <=20.5 and tkspdnum >=19.5 ) then
  24. term.setTextColor(colors.green)
  25. end
  26. if (tkspdnum >20.5 and tkspdnum <= 22.5) then
  27. term.setTextColor(colors.yellow)
  28. end
  29. if (tkspdnum >22.5) then
  30. term.setTextColor(colors.red)
  31. end
  32. if (tkspdnum < 19.5 and tkspdnum >= 17.5) then
  33. term.setTextColor(colors.yellow)
  34. end
  35. if (tkspdnum <17.5) then
  36. term.setTextColor(colors.red)
  37. end
  38. print("tps:" .. tickspeed .. " longest tick:" .. maxdif .. "ms")
  39. c=0
  40. sum=0
  41. maxdif=0
  42. end
  43. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement