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
Available in editor builds, debug export templates and release export templates.
Available in editor builds and debug export templates only.
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 |
|
Muestra la lista de opciones de línea de comandos. |
|
Muestra una cadena con la versión. |
|
Usa el modo stdout detallado. |
|
Modo silencioso, silencia los mensajes de stdout. Los errores seguirán siendo mostrados. |
Opciones de ejecución
Comando |
Descripción |
|
Separator for user-provided arguments. Following arguments are not used by the engine, but can be read from |
|
Start the editor instead of running the scene. |
|
Start the Project Manager, even if a project is auto-detected. |
|
Start the editor debug server ( |
|
Salir después de la primera iteración. |
|
Quit after the given number of iterations. Set to 0 to disable. |
|
Use a specific locale. |
|
La ruta a un proyecto ( |
|
Buscar un archivo 'project.godot' en las carpetas recursivamente. |
|
Ruta a un archivo de paquete (.pck) a cargar. |
|
Modo de renderizado con hilos ('unsafe', 'safe', 'separate'). Ver Thread Model para más detalles. |
|
Sistema de archivos remoto ( |
|
Password for remote filesystem. |
|
Controlador de audio. Usa |
|
Controlador de video (y controlador de renderizado). Usa |
|
Renderer name. Requires driver support. |
|
Controlador de video (depende del controlador de pantalla). Usa |
|
Use a specific GPU (run with |
|
Text driver (Fonts, BiDi, shaping). |
|
Pen tablet input driver. |
|
Enable headless mode ( |
|
Run the engine in a way that a movie is written (usually with .avi or .png extension).
|
Opciones de visualización
Comando |
Descripción |
|
Solicitar modo de pantalla completa. |
|
Solicitar una ventana maximizada. |
|
Solicitar modo ventana. |
|
Solicita una ventana siempre encima. |
|
Solicitar resolución de ventana. |
|
Solicitar posición de la ventana. |
|
Solicitar pantalla de la ventana. |
|
Use a single window (no separate subwindows). |
|
Select XR mode ('default', 'off', 'on'). |
Opciones de depuración
Comando |
Descripción |
|
Depurar (depurador stdout local). |
|
Lista de puntos de interrupción como fuente::pares separados por comas, sin espacios (usar |
|
Habilitar la creación de perfiles en el depurador de scripts. |
|
Show a GPU profile of the tasks that took the most time during frame rendering. |
|
Enable graphics API validation layers for debugging. |
|
Abort on GPU errors (usually validation layer errors), may help see the problem if your system freezes. |
|
Remote debug ( |
|
Scene tree runs in single-threaded mode. Sub-thread groups are disabled and run on the main thread. |
|
Mostrar la forma de la colisión mientras se ejecuta la escena. |
|
Mostrar las líneas de rutas mientras se ejecuta la escena. |
|
Mostrar polígonos de navegación mientras se ejecuta la escena. |
|
Mostrar visuales de depuración de evasión de navegación mientras se ejecuta la escena. |
|
Print all StringName allocations to stdout when the engine quits. |
|
Simular una alta carga de CPU (retrasar cada fotograma <ms> milisegundos). |
|
Forzar la escala de tiempo (los valores altos son más rápidos, 1.0 es la velocidad normal). |
|
Forces disabling of vertical synchronization, even if enabled in the project settings. Does not override driver-level V-Sync enforcement. |
|
Deshabilita el bucle de renderizado para que el renderizado solo ocurra cuando se llama explícitamente desde un script. |
|
Deshabilite el controlador de fallas cuando sea compatible con el código de la plataforma. |
|
Fuerza un número fijo de fotogramas por segundo. Esta configuración deshabilita la sincronización en tiempo real. |
|
Enable or disable frame delta smoothing ('enable', 'disable'). |
|
Imprime los fotogramas por segundo en la stdout. |
Herramientas independientes
Comando |
Descripción |
|
Ejecuta un script. |
|
Analizar solo los errores y salir (usar con `` --script``). |
|
Export the project using the given preset and matching release template. The preset name
should match one defined in export_presets.cfg. |
|
Like |
|
Como |
|
Convert project from Godot 3.x to Godot 4.x. |
|
Show what elements will be renamed when converting project from Godot 3.x to Godot 4.x. |
|
Volcar la API de referencia del motor al |
|
Disallow dumping the base types (used with |
|
Rather than dumping the engine API, generate API reference from the inline documentation in the GDScript files found in <path>
(used with |
|
Build the scripting solutions (e.g. for C# projects). Implies |
|
Generate GDExtension header file 'gdnative_interface.h' in the current folder. This file is the base file required to implement a GDExtension. |
|
Generate JSON dump of the Godot API for GDExtension bindings named 'extension_api.json' in the current folder. |
|
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 the run time and print it to console. |
|
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
# Standard editor:
brew install godot
# Editor with C# support (will be available as `godot-mono` in `PATH`):
brew 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