#!/usr/bin/env bash # ABOUT ME # Turns Cosmoteer's built-in DebugMode on or off by editing settings.rules. # # Why it exists: the game binary contains a part debugger (OpenPartDebugger, # PartDebugValue / PartDebugToggle / PartDebugTrigger) which can show a part's # live component values. That is the only way to see, from inside the game, why # a modded toggle chain is not doing what it should. It is gated behind the # DebugMode setting, which has no in-game UI in a release build. # # Cosmoteer rewrites settings.rules when it exits, so the game must be closed # before running this or the change is lost. # # Usage: ./debug_mode.sh on # ./debug_mode.sh off set -euo pipefail MODE="${1:-}" case "$MODE" in on) VALUE="Normal" ;; off) VALUE="None" ;; *) echo "Usage: $0 on|off" >&2; exit 1 ;; esac find_settings() { local candidates=( "$HOME"/.local/share/Steam/steamapps/compatdata/799600/pfx/drive_c/users/steamuser/"Saved Games"/Cosmoteer/*/settings.rules /mnt/*/SteamLibrary/steamapps/compatdata/799600/pfx/drive_c/users/steamuser/"Saved Games"/Cosmoteer/*/settings.rules "$HOME"/"Saved Games"/Cosmoteer/*/settings.rules "$HOME"/Documents/"My Games"/Cosmoteer/*/settings.rules ) for path in "${candidates[@]}"; do [ -f "$path" ] && printf '%s\n' "$path" && return 0 done return 1 } SETTINGS="${COSMOTEER_SETTINGS:-$(find_settings || true)}" if [ -z "$SETTINGS" ]; then echo "Could not find settings.rules. Set COSMOTEER_SETTINGS and run again." >&2 exit 1 fi if pgrep -f -i cosmoteer >/dev/null 2>&1; then echo "Cosmoteer is running. Quit it first -- it rewrites settings.rules on exit" >&2 echo "and would discard this change." >&2 exit 1 fi [ -f "$SETTINGS.bak-preautorad" ] || cp "$SETTINGS" "$SETTINGS.bak-preautorad" if grep -qE '^DebugMode = ' "$SETTINGS"; then sed -i "s/^DebugMode = .*/DebugMode = $VALUE/" "$SETTINGS" else printf 'DebugMode = %s\n' "$VALUE" >> "$SETTINGS" fi echo "DebugMode = $VALUE" echo "Backup at $SETTINGS.bak-preautorad"