diff --git a/util/clear_editor_state.py b/util/clear_editor_state.py new file mode 100644 index 0000000..05f68a2 --- /dev/null +++ b/util/clear_editor_state.py @@ -0,0 +1,23 @@ +#!/usr/bin/python3 +from pathlib import Path + +# Current working directory +cwd = Path.cwd() + +for path in cwd.glob('**/*.tscn'): + result = [] + + with path.open() as f: + for line in f.readlines(): + if line.startswith('_sections_unfolded'): + # Skip lines that start with _sections_unfolded + continue + elif line.startswith('[node') and 'parent=' not in line: + # Root node, remove 'index="0"' + result.append(line.replace(' index="0"', '')) + else: + # Add line as is + result.append(line) + + with path.open('w') as f: + f.writelines(result) \ No newline at end of file