Advertisement
Guest User

Untietld™

a guest
Dec 22nd, 2018
196
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.48 KB | None | 0 0
  1. -- manual timer start (set to spacebar)
  2. -- stops when mario touches flagpole (but can be manually stopped by pressing \, and reset by pressing R which is forced during a reset assuming you use the reset hotkey)
  3.  
  4. t = 0; s = 0; m = 0; frames = 0;
  5. t_final = 0; s_final = 0; m_final = 0;
  6. x = 214; y = 220;
  7.  
  8. fp = 0;
  9. running = 0;
  10.  
  11. while (true) do
  12.    
  13.     if input.get().R then
  14.         running = 0 --timer not running and reset
  15.         fp = 0
  16.     end;
  17.    
  18.     if input.get().space then
  19.         running = 1 --timer running
  20.         fp = 0
  21.     end;
  22.    
  23.     if input.get().backslash then
  24.         fp = 1 --timer not running but not reset
  25.     end;
  26.    
  27.    
  28.     if running == 0 then
  29.         gui.text(x,y,"0:00.000")
  30.         frames = 0
  31.     end;
  32.    
  33.     if running == 2 then
  34.         gui.text(x,y,string.format(m_final)..":"..string.format(s_final));
  35.     end;
  36.    
  37.     -- timer script
  38.     if running == 1 then
  39.         frames = frames + 1
  40.        
  41.         t = (frames)/(39375000 / 655171);
  42.         s = t % 60;
  43.         s = math.floor(s*1000)/1000;
  44.         if s < 10 then
  45.             s = "0"..s;
  46.         end;
  47.         s = string.format(s)
  48.         m = math.floor(t / 60);
  49.        
  50.         gui.text(x,y,string.format(m)..":"..string.format(s));
  51.     end;
  52.    
  53.     -- s t o p p
  54.     if memory.readbyte(0x001D) == 3 then
  55.         fp = 1;
  56.         t_final = t;
  57.         s_final = t_final % 60;
  58.         s_final = math.floor(s_final*1000)/1000
  59.         if s_final < 10 then
  60.             s_final = "0"..s_final
  61.         end;
  62.         s_final = string.format(s_final)
  63.         m_final = math.floor(t_final / 60);
  64.        
  65.         running = 2;
  66.         gui.text(x,y,string.format(m_final)..":"..string.format(s_final));
  67.     end;
  68.    
  69.     FCEU.frameadvance()
  70. end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement