Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- timert=0
- xc=5
- fp=1
- yc=5
- pause=0
- setup=0
- pauseonend=0
- togg=100
- togr=255
- buttoni={}
- function timer()
- if timert==1 then
- timert=0
- else
- timert=1
- end
- end
- function click(mousex, mousey, button, event)
- if timert==0 then
- return
- end
- for i=1, table.getn(buttoni) do
- if (mousex>=buttoni[i][1]) and (mousex<=buttoni[i][1]+buttoni[i][3]) and (mousey>=buttoni[i][2]) and (mousey<=buttoni[i][2]+buttoni[i][4]) and (button==1) then
- if event==3 then
- graphics.fillRect(buttoni[i][1], buttoni[i][2], buttoni[i][3], buttoni[i][4], buttoni[i][5], buttoni[i][6], buttoni[i][7])
- p=1
- end
- if (event==2) and (p==1) then
- p=0
- buttoni[i][8]()
- end
- end
- end
- end
- tpt.register_mouseclick(click)
- function button(id,x,y,w,h,c,r,g,b,action)
- buttoni[id]={}
- buttoni[id][1]=x
- buttoni[id][2]=y
- buttoni[id][3]=w
- buttoni[id][4]=h
- buttoni[id][5]=r
- buttoni[id][6]=g
- buttoni[id][7]=b
- buttoni[id][8]=action
- graphics.drawRect(x, y, w, h, r, g, b)
- k=string.len(c)*4+string.len(c)-1
- graphics.drawText(x+(w-k)/2, y+(h-7)/2, c,1,1,1)
- if (tpt.mousex>=x) and (tpt.mousex<=x+w) and (tpt.mousey>=y) and (tpt.mousey<=y+h) then
- graphics.fillRect(x, y, w, h, r, g, b,50)
- end
- end
- function start()
- setup=1
- if pause==1 then
- anot=ti+os.time()
- pause=0
- else
- anot=os.time()+s2+s1*10+m2*60+m1*600
- end
- end
- function stopp()
- pause=1
- ptime=os.time()
- end
- function reset()
- setup=0
- end
- function m1p()
- if m1<6 then
- m1=m1+1
- end
- if m1==6 then
- m2=0
- end
- end
- function m1m()
- if m1>0 then
- m1=m1-1
- end
- end
- function m2p()
- if m2==9 then
- m1p()
- m2=0
- else
- if m1~=6 then
- m2=m2+1
- end
- end
- end
- function m2m()
- if m2>0 then
- m2=m2-1
- else
- if m1>0 then
- m1m()
- m2=9
- end
- end
- end
- function s1p()
- if s1<6 then
- s1=s1+1
- end
- if s1==6 then
- s2=0
- end
- end
- function s1m()
- if s1>0 then
- s1=s1-1
- end
- end
- function s2p()
- if s2==9 then
- s1p()
- s2=0
- else
- if s1~=6 then
- s2=s2+1
- end
- end
- end
- function s2m()
- if s2>0 then
- s2=s2-1
- else
- if s1>0 then
- s1m()
- s2=9
- end
- end
- end
- function endaction()
- if pauseonend==1 then
- tpt.set_pause(1)
- end
- end
- function togpause()
- if pauseonend==0 then
- pauseonend=1
- togg=255
- togr=100
- else
- pauseonend=0
- togg=100
- togr=255
- end
- end
- function press(mousex, mousey, button, event)
- if ((button==1) and (event==1)) and (((mousex<xc) or (mousex>100+xc)) or ((mousey<yc) or (mousey>4+yc))) then
- fp=0
- end
- if (button==1) and (event==1) and (mousex>=xc) and (mousex<=100+xc) and (mousey>=yc) and (mousey<=4+yc) then
- fp=1
- fx=mousex-xc
- fy=mousey-yc
- end
- if (button==1) and (event==3) and (fp==1) then
- if (mousex-fx<0) or (mousex-fx>512) then
- if mousex-fx<0 then
- xc=0
- else
- xc=512
- end
- else
- xc=mousex-fx
- end
- if (mousey-fy>353) or (mousey-fy<-1) then
- if mousey-fy>353 then
- yc=353
- else
- yc=-1
- end
- else
- yc=mousey-fy
- end
- end
- end
- tpt.register_mouseclick(press)
- m1=0
- m2=0
- s1=0
- s2=0
- function image()
- if (setup==1) and (pause==0) then
- ti=os.difftime(anot,os.time())
- if ti==0 then
- setup=0
- endaction()
- end
- end
- if (setup==0) and (pause==0) then
- ti=0
- end
- if timert==0 then
- return
- end
- graphics.fillRect(xc,yc,100,50)
- graphics.fillRect(xc,yc,100,5,150,150,255)
- graphics.drawText(xc+12,yc+10,os.date("%M:%S",ti),1,1,1)
- button(1,xc+1,yc+35,33,12,'start',100,255,100,start)
- button(2,xc+36,yc+35,28,12,'pause',200,200,100,stopp)
- button(3,xc+66,yc+35,33,12,'reset',255,100,100,reset)
- button(12,xc+1,yc+20,52,12,'auto pause',togr,togg,100,togpause)
- graphics.drawText(xc+55,yc+15,m1,1,1,1)
- graphics.drawText(xc+65,yc+15,m2,1,1,1)
- graphics.drawText(xc+80,yc+15,s1,1,1,1)
- graphics.drawText(xc+90,yc+15,s2,1,1,1)
- button(4,xc+54,yc+6,8,8,'+',100,100,200,m1p)
- button(5,xc+54,yc+23,8,8,'-',100,100,200,m1m)
- button(6,xc+64,yc+6,8,8,'+',100,100,200,m2p)
- button(7,xc+64,yc+23,8,8,'-',100,100,200,m2m)
- button(8,xc+79,yc+6,8,8,'+',100,100,200,s1p)
- button(9,xc+79,yc+23,8,8,'-',100,100,200,s1m)
- button(10,xc+89,yc+6,8,8,'+',100,100,200,s2p)
- button(11,xc+89,yc+23,8,8,'-',100,100,200,s2m)
- end
- tpt.register_step(image)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement