Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local fadeText = {}
- --A little text that fades away, (align text (left/center/right)?)
- local function newFadeText(text,frames,x,y,r,g,b,noremove)
- local t = {ticks=frames,max=frames,text=text,x=x,y=y,r=r,g=g,b=b,keep=noremove}
- table.insert(fadeText,t)
- return t
- end
- local function resetFade(fade,text) fade.ticks=fade.max if text then fade.text=text end end
- --Some text locations for repeated usage
- local infoText = newFadeText("",30,245,370,255,255,255,true)
- local stepcount,mcount=0,0
- local starttime=os.time()
- local function step()
- stepcount=stepcount+1
- if os.time()>starttime then
- resetFade(infoText,tostring(stepcount.." "..mcount))
- stepcount=0
- mcount=0
- starttime=os.time()
- end
- for k,v in pairs(fadeText) do
- if v.ticks > 0 then
- local a = math.floor(255*(v.ticks/v.max))
- tpt.drawtext(v.x,v.y,v.text,v.r,v.g,v.b,a)
- v.ticks = v.ticks-1
- else if not v.keep then table.remove(fadeText,k) end
- end
- end
- end
- local function mouse()
- mcount=mcount+1
- end
- tpt.register_step(step)
- tpt.register_mouseevent(mouse)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement