play.sh to start the game; Godot checks shared with run_server.sh

This commit is contained in:
Paul Bailey
2026-11-04 18:12:56 +00:00
parent 80786ab796
commit c87b241b29
4 changed files with 55 additions and 30 deletions

View File

@@ -25,6 +25,13 @@ godot --headless --path . --import
Without it you get errors like `Could not find type "Inventory"`.
`server/run_server.sh` and `tests/run_all.sh` do this for you.
## Playing
```bash
./play.sh
```
It finds Godot (on the PATH, or `/Applications/Godot.app`; set `GODOT=` to
pick one), checks it's 4.7+, imports a fresh copy once, then opens the game.
## 3. Running a dedicated server
```bash
server/run_server.sh # settings from server.json

12
play.sh Executable file
View File

@@ -0,0 +1,12 @@
#!/bin/sh
# Starts Emberwild (the game, with its window and title screen).
#
# ./play.sh
#
# Set GODOT=/path/to/godot to use a particular Godot. Any extra arguments go
# to Godot (e.g. ./play.sh --fullscreen). Checks Godot is 4.7+ and imports a
# fresh copy once first, the same as server/run_server.sh.
cd "$(dirname "$0")" || exit 1
. tools/godot_env.sh
exec "$GODOT" --path . "$@"

View File

@@ -8,37 +8,9 @@
# Set GODOT=/path/to/godot to use a particular Godot. Stop it with Ctrl+C.
#
# Before starting it checks that Godot is 4.7 or newer, and imports a fresh
# copy of the project once (Godot's class cache lives in .godot/, which isn't
# in git, so a new clone can't run headless until it has been imported).
# copy of the project once (tools/godot_env.sh).
cd "$(dirname "$0")/.." || exit 1
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
. tools/godot_env.sh
exec "$GODOT" --headless --path . -- --server "$@"

34
tools/godot_env.sh Normal file
View File

@@ -0,0 +1,34 @@
# 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