# Shared by play.sh and server/run_server.sh (sourced, not run). Run from the # project folder. Sets GODOT to a Godot 4.7+ binary and imports a fresh copy # of the project once; exits with a message if either isn't possible. # # Godot's class cache lives in .godot/, which isn't in git, so a new clone # can't run until it has been imported. GODOT="${GODOT:-godot}" if ! command -v "$GODOT" >/dev/null 2>&1; then # macOS: use the app bundle if `godot` isn't on the PATH. if [ -x /Applications/Godot.app/Contents/MacOS/Godot ]; then GODOT=/Applications/Godot.app/Contents/MacOS/Godot else echo "Can't find Godot. Install 4.7.2 from https://godotengine.org/download, or set GODOT=/path/to/godot" >&2 exit 1 fi fi version=$("$GODOT" --version 2>/dev/null | tail -n 1) major=$(echo "$version" | cut -d. -f1) minor=$(echo "$version" | cut -d. -f2) if [ -z "$major" ] || [ "$major" -lt 4 ] || { [ "$major" -eq 4 ] && [ "$minor" -lt 7 ]; }; then echo "This game needs Godot 4.7 or newer, but $GODOT is ${version:-unknown}." >&2 echo "Download 4.7.2 from https://godotengine.org/download (or set GODOT=/path/to/a/newer/godot)" >&2 exit 1 fi if [ ! -f .godot/global_script_class_cache.cfg ]; then echo "First run on this copy: importing the project (a few seconds)..." if ! "$GODOT" --headless --path . --import >/dev/null 2>&1 || [ ! -f .godot/global_script_class_cache.cfg ]; then echo "Import failed. Try: $GODOT --headless --path . --import" >&2 exit 1 fi fi