# Build Script Documentation

This document explains how to use the `build.py` script to automate the build process for the Beyond-ET Godot project.

## Prerequisites

- Python 3.6 or higher
- Godot engine installed and accessible in your PATH, or you can specify the path to the executable

## Basic Usage

To build the project with default settings (release build using the "Windows Desktop" preset):

```powershell
# Using the PowerShell script
.\build.ps1

# Or directly with Python
python build.py
```

This will create a build in the path specified in your `export_presets.cfg` file (currently set to `build/Beyond-ET.exe`).

## Command Line Options

The script supports the following command line options:

| Option | Description | Default |
|--------|-------------|---------|
| `--godot-path PATH` | Path to the Godot executable | From `.vscode/settings.json` or `godot` |
| `--preset NAME` | Export preset name | `Windows Desktop` |
| `--output PATH` | Output file path | From `export_presets.cfg` |
| `--type TYPE` | Export type: release or debug | `release` |
| `--path PATH` | Path to the Godot project | Current directory |
| `--help` | Show help message and exit | - |

## Examples

### Building a Release Version

```powershell
.\build.ps1 --type release
```

### Building a Debug Version

```powershell
.\build.ps1 --type debug
```

### Specifying a Custom Godot Path

```powershell
.\build.ps1 --godot-path "C:\Path\To\Godot\Godot_v4.0.exe"
```

### Building for a Different Preset

If you have multiple export presets defined in your `export_presets.cfg`:

```powershell
.\build.ps1 --preset "Linux/X11"
```

### Specifying a Custom Output Path

```powershell
.\build.ps1 --output "dist/Beyond-ET.exe"
```

## VSCode Integration

The build script automatically detects the Godot executable path from your VSCode settings. If you're using the Godot Tools extension for VSCode, the script will read the path from `.vscode/settings.json` and use it as the default for the `--godot-path` parameter.

This integration makes it easier to use the same Godot executable that you use for development when building your project.

## Troubleshooting

If you encounter issues:

1. Ensure Godot is properly installed and accessible
2. Check that your export presets are correctly configured in Godot
3. Verify that the `export_presets.cfg` file exists in your project directory
4. If using a custom Godot path, ensure the path is correct and the executable has the necessary permissions
5. If the script isn't finding your Godot executable, check that the path in `.vscode/settings.json` is correct

## Adding New Export Presets

To add new export presets:

1. Open your project in the Godot editor
2. Go to Project > Export
3. Add a new preset for your target platform
4. Configure the preset settings
5. Save the project

The new preset will be available to use with the build script.
