LiveSplit-Elite-Magic-8-Bal.../Mischief Mile.asl

129 lines
7.8 KiB
Text
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// Defines the process to monitor. We are not reading anything from the games memory, so its empty.
// We still need it though, LiveSplit will only run the auto splitter if the corresponding process is present.
// See https://github.com/LiveSplit/LiveSplit.AutoSplitters/blob/master/README.md#state-descriptors
state("EliteDangerous64") {}
// Executes when LiveSplit (re-)loads the auto splitter. Does general setup tasks.
// See https://github.com/LiveSplit/LiveSplit.AutoSplitters/blob/master/README.md#script-startup
startup {
// Relevant journal entries
vars.journalReader = null;
vars.startingConditions = new List<System.Text.RegularExpressions.Regex>(2);
vars.startingConditions.Add(
new System.Text.RegularExpressions.Regex(@"\{ ""timestamp"":""(?<timestamp>.*)"", ""event"":""Undocked"", ""StationName"":""Hooke Hub"", ""StationType"":""Ocellus"", ""MarketID"":3230060800(, ""Taxi"":(true|false), ""Multicrew"":(true|false))? \}"));
vars.startingConditions.Add(
new System.Text.RegularExpressions.Regex(@"\{ ""timestamp"":""(?<timestamp>.*)"", ""event"":""Undocked"", ""StationName"":""Ocampo Station"", ""StationType"":""Coriolis"", ""MarketID"":3226909696(, ""Taxi"":(true|false), ""Multicrew"":(true|false))? \}"));
vars.journalEntries = new List<System.Text.RegularExpressions.Regex>(11);
vars.journalEntries.Add(
new System.Text.RegularExpressions.Regex(@"\{ ""timestamp"":""(?<timestamp>.*)"", ""event"":""FSDJump""(, ""Taxi"":(true|false), ""Multicrew"":(true|false))?, ""StarSystem"":""NLTT 48288"", ""SystemAddress"":670149125569, .*\}"));
vars.journalEntries.Add(
new System.Text.RegularExpressions.Regex(@"\{ ""timestamp"":""(?<timestamp>.*)"", ""event"":""FSDJump""(, ""Taxi"":(true|false), ""Multicrew"":(true|false))?, ""StarSystem"":""LHS 3719"", ""SystemAddress"":5069269312953, .*\}"));
vars.journalEntries.Add(
new System.Text.RegularExpressions.Regex(@"\{ ""timestamp"":""(?<timestamp>.*)"", ""event"":""FSDJump""(, ""Taxi"":(true|false), ""Multicrew"":(true|false))?, ""StarSystem"":""Fuelum"", ""SystemAddress"":5031721931482, .*\}"));
vars.journalEntries.Add(
new System.Text.RegularExpressions.Regex(@"\{ ""timestamp"":""(?<timestamp>.*)"", ""event"":""SupercruiseExit""(, ""Taxi"":(true|false), ""Multicrew"":(true|false))?, ""StarSystem"":""Fuelum"", ""SystemAddress"":5031721931482, ""Body"":""Wollheim Vision"", ""BodyID"":24, ""BodyType"":""Station"" \}"));
vars.journalEntries.Add(
new System.Text.RegularExpressions.Regex(@"\{ ""timestamp"":""(?<timestamp>.*)"", ""event"":""Docked"", ""StationName"":""Wollheim Vision"", ""StationType"":""Coriolis""(, ""Taxi"":(true|false), ""Multicrew"":(true|false))?, ""StarSystem"":""Fuelum"", .*\}"));
vars.journalEntries.Add(
new System.Text.RegularExpressions.Regex(@"\{ ""timestamp"":""(?<timestamp>.*)"", ""event"":""FSDJump""(, ""Taxi"":(true|false), ""Multicrew"":(true|false))?, ""StarSystem"":""Mirateje"", ""SystemAddress"":9429432931034, .*\}"));
vars.journalEntries.Add(
new System.Text.RegularExpressions.Regex(@"\{ ""timestamp"":""(?<timestamp>.*)"", ""event"":""SupercruiseExit""(, ""Taxi"":(true|false), ""Multicrew"":(true|false))?, ""StarSystem"":""Mirateje"", ""SystemAddress"":9429432931034, ""Body"":""Ocampo Station"", ""BodyID"":40, ""BodyType"":""Station"" \}"));
vars.journalEntries.Add(
new System.Text.RegularExpressions.Regex(@"\{ ""timestamp"":""(?<timestamp>.*)"", ""event"":""Docked"", ""StationName"":""Ocampo Station"", ""StationType"":""Coriolis""(, ""Taxi"":(true|false), ""Multicrew"":(true|false))?, ""StarSystem"":""Mirateje"", .*\}"));
vars.journalEntries.Add(
new System.Text.RegularExpressions.Regex(@"\{ ""timestamp"":""(?<timestamp>.*)"", ""event"":""FSDJump""(, ""Taxi"":(true|false), ""Multicrew"":(true|false))?, ""StarSystem"":""Tepech"", ""SystemAddress"":11668218324393, .*\}"));
vars.journalEntries.Add(
new System.Text.RegularExpressions.Regex(@"\{ ""timestamp"":""(?<timestamp>.*)"", ""event"":""SupercruiseExit""(, ""Taxi"":(true|false), ""Multicrew"":(true|false))?, ""StarSystem"":""Tepech"", ""SystemAddress"":11668218324393, ""Body"":""Hooke Hub"", ""BodyID"":38, ""BodyType"":""Station"" \}"));
vars.journalEntries.Add(
new System.Text.RegularExpressions.Regex(@"\{ ""timestamp"":""(?<timestamp>.*)"", ""event"":""Docked"", ""StationName"":""Hooke Hub"", ""StationType"":""Ocellus""(, ""Taxi"":(true|false), ""Multicrew"":(true|false))?, ""StarSystem"":""Tepech"", .*\}"));
// Journal file handling
vars.journalPath = Path.Combine(
Environment.GetFolderPath(Environment.SpecialFolder.UserProfile),
"Saved Games",
"Frontier Developments",
"Elite Dangerous"
);
vars.currentJournal = "none";
vars.updateJournalReader = (Action)delegate() {
FileInfo journalFile = new DirectoryInfo(vars.journalPath).GetFiles("journal.*.log").OrderByDescending(file => file.LastWriteTime).First();
print("Current journal file: " + vars.currentJournal + ", latest journal file: " + journalFile.Name);
if (journalFile.Name != vars.currentJournal) {
vars.journalReader = new StreamReader(new FileStream(journalFile.FullName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite));
vars.currentJournal = journalFile.Name;
}
};
vars.updateJournalReader();
vars.journalReader.ReadToEnd();
// Watch for new files
FileSystemWatcher journalWatcher = new FileSystemWatcher(vars.journalPath);
journalWatcher.Created += (object sender, FileSystemEventArgs eventArgs) => {
vars.updateJournalReader();
};
journalWatcher.EnableRaisingEvents = true;
}
// Executes when LiveSplit detects the game process (see “state” at the top of the file).
// In our case the journal and netlog files are unique to every execution of the game, so we need to prepare them here.
// We also need to check if file logging is enabled (the setting is not available in `startup`) and create/open our log file.
// See https://github.com/LiveSplit/LiveSplit.AutoSplitters/blob/master/README.md#script-initialization-game-start
init {
vars.updateJournalReader();
vars.journalReader.ReadToEnd();
}
// Executes as long as the game process is running, by default 60 times per second.
// Unless explicitly returning `false`, `start`, `split` and `reset` are executed right after.
// See https://github.com/LiveSplit/LiveSplit.AutoSplitters/blob/master/README.md#generic-update
update {
current.journalString = vars.journalReader.ReadToEnd();
}
// Executes every `update`. Starts the timer if the first journal event is detected.
// See https://github.com/LiveSplit/LiveSplit.AutoSplitters/blob/master/README.md#automatic-timer-start-1
start {
bool start = false;
if (!String.IsNullOrEmpty(current.journalString)) {
foreach (System.Text.RegularExpressions.Regex condition in vars.startingConditions) {
if (condition.Match(current.journalString).Success) {
start = true;
}
}
}
return start;
}
// Executes every `update`. Triggers a split if the journal event triggering the next split is detected.
// See https://github.com/LiveSplit/LiveSplit.AutoSplitters/blob/master/README.md#automatic-splits-1
split {
bool split = false;
if (!String.IsNullOrEmpty(current.journalString)) {
foreach (System.Text.RegularExpressions.Regex entry in vars.journalEntries) {
if (entry.Match(current.journalString).Success) {
split = true;
}
}
}
return split;
}
// Executes when the game process is shut down.
// In our case were going to close the files we opened in `init`.
// See https://github.com/LiveSplit/LiveSplit.AutoSplitters/blob/master/README.md#game-exit
exit {
vars.journalReader.Close();
}
// Executes when LiveScript shuts the auto splitter down, e.g. on reloading it.
// When reloading the splitter with the game running, LiveSplit does **not** execute `exit`, but it does execute `shutdown`.
// see https://github.com/LiveSplit/LiveSplit.AutoSplitters/blob/master/README.md#script-shutdown
shutdown {
if (vars.journalReader != null) {
vars.journalReader.Close();
}
}