Advertisement
8bitmissingno

Mixitup Morshu Timer Code

Mar 11th, 2025 (edited)
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.92 KB | Software | 0 0
  1. _______________________________________________________________________________________
  2. Start timer
  3. _______________________________________________________________________________________
  4. using System;
  5. using System.IO;
  6. using System.Text;
  7.            
  8. namespace CustomNamespace
  9. {
  10.     public class CustomClass
  11.     {
  12.         public object Run()
  13.         {
  14.             // Replace my windows username with yours in this filepath
  15.             string path = @"C:\Users\Tetra Gomez\AppData\Local\MixItUp";
  16.  
  17.             // Save current time
  18.             long startTime = DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond;
  19.             File.WriteAllText(path + @"\startTime.txt", startTime.ToString());
  20.             return 0;
  21.         }
  22.     }
  23. }
  24.    
  25. _______________________________________________________________________________________
  26. Stop timer and check record
  27. _______________________________________________________________________________________
  28. using System;
  29. using System.IO;
  30. using System.Text;
  31.            
  32. namespace CustomNamespace
  33. {
  34.     public class CustomClass
  35.     {
  36.         public object Run()
  37.         {
  38.             // Replace my windows username with yours in this filepath
  39.             string path = @"C:\Users\Tetra Gomez\AppData\Local\MixItUp";
  40.  
  41.             // You can edit the text that is added to the time when there is a new record here
  42.             string recordText = " NEW RECORD!!!";
  43.  
  44.             // Calculate time delta
  45.             long startTime = long.Parse(File.ReadAllText(path + @"\startTime.txt"));
  46.             long endTime = DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond;
  47.             long elapsedTime = endTime - startTime;
  48.  
  49.             // Calculate readable increments of time
  50.             long seconds = elapsedTime / 1000;
  51.             long minutes = seconds / 60;
  52.             long hours = minutes / 60;
  53.            
  54.             // Create readable time string
  55.             StringBuilder time = new StringBuilder();
  56.             if (hours > 0)
  57.             {
  58.                 time.Append(hours.ToString());
  59.                 time.Append(":");
  60.             }
  61.             time.Append((minutes % 60).ToString("D2"));
  62.             time.Append(":");
  63.             time.Append((seconds % 60).ToString("D2"));
  64.             time.Append(".");
  65.             time.Append((elapsedTime % 1000).ToString("D4"));
  66.            
  67.             // Check record file, update if necessary. Add new record text if new record achieved.
  68.             if (!File.Exists(path + @"\readableRecord.txt"))
  69.             {
  70.                 File.WriteAllText(path + @"\millisRecord.txt", elapsedTime.ToString());
  71.                 File.WriteAllText(path + @"\readableRecord.txt", time.ToString());
  72.             }
  73.             else
  74.             {
  75.                 long recordTime = long.Parse(File.ReadAllText(path + @"\millisRecord.txt"));
  76.                 if (elapsedTime < recordTime)
  77.                 {
  78.                     File.WriteAllText(path + @"\millisRecord.txt", elapsedTime.ToString());
  79.                     File.WriteAllText(path + @"\readableRecord.txt", time.ToString());
  80.                     time.Append(recordText);
  81.                 }
  82.             }
  83.            
  84.             // Output readable time with possible new record text to scriptresult
  85.             return time.ToString();
  86.         }
  87.     }
  88. }
  89.  
  90. _______________________________________________________________________________________
  91. Show Record
  92. _______________________________________________________________________________________
  93. using System;
  94. using System.IO;
  95. using System.Text;
  96.            
  97. namespace CustomNamespace
  98. {
  99.     public class CustomClass
  100.     {
  101.         public object Run()
  102.         {
  103.             // Replace my windows username with yours in this filepath
  104.             string path = @"C:\Users\Tetra Gomez\AppData\Local\MixItUp";
  105.  
  106.             // Output record to scriptresult
  107.             return File.ReadAllText(path + @"\readableRecord.txt");
  108.         }
  109.     }
  110. }
  111.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement