Skip to content

Instantly share code, notes, and snippets.

@Dregu
Last active May 29, 2022 18:02
Show Gist options
  • Save Dregu/f1b19e91989b93c908f2d2d642bf922c to your computer and use it in GitHub Desktop.
Save Dregu/f1b19e91989b93c908f2d2d642bf922c to your computer and use it in GitHub Desktop.
Noita Scriptable Auto Splitter (+seed/kill display) for LiveSplit
/*
* Noita Scriptable Auto Splitter + seed display + kill counter
* Starts on spawn
* Splits on work
* Resets on death or new game
*
* You have to edit the logPath below to point to your installation for this to actually work, I don't know where your game is.
* Get https://github.com/hawkerm/LiveSplit.ASLVarViewer to display world seed and/or kill counter to your stream, mom or whatever.
*/
state("noita") {
int foo: "noita.exe", 0; // stupid ASLVarViewer doesn't work without state variables
}
startup {
settings.Add("start", true, "Start");
settings.Add("spawn", true, "when player spawns", "start");
settings.Add("splits", true, "Split");
settings.Add("work", true, "when you complete the work", "splits");
settings.Add("reset", true, "Reset");
settings.Add("dead", true, "when dead", "reset");
settings.Add("newgame", true, "when starting game", "reset");
}
init {
string logPath = "C:\\Steam\\steamapps\\common\\Noita\\logger.txt";
try {
FileStream fs = new FileStream(logPath, FileMode.Open, FileAccess.Write, FileShare.ReadWrite);
fs.SetLength(0);
fs.Close();
} catch {
print("Cant open log");
}
vars.nextIsSeed = false;
vars.seed = "";
vars.kills = 0;
vars.isPaused = false;
vars.line = "";
vars.reader = new StreamReader(new FileStream(logPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite));
if (vars.reader != null) print("opened log");
}
exit {
timer.IsGameTimePaused = true;
vars.reader = null;
}
update {
if (vars.reader == null) return false;
vars.line = vars.reader.ReadLine();
if(vars.line != null && vars.line.StartsWith("Player killed someone!")) {
vars.kills++;
} else if (vars.line != null && vars.line.StartsWith("World seed:")) {
vars.seed = vars.line.Split(' ')[2];
if(vars.seed == "") vars.nextIsSeed = true;
} else if (vars.nextIsSeed) {
vars.seed = vars.line;
vars.nextIsSeed = false;
}
}
start {
if(vars.line != null && vars.line.StartsWith("SpawnPlayer")) {
timer.IsGameTimePaused = false;
vars.kills = 0;
vars.dead = false;
return true;
}
}
reset {
if(vars.line != null && vars.line.StartsWith("World seed:")) {
return settings["newgame"];
}
if(vars.line != null && vars.line.StartsWith("HandleEvent - Player Entity Destroyed")) {
return settings["dead"];
}
}
split {
if (vars.line != null && vars.line.StartsWith("LUA: Sampo:")) {
return (settings["work"]);
}
}
isLoading {
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment