Skip to content

Instantly share code, notes, and snippets.

@rapidcow
Last active January 18, 2023 15:48
Show Gist options
  • Save rapidcow/adbe1549765e2a02c7cd3e3edd990371 to your computer and use it in GitHub Desktop.
Save rapidcow/adbe1549765e2a02c7cd3e3edd990371 to your computer and use it in GitHub Desktop.
tool for doing isaac daily run :P

this is a python 3.8+ script that automatically toggles EnableDebugConsole... because to do daily run not only do you have to turn off all mods but also you have to disable the debug console.

(NOTE: ONLY FOR REPENTANCE ON WINDOWS!!!1!)

put this file literally anywhere on your device and it should work... i hope.

it finds the options.ini file in your $USERPROFILE/Document/My Games/Binding of Isaac Repentance/ directory and either

  • creates a new options.ini with a single line EnableDebugConsole=1, or
  • toggles the value of EnableDebugConsole in the preexisting options.ini file (by toggling i basically mean 0 turns into 1, and 1 turns into 0)

if you don't have any line that starts with EnableDebugConsole, then this script will append EnableDebugConsole=1 to the end of your file.

running this script changes options.ini upon success, although a backup can be found at options_backup.ini. (if options_backup.ini already exists, though, it is overridden without warnings.)

"""cheating (Windows + Repentance only!)"""
import os
import shutil
import sys
import tempfile
try:
USER = os.environ['USERPROFILE']
except KeyError:
raise RuntimeError('failed to acquire USER path')
def perror(*args, **kwargs):
print(*args, **kwargs, file=sys.stderr)
def toggle_debug_console(options_ini):
if not os.path.exists(options_ini):
print("options.ini doesn't exist yet! creating it now...")
with open(options_ini, encoding='ascii') as fp:
fp.write('EnableDebugConsole=1\n')
return
# value of EnableDebugConsole if it exists, else 0 by default
value = 0
# line number right when EnableDebugConsole appears
# (number of lines before that line minus one)
lineno = 0
with open(options_ini, encoding='ascii') as fp:
i = 0
for i, line in enumerate(fp):
if line.startswith('EnableDebugConsole'):
line = line.rstrip('\r\n')
try:
left, right = line.split('=')
value = int(right)
except ValueError:
raise ValueError(f"i can't parse this line in "
f"options.ini: {line!r}")
lineno = i
# don't break the loop because we might find a newer line!
# if we didn't encounter EnableDebugConsole=... on any line,
# then we'll set this to the last line number (so that later on
# no line will be skipped)
if not lineno:
lineno = i
# alternate between (0, 1)
new_value = value ^ 1
with tempfile.TemporaryDirectory() as tmpdir:
tmp_ini = os.path.join(tmpdir, 'options.ini')
with open(tmp_ini, 'w', encoding='ascii') as dst:
with open(options_ini, encoding='ascii') as src:
for _ in range(lineno):
dst.write(src.readline())
if value != -1:
dst.write(f'EnableDebugConsole={new_value}\n')
src.readline()
else:
dst.write('EnableDebugConsole=1\n')
for line in src:
dst.write(line)
if value != -1:
print(f'changed value of EnableDebugConsole from '
f'{value} to {new_value}')
else:
print('added EnableDebugConsole=1 to the end')
# create a backup
backup_ini = os.path.splitext(options_ini)[0] + '_backup.ini'
if os.path.exists(backup_ini):
print('options_backup.ini exists, removing it')
os.unlink(backup_ini)
shutil.copy(options_ini, backup_ini)
shutil.move(tmp_ini, options_ini)
if __name__ == '__main__':
my_games = os.path.join(USER, 'Documents', 'My Games')
selected_dir = None
for entry in os.scandir(my_games):
if entry.is_dir():
if entry.name == 'Binding of Isaac Repentance':
selected_dir = entry.path
if not selected_dir:
perror(f'i did not find any isaac in your {my_games} directory '
f'(sad)')
exit(1)
# if len(found) > 1:
# print(f'found {len(found)} isaacs! but i need you to choose...')
# while True:
# perror('choose one of',
# ', '.join(name for (name, _) in found),
# end=': ')
# user_input = input()
# for name, dirpath in found:
# if user_input.lower() == name.lower():
# selected_dir = dirpath
# break
# else:
# continue
# break
# else:
# selected_dir = found[0]
print('selected', selected_dir)
toggle_debug_console(os.path.join(selected_dir, 'options.ini'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment