Title here
Summary here
Command-line arguments are a common way to parameterize execution of programs. For example, godot --script hello.gd
uses --script
and hello.gd
arguments to the godot
program.
To experiment with command-line arguments, it’s best to run the script directly with Godot.
In GDScript, we use OS.get_cmdline_args()
to access command-line arguments. The first argument is typically the path to the Godot executable, followed by any script-specific arguments.
Note that in GDScript, arrays are zero-indexed, so OS.get_cmdline_args()[3]
would give us the fourth argument (in this case, “c”).
Next, we’ll look at more advanced command-line processing with parsing options.