Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- _______________________________________________________________________________________
- Start timer
- _______________________________________________________________________________________
- using System;
- using System.IO;
- using System.Text;
- namespace CustomNamespace
- {
- public class CustomClass
- {
- public object Run()
- {
- // Replace my windows username with yours in this filepath
- string path = @"C:\Users\Tetra Gomez\AppData\Local\MixItUp";
- // Save current time
- long startTime = DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond;
- File.WriteAllText(path + @"\startTime.txt", startTime.ToString());
- return 0;
- }
- }
- }
- _______________________________________________________________________________________
- Stop timer and check record
- _______________________________________________________________________________________
- using System;
- using System.IO;
- using System.Text;
- namespace CustomNamespace
- {
- public class CustomClass
- {
- public object Run()
- {
- // Replace my windows username with yours in this filepath
- string path = @"C:\Users\Tetra Gomez\AppData\Local\MixItUp";
- // You can edit the text that is added to the time when there is a new record here
- string recordText = " NEW RECORD!!!";
- // Calculate time delta
- long startTime = long.Parse(File.ReadAllText(path + @"\startTime.txt"));
- long endTime = DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond;
- long elapsedTime = endTime - startTime;
- // Calculate readable increments of time
- long seconds = elapsedTime / 1000;
- long minutes = seconds / 60;
- long hours = minutes / 60;
- // Create readable time string
- StringBuilder time = new StringBuilder();
- if (hours > 0)
- {
- time.Append(hours.ToString());
- time.Append(":");
- }
- time.Append((minutes % 60).ToString("D2"));
- time.Append(":");
- time.Append((seconds % 60).ToString("D2"));
- time.Append(".");
- time.Append((elapsedTime % 1000).ToString("D4"));
- // Check record file, update if necessary. Add new record text if new record achieved.
- if (!File.Exists(path + @"\readableRecord.txt"))
- {
- File.WriteAllText(path + @"\millisRecord.txt", elapsedTime.ToString());
- File.WriteAllText(path + @"\readableRecord.txt", time.ToString());
- }
- else
- {
- long recordTime = long.Parse(File.ReadAllText(path + @"\millisRecord.txt"));
- if (elapsedTime < recordTime)
- {
- File.WriteAllText(path + @"\millisRecord.txt", elapsedTime.ToString());
- File.WriteAllText(path + @"\readableRecord.txt", time.ToString());
- time.Append(recordText);
- }
- }
- // Output readable time with possible new record text to scriptresult
- return time.ToString();
- }
- }
- }
- _______________________________________________________________________________________
- Show Record
- _______________________________________________________________________________________
- using System;
- using System.IO;
- using System.Text;
- namespace CustomNamespace
- {
- public class CustomClass
- {
- public object Run()
- {
- // Replace my windows username with yours in this filepath
- string path = @"C:\Users\Tetra Gomez\AppData\Local\MixItUp";
- // Output record to scriptresult
- return File.ReadAllText(path + @"\readableRecord.txt");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement