Skip to content

Instantly share code, notes, and snippets.

@Specnr
Created September 11, 2021 23:06
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Specnr/279e61476ba754fed7307068edecada9 to your computer and use it in GitHub Desktop.
Save Specnr/279e61476ba754fed7307068edecada9 to your computer and use it in GitHub Desktop.
A biome-exclusive autoresetting AHK script for Minecraft RSG (Currently NOT legal)
; Biome-exclusive single-instance autoresetting AHK script
; Author: Specnr
; Depends on AutoReset Mod AND Chunk Mod v1.0.2+ AND (probably idk) FastReset
#NoEnv
#SingleInstance Force
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%
SetTitleMatchMode, 2
; default global variables
global saves := "C:\MultiInstanceMC\MultiMC\instances\WideHardo\.minecraft\saves\" ; keep the last slash
global oldWorldsFolder := "C:\MultiInstanceMC\oldWorlds\"
global disableTTS := False
global prefs := {"beach": True, "forest": True, "plains": True, "savannah": True, "ocean": True, "jungle": True, "desert": True}
IsInGame()
{
rawLogFile := StrReplace(saves, "saves", "logs\latest.log")
StringTrimRight, logFile, rawLogFile, 1
numLines := 0
Loop, Read, %logFile%
{
numLines += 1
}
saved := False
startTime := A_TickCount
Loop, Read, %logFile%
{
if ((numLines - A_Index) < 5)
{
if (InStr(A_LoopReadLine, "Loaded 0 advancements")) {
saved := True
break
}
}
}
return saved
}
MoveWorlds()
{
Loop, Files, %saves%*, D
{
If (InStr(A_LoopFileName, "Speedrun #"))
FileMoveDir, %saves%%A_LoopFileName%, %oldWorldsFolder%%A_LoopFileName%%A_NowUTC%Instance %idx%, R
}
}
GetCurrAdvDir() {
Loop, Files, %saves%*, D
{
CheckFile_Start := A_LoopFileTimeCreated
If (CheckFile_Start > CheckFile_End)
{
CheckFile_End := A_LoopFileTimeCreated
Out := A_LoopFileFullPath
}
}
return Out "\advancements\"
}
SpawnBiome(biome, advDir)
{
while (True) {
if (FileExist(advDir "*.json"))
break
}
Loop, Files, %advDir%*.json
FileReadLine, data, %advDir%%A_LoopFileName%, 4
return InStr(data, biome)
}
CheckBiomes(advDir)
{
for biome, toCheck in prefs {
if (toCheck && SpawnBiome(biome, advDir))
return biome
}
return -1
}
AutoReset()
{
while (True) {
Send, +{Tab}{Enter}
sleep, 150
MoveWorlds()
while (True) {
if (IsInGame())
break
}
Send, {Esc}
advDir := GetCurrAdvDir()
if (CheckBiomes(advDir) != -1) {
Send, {Esc}{F3 down}{Esc}{F3 up}
if (!disableTTS)
ComObjCreate("SAPI.SpVoice").Speak("Seed")
return
}
}
}
#IfWinActive, Minecraft
{
RAlt::ExitApp ; Exits Script
U:: ; Starts autoresetting
Send, {Esc}
AutoReset()
return
}
@Specnr
Copy link
Author

Specnr commented Sep 11, 2021

@Specnr
Copy link
Author

Specnr commented Sep 11, 2021

For setup just configure saves, oldWorlds, disableTTS and prefs to your liking.
To enable/disable a biome just edit prefs to be True/False for that biome. You can add other biomes by following the trend in prefs

@Specnr
Copy link
Author

Specnr commented Sep 11, 2021

ILLEGAL BTW :)

@Morni12
Copy link

Morni12 commented Feb 14, 2022

can i get this but on a wall?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment