Skip to content

Instantly share code, notes, and snippets.

@databoose
Created July 8, 2025 04:16
Show Gist options
  • Save databoose/bf181c72d749b0ad9a06c4fa779f5e2b to your computer and use it in GitHub Desktop.
Save databoose/bf181c72d749b0ad9a06c4fa779f5e2b to your computer and use it in GitHub Desktop.
import re
from pathlib import Path
def get_potential_base_paths():
base_suffix = Path('steamapps/compatdata/1874880/pfx/drive_c/users/steamuser/Documents/My Games/ArmaReforger/profile/.save')
for steam_root in [Path.home() / '.steam' / 'steam', Path.home() / '.local' / 'share' / 'Steam', Path.home() / '.steam' / 'root']:
yield steam_root / base_suffix
library_config = Path.home() / '.steam' / 'steam' / 'config' / 'libraryfolders.vdf'
if library_config.exists():
try:
with open(library_config, 'r') as f:
for path in re.findall(r'"path"\s+"([^"]+)"', f.read()):
yield Path(path) / base_suffix
except Exception as e:
print(f"Failed to read {library_config}: {e}")
for mount_point in [Path('/media'), Path('/mnt')]:
print(mount_point)
if mount_point.exists():
for user_dir in mount_point.iterdir():
if user_dir.is_dir():
for sub_dir in user_dir.iterdir():
steam_lib = sub_dir / 'SteamLibrary'
if steam_lib.is_dir():
yield steam_lib / base_suffix
def find_config_file():
for base_path in get_potential_base_paths():
if not base_path.exists():
continue
# print(f"Checking base path: {base_path}")
try:
app_folder = next(f for f in base_path.iterdir() if f.is_dir() and f.name.startswith('app'))
config_path = app_folder / 'settings' / 'ReforgerEngineSettings.conf'
if config_path.exists():
print(f"Config file located: {config_path}\n")
return config_path
print(f"No config file found in {app_folder}")
except StopIteration:
print(f"No 'app*' folder found in {base_path}")
print("No config file found after searching all potential locations.")
return None
def update_grass_settings(config_file):
try:
with open(config_file, 'r', encoding='utf-8') as f:
content = f.read()
pattern = r'(GrassMaterialSettings\s+GrassMaterialSettings\s+(\S+)\s*\{)(.*?)\}'
match = re.search(pattern, content, re.DOTALL)
if not match:
print("No GrassMaterialSettings block found in the config.")
return
identifier = match.group(2)
# print(f"Detected identifier: {identifier}")
current_settings = {}
for line in match.group(3).split('\n'):
line = line.strip()
if not line:
continue
parts = re.split(r'\s+', line, maxsplit=1)
if len(parts) == 2:
current_settings[parts[0]] = parts[1]
else:
print(f"Skipping malformed setting: '{line}'")
target_settings = {'Distance': '0', 'Lod': '1', 'Quality': '0'}
if current_settings == target_settings:
print("GrassMaterialSettings already set to target values.")
return
new_settings_lines = [f" {key} {value}" for key, value in target_settings.items()]
new_settings = '\n'.join(new_settings_lines)
new_block = f"GrassMaterialSettings GrassMaterialSettings {identifier} {{\n{new_settings}\n}}"
updated_content = content[:match.start(0)] + new_block + content[match.end(0):]
with open(config_file, 'w', encoding='utf-8') as f:
f.write(updated_content)
print(f"Successfully updated {config_file} with new GrassMaterialSettings.\n")
except Exception as e:
print(f"Error updating {config_file}: {e}")
def main():
"""Main function to locate and update the config file."""
config_path = find_config_file()
if config_path:
update_grass_settings(config_path)
else:
print("Unable to locate ReforgerEngineSettings.conf.")
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment