From 718f15fee81884318e1d03b3069a2c28eda53cae Mon Sep 17 00:00:00 2001 From: Donal Cahill Date: Wed, 9 Mar 2022 17:28:59 +0000 Subject: [PATCH] feature: allow running the script from any cwd --- er-patcher | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/er-patcher b/er-patcher index 0caf55b..0ce560e 100755 --- a/er-patcher +++ b/er-patcher @@ -25,6 +25,13 @@ if __name__ == "__main__": patch = parser.parse_args(patcher_args) exe_name = Path("eldenring.exe") + + # If the script is in the same directory as eldenring.exe, assume that is the game directory. + # Otherwise, assume we are already in the game directory. + script_dir = Path(os.path.dirname(os.path.realpath(__file__))) + if (script_dir / exe_name).exists(): + os.chdir(script_dir) + with open(exe_name, "rb") as f: exe_hex = f.read().hex()