Godot 4 Example - binarycounter/Westonpack GitHub Wiki

Running Godot 4 Games

Prerequisites:

  • Your game needs to be compatible with Godot version 4.2.2, 4.3 or 4.4. If your version isn't listed here, try the next version up, there's a good chance it'll work.
  • If your game has compressed textures, they need to be in ETC2 or ASTC format. Most 2D games do not have compressed textures, most 3D games do. (Stay tuned, a texture converter is in development)
  • Your game needs to be compatible with the "compatibility" or "mobile" renderer.
  • You game cannot include native code for non-arm64 platforms

Required Runtimes:

  • Westonpack 0.2.6 or higher (weston_pkg_0.2.squashfs)
  • Godot 4.2.2 or higher (godot_4.2.2.squashfs)

Example Script

#!/bin/bash

# PortMaster preamble
XDG_DATA_HOME=${XDG_DATA_HOME:-$HOME/.local/share}
if [ -d "/opt/system/Tools/PortMaster/" ]; then
  controlfolder="/opt/system/Tools/PortMaster"
elif [ -d "/opt/tools/PortMaster/" ]; then
  controlfolder="/opt/tools/PortMaster"
elif [ -d "$XDG_DATA_HOME/PortMaster/" ]; then
  controlfolder="$XDG_DATA_HOME/PortMaster"
else
  controlfolder="/roms/ports/PortMaster"
fi
source $controlfolder/control.txt
[ -f "${controlfolder}/mod_${CFW_NAME}.txt" ] && source "${controlfolder}/mod_${CFW_NAME}.txt"
get_controls

# Adjust these to your paths and desired godot version
GAMEDIR=/$directory/ports/your_port_folder
godot_runtime="godot_4.2.2"
godot_executable="godot422.$DEVICE_ARCH"
pck_filename="YourGame.pck"
gptk_filename="YourControls.gptk"

# Logging
> "$GAMEDIR/log.txt" && exec > >(tee "$GAMEDIR/log.txt") 2>&1

# Create directory for save files
CONFDIR="$GAMEDIR/conf/"
$ESUDO mkdir -p "${CONFDIR}"

# Mount Weston runtime
weston_dir=/tmp/weston
$ESUDO mkdir -p "${weston_dir}"
weston_runtime="weston_pkg_0.2"
if [ ! -f "$controlfolder/libs/${weston_runtime}.squashfs" ]; then
  if [ ! -f "$controlfolder/harbourmaster" ]; then
    pm_message "This port requires the latest PortMaster to run, please go to https://portmaster.games/ for more info."
    sleep 5
    exit 1
  fi
  $ESUDO $controlfolder/harbourmaster --quiet --no-check runtime_check "${weston_runtime}.squashfs"
fi
if [ "$PM_CAN_MOUNT" != "N" ](/binarycounter/Westonpack/wiki/-"$PM_CAN_MOUNT"-!=-"N"-); then
    $ESUDO umount "${weston_dir}"
fi
$ESUDO mount "$controlfolder/libs/${weston_runtime}.squashfs" "${weston_dir}"

# Mount Godot runtime
godot_dir=/tmp/godot
$ESUDO mkdir -p "${godot_dir}"
if [ ! -f "$controlfolder/libs/${godot_runtime}.squashfs" ]; then
  if [ ! -f "$controlfolder/harbourmaster" ]; then
    pm_message "This port requires the latest PortMaster to run, please go to https://portmaster.games/ for more info."
    sleep 5
    exit 1
  fi
  $ESUDO $controlfolder/harbourmaster --quiet --no-check runtime_check "${godot_runtime}.squashfs"
fi
if [ "$PM_CAN_MOUNT" != "N" ](/binarycounter/Westonpack/wiki/-"$PM_CAN_MOUNT"-!=-"N"-); then
    $ESUDO umount "${godot_dir}"
fi
$ESUDO mount "$controlfolder/libs/${godot_runtime}.squashfs" "${godot_dir}"


cd $GAMEDIR
$GPTOKEYB "$godot_executable" -c "$GAMEDIR/$gptk_filename" &

# Start Westonpack and Godot
# Put CRUSTY_SHOW_CURSOR=1 after "env" if you need a mouse cursor
$ESUDO env $weston_dir/westonwrap.sh headless noop kiosk crusty_x11egl \
XDG_DATA_HOME=$CONFDIR $godot_dir/$godot_executable \
--resolution ${DISPLAY_WIDTH}x${DISPLAY_HEIGHT} -f \
--rendering-driver opengl3_es --audio-driver ALSA --main-pack $GAMEDIR/$pck_filename

#Clean up after ourselves
$ESUDO $weston_dir/westonwrap.sh cleanup
if [ "$PM_CAN_MOUNT" != "N" ](/binarycounter/Westonpack/wiki/-"$PM_CAN_MOUNT"-!=-"N"-); then
    $ESUDO umount "${weston_dir}"
    $ESUDO umount "${godot_dir}"
fi
pm_finish