Advertisement
mniip

TPT FPS gauge

Nov 3rd, 2012
290
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.60 KB | None | 0 0
  1. function inrct(x,y,x1,y1,x2,y2)
  2.  return x>=x1 and x<=x2 and y>=y1 and y<=y2
  3. end
  4. function exptov(a)
  5.  return 2+(1.15^(40*a))
  6. end
  7. function vtoexp(a)
  8.  return math.log(a-2)/math.log(1.15)/40
  9. end
  10. local al=0
  11. local spd=24
  12. local wx,wy,ww,wh=586,50,25,250
  13. local expv=vtoexp(61)
  14. local fps=61
  15. local tfps=61
  16. local lt=0
  17. local afps=61
  18. function step()
  19.  local x,y=tpt.mousex,tpt.mousey
  20.  if (al>0 and inrct(x,y,wx,wy,wx+ww,wy+wh))or inrct(x,y,612,96,650,151) then
  21.   al=al+spd
  22.   if al>255 then al=255 end
  23.  else
  24.   al=al-spd
  25.   if al<0 then al=0 end
  26.  end
  27.  tpt.drawrect(wx,wy,ww,wh+24,255,255,255,al)
  28.  tpt.fillrect(wx,wy,ww-2,wh+12,0,0,0,al)
  29.  tpt.drawrect(wx+3,wy+3,ww-6,wh-6,255,255,255,al)
  30.  if tfps-1>fps then
  31.   fps=fps+1
  32.   tpt.setfpscap(fps)
  33.  elseif tfps+1<fps then
  34.   fps=fps-1
  35.   tpt.setfpscap(fps)
  36.  elseif tfps~=fps then
  37.   fps=tfps
  38.   tpt.setfpscap(fps)
  39.  end
  40.  local t=os.clock()
  41.  afps=1/(t-lt)
  42.  lt=t
  43.  local h=(wh-8)*expv
  44.  tpt.fillrect(wx+3,wy+wh-5-h,ww-8,h,0,0,255,al)
  45.  local h=(wh-8)*vtoexp(fps)
  46.  tpt.fillrect(wx+3,wy+wh-5-h,(ww-8)/2,h,255,0,255,al/2)
  47.  local h=(wh-8)*vtoexp(afps)
  48.  tpt.fillrect(wx+3+(ww-8)/2,wy+wh-5-h,(ww-8)/2,h,255,0,0,al/2)
  49.  tpt.drawtext(wx+5,wy+wh,math.floor(exptov(expv)),128,128,255,al)
  50.  tpt.drawtext(wx+5,wy+wh+8,math.floor(fps),255,128,255,al)
  51.  tpt.drawtext(wx+5,wy+wh+16,math.floor(afps),255,128,128,al)
  52. end
  53. function mouse(x,y,b,n)
  54.  if al>0 then
  55.   if inrct(x,y,wx+4,wy+4,wx+ww-4,wy+wh-4) then
  56.    expv=1-(y-wy-4)/(wh-8)
  57.    tfps=exptov(expv)
  58.   end
  59.   if inrct(x,y,wx,wy,wx+ww,wy+wh) then
  60.    return false
  61.   end
  62.  end
  63. end
  64. tpt.register_step(step)
  65. tpt.register_mouseclick(mouse)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement