Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os
- import re
- # Directory containing the files
- directory = '......\CustomLevels'
- # New value for noteJumpMovementSpeed
- new_value = 6
- # Collect debug information
- debug_info = []
- def replace_note_jump_speed(file_path, new_value):
- try:
- with open(file_path, 'r', encoding='utf-8') as file:
- content = file.read()
- # Regex to find noteJumpMovementSpeed values with different spacing scenarios
- pattern = re.compile(r'"_noteJumpMovementSpeed"\s*:\s*\d+(\.\d+)?')
- replacement = f'"_noteJumpMovementSpeed": {new_value}'
- # Check if pattern matches anything
- matches = pattern.findall(content)
- if matches:
- debug_info.append(f"Matches found in {file_path}: {matches}")
- else:
- debug_info.append(f"No matches found in {file_path}")
- # Capture content before replacement for debugging
- debug_info.append(f"Original content of {file_path}:\n{content}\n")
- updated_content = pattern.sub(replacement, content)
- # Capture content after replacement for debugging
- debug_info.append(f"Updated content of {file_path}:\n{updated_content}\n")
- if content != updated_content:
- with open(file_path, 'w', encoding='utf-8') as file:
- file.write(updated_content)
- debug_info.append(f"Updated {file_path}")
- else:
- debug_info.append(f"No changes made to {file_path}")
- except Exception as e:
- debug_info.append(f"Failed to update {file_path}: {e}")
- for root, _, files in os.walk(directory):
- debug_info.append(f"Checking directory: {root}")
- found_info_dat = False
- for file in files:
- if file.lower() == 'info.dat':
- file_path = os.path.join(root, file)
- debug_info.append(f"Found file: {file_path}")
- replace_note_jump_speed(file_path, new_value)
- found_info_dat = True
- if not found_info_dat:
- debug_info.append(f"No info.dat found in directory: {root}")
- # Print collected debug information at the end
- with open('debug_output.txt', 'w', encoding='utf-8') as debug_file:
- for info in debug_info:
- debug_file.write(info + '\n')
- print("All files have been checked. Debug information written to debug_output.txt.")
- input("Press Enter to exit...")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement