Up to date

This page is up to date for Godot 4.2. If you still find outdated information, please open an issue.

Tutorial de línea de comandos

A algunos desarrolladores les gusta usar la línea de comandos extensivamente. Godot está diseñado para ser amigable con ellos, así que aquí están los pasos para trabajar completamente desde la línea de comandos. Dado que el motor depende de pocas o ninguna librería externa, los tiempos de inicialización son bastante rápidos, lo que lo hace adecuado para este flujo de trabajo.

Nota

En Windows y Linux, puedes ejecutar un binario de Godot en una terminal especificando su ruta relativa o absoluta.

En macOS, el proceso es diferente debido a que Godot está contenido en un paquete .app (que es una carpeta, no un archivo). Para ejecutar un binario de Godot desde un terminal en macOS, debe cd en la carpeta donde se encuentra el paquete de aplicaciones de Godot, luego ejecutar Godot.app / Contents / MacOS / Godot seguido de cualquier línea de comando argumentos. Si ha cambiado el nombre del paquete de aplicaciones de Godot a otro nombre, asegúrese de editar esta línea de comando en consecuencia.

Referencia de la línea de comandos

Legend

  • release Available in editor builds, debug export templates and release export templates.

  • debug Available in editor builds and debug export templates only.

  • editor Only available in editor builds.

Note that unknown command line arguments have no effect whatsoever. The engine will not warn you when using a command line argument that doesn't exist with a given build type.

Opciones generales

Comando

Descripción

-h, --help

release Muestra la lista de opciones de línea de comandos.

--version

release Muestra una cadena con la versión.

-v, --verbose

release Usa el modo stdout detallado.

-q, --quiet

release Modo silencioso, silencia los mensajes de stdout. Los errores seguirán siendo mostrados.

Opciones de ejecución

Comando

Descripción

--, ++

release Separator for user-provided arguments. Following arguments are not used by the engine, but can be read from OS.get_cmdline_user_args().

-e, --editor

editor Start the editor instead of running the scene.

-p, --project-manager

editor Start the Project Manager, even if a project is auto-detected.

--debug-server <uri>

editor Start the editor debug server (<protocol>://<host/IP>[:<port>], e.g. tcp://127.0.0.1:6007)

--quit

release Salir después de la primera iteración.

--quit-after

release Quit after the given number of iterations. Set to 0 to disable.

-l, --language <locale>

release Use a specific locale. <locale> follows the format language_Script_COUNTRY_VARIANT where language is a 2 or 3-letter language code in lowercase and the rest is optional. See Locale codes for more details.

--path <directorio>

release La ruta a un proyecto (directory debe contener un archivo 'project.godot').

-u, --upwards

release Buscar un archivo 'project.godot' en las carpetas recursivamente.

--main-pack <archivo>

release Ruta a un archivo de paquete (.pck) a cargar.

--render-thread <modo>

release Modo de renderizado con hilos ('unsafe', 'safe', 'separate'). Ver Thread Model para más detalles.

--remote-fs <dirección>

release Sistema de archivos remoto (<host/IP>[:<port>] dirección).

--remote-fs-password <password>

release Password for remote filesystem.

--audio-driver <driver>

release Controlador de audio. Usa --help primero para mostrar la lista de controladores disponibles.

--display-driver <driver>

release Controlador de video (y controlador de renderizado). Usa --help primero para mostrar la lista de controladores disponibles.

--rendering-method <renderer>

release Renderer name. Requires driver support.

--rendering-driver <driver>

release Controlador de video (depende del controlador de pantalla). Usa --help primero para mostrar la lista de controladores disponibles.

--gpu-index <device_index>

release Use a specific GPU (run with --verbose to get available device list).

--text-driver <driver>

release Text driver (Fonts, BiDi, shaping).

--tablet-driver <driver>

release Pen tablet input driver.

--headless

release Enable headless mode (--display-driver headless --audio-driver Dummy). Useful for servers and with --script.

--write-movie <file>

release Run the engine in a way that a movie is written (usually with .avi or .png extension). --fixed-fps is forced when enabled, but can be used to change movie FPS. --disable-vsync can speed up movie writing but makes interaction more difficult. --quit-after can be used to specify the number of frames to write.

Opciones de visualización

Comando

Descripción

-f, --fullscreen

release Solicitar modo de pantalla completa.

-m, --maximized

release Solicitar una ventana maximizada.

-w, --windowed

release Solicitar modo ventana.

-t, --always-on-top

release Solicita una ventana siempre encima.

--resolution <W>x<H>

release Solicitar resolución de ventana.

--position <X>,<Y>

release Solicitar posición de la ventana.

--screen <N>

release Solicitar pantalla de la ventana.

--single-window

release Use a single window (no separate subwindows).

--xr-mode <mode>

release Select XR mode ('default', 'off', 'on').

Opciones de depuración

Comando

Descripción

-d, --debug

release Depurar (depurador stdout local).

-b, --breakpoints

release Lista de puntos de interrupción como fuente::pares separados por comas, sin espacios (usar %20 en su lugar).

--profiling

release Habilitar la creación de perfiles en el depurador de scripts.

--gpu-profile

release Show a GPU profile of the tasks that took the most time during frame rendering.

--gpu-validation

release Enable graphics API validation layers for debugging.

--gpu-abort

debug Abort on GPU errors (usually validation layer errors), may help see the problem if your system freezes.

--remote-debug <uri>

release Remote debug (<protocol>://<host/IP>[:<port>], e.g. tcp://127.0.0.1:6007).

--single-threaded-scene

release Scene tree runs in single-threaded mode. Sub-thread groups are disabled and run on the main thread.

--debug-collisions

debug Mostrar la forma de la colisión mientras se ejecuta la escena.

--debug-paths

debug Mostrar las líneas de rutas mientras se ejecuta la escena.

--debug-navigation

debug Mostrar polígonos de navegación mientras se ejecuta la escena.

--debug-avoidance

debug Mostrar visuales de depuración de evasión de navegación mientras se ejecuta la escena.

--debug-stringnames

debug Print all StringName allocations to stdout when the engine quits.

--frame-delay <ms>

release Simular una alta carga de CPU (retrasar cada fotograma <ms> milisegundos).

--time-scale <escala>

release Forzar la escala de tiempo (los valores altos son más rápidos, 1.0 es la velocidad normal).

--disable-vsync

release Forces disabling of vertical synchronization, even if enabled in the project settings. Does not override driver-level V-Sync enforcement.

--disable-render-loop

release Deshabilita el bucle de renderizado para que el renderizado solo ocurra cuando se llama explícitamente desde un script.

--disable-crash-handler

release Deshabilite el controlador de fallas cuando sea compatible con el código de la plataforma.

--fixed-fps <fps>

release Fuerza un número fijo de fotogramas por segundo. Esta configuración deshabilita la sincronización en tiempo real.

--delta-smoothing <enable>

release Enable or disable frame delta smoothing ('enable', 'disable').

--print-fps

release Imprime los fotogramas por segundo en la stdout.

Herramientas independientes

Comando

Descripción

-s, --script <script>

release Ejecuta un script.

--check-only

release Analizar solo los errores y salir (usar con `` --script``).

--export-release <preset> <path>

editor Export the project using the given preset and matching release template. The preset name should match one defined in export_presets.cfg. <path> should be absolute or relative to the project directory, and include the filename for the binary (e.g. 'builds/game.exe'). The target directory should exist.

--export-debug <preset> <path>

editor Like --export-release, but use debug template.

--export-pack <preestablecido> <ruta>

editor Como --export-release, pero sólo para exportar el paquete del juego para un preset dado. La extensión de <path> determina si será en formato PCK o ZIP.

--convert-3to4 [<max_file_kb>] [<max_line_size>]

editor Convert project from Godot 3.x to Godot 4.x.

--validate-conversion-3to4 [<max_file_kb>] [<max_line_size>]

editor Show what elements will be renamed when converting project from Godot 3.x to Godot 4.x.

--doctool [<path>]

editor Volcar la API de referencia del motor al <path> dado en formato XML, si encuentra archivos existentes, los combina.

--no-docbase

editor Disallow dumping the base types (used with --doctool).

--gdscript-docs <path>

editor Rather than dumping the engine API, generate API reference from the inline documentation in the GDScript files found in <path> (used with --doctool).

--build-solutions

editor Build the scripting solutions (e.g. for C# projects). Implies --editor and requires a valid project to edit.

--dump-gdextension-interface

editor Generate GDExtension header file 'gdnative_interface.h' in the current folder. This file is the base file required to implement a GDExtension.

--dump-extension-api

editor Generate JSON dump of the Godot API for GDExtension bindings named 'extension_api.json' in the current folder.

--validate-extension-api <path>

editor Validate an extension API file dumped (with the option above) from a previous version of the engine to ensure API compatibility. If incompatibilities or errors are detected, the return code will be non-zero.

--benchmark

editor Benchmark the run time and print it to console.

--benchmark-file <path>

editor Benchmark the run time and save it to a given file in JSON format. The path should be absolute.

Ruta

Se recomienda que el binario de Godot se encuentre en la variable de entorno PATH, para que pueda ejecutarse fácilmente desde cualquier lugar escribiendo godot. Puedes hacerlo en Linux colocando el binario de Godot en /usr/local/bin y asegurándote de que se llame godot (sensible a mayúsculas).

To achieve this on Windows or macOS easily, you can install Godot using Scoop (on Windows) or Homebrew (on macOS). This will automatically make the copy of Godot installed available in the PATH:

# Standard editor:
scoop install godot

# Editor with C# support (will be available as `godot-mono` in `PATH`):
scoop install godot-mono

Configuración de la ruta del proyecto

Dependiendo de dónde se encuentre el binario de Godot y cuál sea su directorio de trabajo actual, es posible que necesites establecer la ruta a tu proyecto para que cualquiera de los siguientes comandos funcione correctamente.

When running the editor, this can be done by giving the path to the project.godot file of your project as either the first argument, like this:

godot path_to_your_project/project.godot [other] [commands] [and] [args]

For all commands, this can be done by using the --path argument:

godot --path path_to_your_project [other] [commands] [and] [args]

Por ejemplo, el comando completo para exportar tu juego (como se explica a continuación) podría verse así:

godot --headless --path path_to_your_project --export-release my_export_preset_name game.exe

When starting from a subdirectory of your project, use the --upwards argument for Godot to automatically find the project.godot file by recursively searching the parent directories.

For example, running a scene (as explained below) nested in a subdirectory might look like this when your working directory is in the same path:

godot --upwards nested_scene.tscn

Creación de un proyecto

Para crear un proyecto desde la línea de comandos, navega hasta el lugar deseado en el shell y crea un archivo project.godot.

mkdir newgame
cd newgame
touch project.godot

El proyecto ahora puede abrirse con Godot.

Ejecutar el editor

Running the editor is done by executing Godot with the -e flag. This must be done from within the project directory or by setting the project path as explained above, otherwise the command is ignored and the Project Manager appears.

godot -e

When passing in the full path to the project.godot file, the -e flag may be omitted.

Si una escena ha sido creada y guardada, puede ser editada más tarde ejecutando el mismo código con esa escena como argumento.

godot -e scene.tscn

Borrar una escena

Godot is friends with your filesystem and will not create extra metadata files. Use rm to erase a scene file. Make sure nothing references that scene. Otherwise, an error will be thrown upon opening the project.

rm scene.tscn

Ejecutar el juego

To run the game, execute Godot within the project directory or with the project path as explained above.

godot

Note that passing in the project.godot file will always run the editor instead of running the game.

Cuando sea necesario probar una escena específica, pásala por línea de comandos.

godot scene.tscn

Depuración

Catching errors in the command line can be a difficult task because they scroll quickly. For this, a command line debugger is provided by adding -d. It works for running either the game or a single scene.

godot -d
godot -d scene.tscn

Exportar

Exporting the project from the command line is also supported. This is especially useful for continuous integration setups.

Nota

Using the --headless command line argument is required on platforms that do not have GPU access (such as continuous integration). On platforms with GPU access, --headless prevents a window from spawning while the project is exporting.

# `godot` must be a Godot editor binary, not an export template.
# Also, export templates must be installed for the editor
# (or a valid custom export template must be defined in the export preset).
godot --headless --export-release "Linux/X11" /var/builds/project
godot --headless --export-release Android /var/builds/project.apk

El nombre del preset debe coincidir con el nombre de un preset de exportación definido en el archivo `` export_presets.cfg `` del proyecto. Si el nombre predeterminado contiene espacios o caracteres especiales (como "Escritorio de Windows"), debe estar entre comillas.

To export a debug version of the game, use the --export-debug switch instead of --export-release. Their parameters and usage are the same.

To export only a PCK file, use the --export-pack option followed by the preset name and output path, with the file extension, instead of --export-release or --export-debug. The output path extension determines the package's format, either PCK or ZIP.

Advertencia

When specifying a relative path as the path for --export-release, --export-debug or --export-pack, the path will be relative to the directory containing the project.godot file, not relative to the current working directory.

Ejecutar un script

It is possible to run a .gd script from the command line. This feature is especially useful in large projects, e.g. for batch conversion of assets or custom import/export.

El script debe heredar de SceneTree o MainLoop.

Here is an example sayhello.gd, showing how it works:

#!/usr/bin/env -S godot -s
extends SceneTree

func _init():
    print("Hello!")
    quit()

Y cómo ejecutarlo:

# Prints "Hello!" to standard output.
godot -s sayhello.gd

Si project.godot no existe en la ruta, se asume que la ruta actual es el directorio de trabajo a utilizar (a menos que se especifique --path).

La primera línea de sayhello.gd se conoce comúnmente como shebang. Si el binario Godot está en tu PATH como godot, te permite ejecutar el script de la siguiente manera en distribuciones Linux modernas, así como en macOS:

# Mark script as executable.
chmod +x sayhello.gd
# Prints "Hello!" to standard output.
./sayhello.gd

Si lo anterior no funciona en su versión actual de Linux o MacOS, siempre puede hacer que el shebang ejecute Godot directamente desde donde se encuentra, de la siguiente manera:

#!/usr/bin/godot -s