Advertisement
xerpi

Untitled

Apr 14th, 2011
229
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.71 KB | None | 0 0
  1. rojo = color.new( 255, 0, 0 )
  2. azul = color.new( 0, 0, 255)
  3. verde = color.new( 0, 255,0)
  4. size=0.8
  5.  
  6. tiempo={}
  7.  
  8. crono={tiempo=timer.new(),status="pause"}
  9. crono.tiempo:reset(); crono.tiempo:stop();
  10.  
  11.  
  12. function returntime(time)
  13. if time/1000<60 then return tostring(time/1000).." sec"
  14. elseif time/1000>60 then return tostring(math.floor((time/1000)/60))..":"..tostring((time/1000)-math.floor((time/1000)/60)*60) .." min"
  15. end
  16. end
  17.  
  18. while true do
  19. controls.read()
  20.  
  21.  
  22. for i = 1, #tiempo do
  23.     if i<=14 then
  24.         screen.print(5,50+(i-1)*16,i..": ",size,verde,0x0)
  25.         screen.print(5+screen.textwidth(i..": "),50+(i-1)*16,tiempo[i],size,rojo,0x0)
  26.     elseif i >14 and i <= 28 then screen.print(150,50+(i-15)*16,i..": ",size,verde,0x0)
  27.         screen.print(150+screen.textwidth(i..": "),50+(i-15)*16,tiempo[i],size,rojo,0x0)
  28.     elseif i >28 then screen.print(340,50+(i-29)*16,i..": ",size,verde,0x0)
  29.         screen.print(340+screen.textwidth(i..": "),50+(i-29)*16,tiempo[i],size,rojo,0x0)
  30.     end
  31. end
  32.  
  33. if controls.press("cross") then
  34.     if crono.tiempo:time() == 0 then
  35.         crono.tiempo:start()
  36.         crono.status="running"
  37.     elseif crono.tiempo:time() > 0 and #tiempo <42 then
  38.         table.insert(tiempo,returntime(crono.tiempo:time()))
  39.     end
  40. end
  41.  
  42. if controls.press("start") then
  43.     if crono.status == "pause" then
  44.         crono.tiempo:start()
  45.         crono.status="running"
  46.     elseif crono.status == "running" then
  47.         crono.tiempo:stop()
  48.         crono.status="pause"
  49.     end
  50. end
  51. if controls.press("circle") then
  52.     crono.tiempo:reset(); crono.tiempo:stop();
  53.     crono.status="pause"
  54. end
  55.  
  56. if controls.r() and controls.l() then
  57.     tiempo={}
  58. end
  59.  
  60.  
  61. screen.print(200,20,returntime(crono.tiempo:time()),size,azul,0x0)
  62.  
  63. if controls.select() then a() end
  64.  
  65. screen.flip()
  66. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement