Skip to content

Instantly share code, notes, and snippets.

@jasonswearingen
Created March 5, 2025 04:30
Show Gist options
  • Save jasonswearingen/05652aa8560a563cb240913300a64461 to your computer and use it in GitHub Desktop.
Save jasonswearingen/05652aa8560a563cb240913300a64461 to your computer and use it in GitHub Desktop.
godot launcher Powershell script for developers
<#
.SYNOPSIS
Runs Godot editor and automatically restarts it if it closes.
.DESCRIPTION
This script launches the Godot editor with specified arguments, and automatically restarts it if it closes.
.PARAMETER ExePath
The path to the Godot executable. Defaults to the console version of Godot 4.4 stable.
Use the _console.exe version of godot otherwise the script won't wait while godot is running.
.PARAMETER Arguments
Command line arguments to pass to Godot. Defaults to "--verbose --editor --debug --path ."
.PARAMETER ProjectPath
The path to the Godot project directory. Defaults to "V:\r2025\v2025-MonoRepo\src\Novaleaf.GodotDev"
#>
param (
# Use the _console.exe version of godot otherwise the script won't wait while godot is running.
[Parameter(Mandatory=$false)]
[string]$ExePath = "V:\r2025\v2025-MonoRepo\binaries\Godot_v4.4-stable_mono_win64\Godot_v4.4-stable_mono_win64_console.exe",
[Parameter(Mandatory=$false)]
[string]$Arguments = "--verbose --editor --debug --path .",
[Parameter(Mandatory=$false)]
[string]$ProjectPath = "V:\r2025\v2025-MonoRepo\src\Novaleaf.GodotDev"
)
# Store the original location before changing it
$originalLocation = Get-Location
# Extract the directory from the full exe path
$exeDir = Split-Path -Parent $ExePath
$exeName = Split-Path -Leaf $ExePath
# Change to the directory containing the exe
Set-Location -Path $ProjectPath
try {
while ($true) {
# Execute the program with arguments
Write-Host "Starting $exeName with arguments: $Arguments" -ForegroundColor Cyan
& "$ExePath" $Arguments.Split()
Write-Host "============== PROGRAM EXITED, WILL RESTART (CTRL-C TO ABORT) ==================" -ForegroundColor Yellow
Write-Host "============== PROGRAM EXITED, WILL RESTART (CTRL-C TO ABORT) ==================" -ForegroundColor Yellow
Write-Host "============== PROGRAM EXITED, WILL RESTART (CTRL-C TO ABORT) ==================" -ForegroundColor Yellow
Start-Sleep -Seconds 1 # Short pause before restarting
}
}
finally {
# This block will execute when the script exits (even if terminated with Ctrl+C)
# Return to the original directory
Set-Location -Path $originalLocation
Write-Host "Returned to original directory: $originalLocation" -ForegroundColor Cyan
Read-Host -Prompt "Press Enter to exit"
}
@jasonswearingen
Copy link
Author

this is a script I wrote to help development.

Modify the input parameters in the script $ExePath and $ProjectPath, then when you run it (from anywhere), it will show highly detailed output, including thrown C# exceptions that the godot console doesn't show.

If godot crashes, it will automatically relaunch. I use this with [Tool] scripts because when I rebuild my C# project sometimes godot will crash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment