chore: add script to toggle Cosmoteer's built-in DebugMode
The binary ships a part debugger (OpenPartDebugger, PartDebugValue / PartDebugToggle / PartDebugTrigger) that can show a part's live component values -- the only way from inside the game to see why a modded toggle chain is not firing. It is gated behind the DebugMode setting, which has no UI in a release build. The script refuses to run while the game is open, because Cosmoteer rewrites settings.rules on exit and would discard the change. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011oLWY1G6S8U35bi2FxVWni
This commit is contained in:
Executable
+61
@@ -0,0 +1,61 @@
|
|||||||
|
#!/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"
|
||||||
Reference in New Issue
Block a user