Advertisement
Guest User

SMB1 Any% Autosplitter

a guest
Jan 27th, 2017
322
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.72 KB | None | 0 0
  1. require("shapedefs");
  2.  
  3. --Add splits here
  4. --4:59.956 splits
  5. --pb11 = 32.147;
  6. --pb12 = 31.481;
  7. --pb41 = 37.405;
  8. --pb42 = 29.751;
  9. --pb81 = 51.033;
  10. --pb82 = 37.405;
  11. --pb83 = 35.309;
  12. --pb84 = 45.425;
  13.  
  14. --5:04 splits
  15. pb11 = 32.147;
  16. pb12 = 31.831;
  17. pb41 = 37.405;
  18. pb42 = 30.100;
  19. pb81 = 52.081;
  20. pb82 = 37.754;
  21. pb83 = 35.658;
  22. pb84 = 47.821;
  23.  
  24. --position
  25. --bottom y=224
  26. --top y=0
  27. y = 224;
  28.  
  29. x = 220;
  30. n = 0; s = 0; m = 0;
  31. fr = 0; pg = 0;
  32.  
  33. bow = 0;
  34. hit = 0;
  35. once = 0;
  36. s_final = 0; m_final = 0;
  37.  
  38. lvl1 = 0; lvl2 = 0;
  39. oldlvl1 = 0; oldlvl2 = 0;
  40. split = 0;
  41. lvltime = 0;
  42. lvltimefinal = 0;
  43. lvltimesum = 0;
  44. pb = 0;
  45. pbs = 0;
  46.  
  47. function round(num, idp)
  48.         local mult = 10^(idp or 0)
  49.         return math.floor(num * mult) / mult
  50. end
  51.  
  52. while (true) do
  53.  
  54.         -- reset
  55.  
  56.         if movie.framecount() < 196 then
  57.                 n = 0; s = 0; m = 0;
  58.                 fr = 0; pg = 0;
  59.                 bow = 0;
  60.                 hit = 0;
  61.                 once = 0;
  62.                 s_final = 0; m_final = 0;
  63.                 lvl1 = 0; lvl2 = 0;
  64.                 oldlvl1 = -1; oldlvl2 = -1;
  65.                 split = 0;
  66.                 lvltime = 0;
  67.                 lvltimefinal = 0;
  68.                 lvltimesum = 0;
  69.                 pb = 0;
  70.                 pbs = 0;
  71.         end;
  72.  
  73.  
  74.         -- timer
  75.  
  76.         n = (movie.framecount()-196)/(39375000/655171);
  77.         s = n % 60;
  78.         m = math.floor(n / 60);
  79.  
  80.         if s < 10 then
  81.                 gui.text(x-6,y,string.format("%.0f",m)..":0"..string.format("%0.10f",s));
  82.         end;
  83.         if s >= 10 then
  84.                 gui.text(x-6,y,string.format("%.0f",m)..":"..string.format("%0.10f",s));
  85.         end;
  86.         if movie.framecount() < 197 then
  87.                 gui.text(x-6,y,"0:00.000");
  88.         end;
  89.  
  90.  
  91.         -- stop timer
  92.  
  93.         ----detects if Bowser is on the screen and you are in world 8
  94.         for i=0,5 do
  95.                 if memory.readbyte((0x0016)+i) == 0x2d and memory.readbyte(0x075F) == 7 then
  96.                         bow = 1;
  97.                 end;
  98.         end;
  99.  
  100.         ----detects if you hit the switch and locks the timer's values
  101.         if bow == 1 and memory.readbyte(0x01ED) == 242 and memory.readbyte(0x03AD) > 210 and once == 0 then
  102.                 hit = 1;
  103.                 once = 1;
  104.                 split = 1;
  105.                 s_final = round(s - 655171/39375000, 3);
  106.                 m_final = m;
  107.         end;
  108.  
  109.         ----timer with locked values
  110.         if hit == 1 then
  111.                 if s_final < 10 then
  112.                         gui.text(x-6,y,string.format("%.0f",m_final)..":0"..string.format("%0.10f",s_final));
  113.                 end;
  114.                 if s_final >= 10 then
  115.                         gui.text(x-6,y,string.format("%.0f",m_final)..":"..string.format("%0.10f",s_final));
  116.                 end;
  117.         end;
  118.  
  119.  
  120.         --level timer
  121.         if hit == 0 then
  122.             lvltime = n-lvltimesum
  123.         --  gui.text(x-69,y,string.format("%04.1f",lvltime));      
  124.         end
  125.        
  126.        
  127.         --splitter
  128.         --detects level change
  129.         if (memory.readbyte(0x075F) ~= lvl1 or memory.readbyte(0x075C) ~= lvl2) and memory.readbyte(0x0772) == 2 then
  130.             split = 1;
  131.         end
  132.        
  133.         --records final level time
  134.         if movie.framecount() > 196 and split == 1 then
  135.             oldlvl1=lvl1;
  136.             oldlvl2=lvl2;
  137.             lvl1 = memory.readbyte(0x075F);
  138.             lvl2 = memory.readbyte(0x075C);
  139.             lvltimefinal = lvltime;
  140.             lvltimesum = n;
  141.         end
  142.        
  143.         --determines currecnt pb to reference
  144.         if oldlvl1 == 0 and oldlvl2 == 0 then
  145.             pb = pb11
  146.             pbs = pb11
  147.         end
  148.        
  149.         if oldlvl1 == 0 and oldlvl2 == 1 then
  150.             pb = pb12
  151.             pbs = pb11 + pb12
  152.         end    
  153.        
  154.         if oldlvl1 == 3 and oldlvl2 == 0 then
  155.             pb = pb41
  156.             pbs = pb11 + pb12 + pb41
  157.         end
  158.        
  159.         if oldlvl1 == 3 and oldlvl2 == 1 then
  160.             pb = pb42
  161.             pbs = pb11 + pb12 + pb41 + pb42
  162.         end    
  163.        
  164.         if oldlvl1 == 7 and oldlvl2 == 0 then
  165.             pb = pb81
  166.             pbs = pb11 + pb12 + pb41 + pb42 + pb81
  167.         end
  168.        
  169.         if oldlvl1 == 7 and oldlvl2 == 1 then
  170.             pb = pb82
  171.             pbs = pb11 + pb12 + pb41 + pb42 + pb81 + pb82
  172.         end
  173.        
  174.         if oldlvl1 == 7 and oldlvl2 == 2 then
  175.             pb = pb83
  176.             pbs = pb11 + pb12 + pb41 + pb42 + pb81 + pb82 + pb83
  177.         end
  178.        
  179.         if oldlvl1 == 7 and oldlvl2 == 3 then
  180.             pb = pb84
  181.             pbs = pb11 + pb12 + pb41 + pb42 + pb81 + pb82 + pb83 + pb84 + 655171/39375000
  182.         end
  183.        
  184.        
  185.         --splitter display
  186.         gui.text(x-219,y,(oldlvl1+1).."-"..(oldlvl2+1));
  187.         gui.text(x-200,y,string.format("%06.3f",lvltimefinal));
  188.        
  189.         if lvltimefinal-pb > 0 then
  190.             gui.text(x-165,y,"+"..string.format("%4.2f",lvltimefinal-pb));
  191.         else
  192.             gui.text(x-165,y,string.format("%5.2f",lvltimefinal-pb));
  193.         end
  194.        
  195.         if lvltimesum-pbs > 0 then
  196.             gui.text(x-40,y,"+"..string.format("%4.2f",lvltimesum-pbs));
  197.         else
  198.             gui.text(x-40,y,string.format("%5.2f",lvltimesum-pbs));
  199.         end
  200.        
  201.        
  202.         --splitter reset
  203.         split = 0;
  204.  
  205.         FCEU.frameadvance();
  206. end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement