1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
|
// AutoSplit script for Temple of Starlight, by hatkirby
state("Temple of Starlight") {}
startup {
// Relative to Livesplit.exe
vars.logFilePath = Directory.GetCurrentDirectory() + "\\autosplitter_starlight.log";
vars.log = (Action<string>)((string logLine) => {
print("[Temple of Starlight ASL] " + logLine);
string time = System.DateTime.Now.ToString("dd/MM/yy hh:mm:ss.fff");
// AppendAllText will create the file if it doesn't exist.
System.IO.File.AppendAllText(vars.logFilePath, time + ": " + logLine + "\r\n");
});
var bytes = File.ReadAllBytes(@"Components\LiveSplit.ASLHelper.bin");
var type = Assembly.Load(bytes).GetType("ASLHelper.Unity");
vars.Helper = Activator.CreateInstance(type, timer, this);
vars.Helper.LoadSceneManager = true;
vars.prevLevel = 0;
vars.prev = new List<int>();
vars.firstRoom = false;
vars.noSplitScenes = new List<String>{
"StartScene",
"LevelSelect"
};
vars.log("Autosplitter loaded");
}
init {
vars.Helper.TryOnLoad = (Func<dynamic, bool>)(mono =>
{
return true;
});
vars.Helper.Load();
}
update {
if (!vars.Helper.Update())
return false;
current.level = vars.Helper.Scenes.Active.Index;
}
onStart {
vars.prevLevel = current.level;
vars.prev.Clear();
vars.firstRoom = false;
}
split {
// Split when level index changes. We don't split for the first room change
// in a run, because that is always going to be changing to the first room,
// and it happens a couple of seconds after the timer starts.
if (vars.firstRoom
&& current.level != vars.prevLevel
&& current.level > 0
&& !vars.noSplitScenes.Contains(vars.Helper.Scenes.Active.Name)) {
vars.log(String.Format("{0}: '{1}'", current.level, vars.Helper.Scenes.Active.Name));
string action = "NO SPLIT";
if (vars.prevLevel != 0) {
action = "SPLIT";
if (vars.prev.Contains(current.level)) {
action = "NO SPLIT";
}
vars.prev.Add(current.level);
vars.log(String.Format("Level changed from {0} to {1}: {2}", vars.prevLevel, current.level, action));
}
vars.prevLevel = current.level;
return action.StartsWith("SPLIT");
} else if (!vars.firstRoom && vars.Helper.Scenes.Active.Name == "Level01") {
vars.firstRoom = true;
vars.prevLevel = current.level;
vars.prev.Add(current.level);
}
}
exit
{
vars.Helper.Dispose();
}
shutdown
{
vars.Helper.Dispose();
}
|