Advertisement
cracker64

stepcounter

May 20th, 2013
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.04 KB | None | 0 0
  1. local fadeText = {}
  2. --A little text that fades away, (align text (left/center/right)?)
  3. local function newFadeText(text,frames,x,y,r,g,b,noremove)
  4.     local t = {ticks=frames,max=frames,text=text,x=x,y=y,r=r,g=g,b=b,keep=noremove}
  5.     table.insert(fadeText,t)
  6.     return t
  7. end
  8. local function resetFade(fade,text) fade.ticks=fade.max if text then fade.text=text end end
  9. --Some text locations for repeated usage
  10. local infoText = newFadeText("",30,245,370,255,255,255,true)
  11. local stepcount,mcount=0,0
  12. local starttime=os.time()
  13. local function step()
  14.     stepcount=stepcount+1
  15.     if os.time()>starttime then
  16.         resetFade(infoText,tostring(stepcount.." "..mcount))
  17.         stepcount=0
  18.         mcount=0
  19.         starttime=os.time()
  20.     end
  21.     for k,v in pairs(fadeText) do
  22.         if v.ticks > 0 then
  23.             local a = math.floor(255*(v.ticks/v.max))
  24.             tpt.drawtext(v.x,v.y,v.text,v.r,v.g,v.b,a)
  25.             v.ticks = v.ticks-1
  26.         else if not v.keep then table.remove(fadeText,k) end
  27.         end
  28.     end
  29. end
  30. local function mouse()
  31.     mcount=mcount+1
  32. end
  33. tpt.register_step(step)
  34. tpt.register_mouseevent(mouse)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement