Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- rojo = color.new( 255, 0, 0 )
- azul = color.new( 0, 0, 255)
- verde = color.new( 0, 255,0)
- size=0.8
- tiempo={}
- crono={tiempo=timer.new(),status="pause"}
- crono.tiempo:reset(); crono.tiempo:stop();
- function returntime(time)
- if time/1000<60 then return tostring(time/1000).." sec"
- elseif time/1000>60 then return tostring(math.floor((time/1000)/60))..":"..tostring((time/1000)-math.floor((time/1000)/60)*60) .." min"
- end
- end
- while true do
- controls.read()
- for i = 1, #tiempo do
- if i<=14 then
- screen.print(5,50+(i-1)*16,i..": ",size,verde,0x0)
- screen.print(5+screen.textwidth(i..": "),50+(i-1)*16,tiempo[i],size,rojo,0x0)
- elseif i >14 and i <= 28 then screen.print(150,50+(i-15)*16,i..": ",size,verde,0x0)
- screen.print(150+screen.textwidth(i..": "),50+(i-15)*16,tiempo[i],size,rojo,0x0)
- elseif i >28 then screen.print(340,50+(i-29)*16,i..": ",size,verde,0x0)
- screen.print(340+screen.textwidth(i..": "),50+(i-29)*16,tiempo[i],size,rojo,0x0)
- end
- end
- if controls.press("cross") then
- if crono.tiempo:time() == 0 then
- crono.tiempo:start()
- crono.status="running"
- elseif crono.tiempo:time() > 0 and #tiempo <42 then
- table.insert(tiempo,returntime(crono.tiempo:time()))
- end
- end
- if controls.press("start") then
- if crono.status == "pause" then
- crono.tiempo:start()
- crono.status="running"
- elseif crono.status == "running" then
- crono.tiempo:stop()
- crono.status="pause"
- end
- end
- if controls.press("circle") then
- crono.tiempo:reset(); crono.tiempo:stop();
- crono.status="pause"
- end
- if controls.r() and controls.l() then
- tiempo={}
- end
- screen.print(200,20,returntime(crono.tiempo:time()),size,azul,0x0)
- if controls.select() then a() end
- screen.flip()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement