|
187 | 187 | <method name="get_cmdline_args"> |
188 | 188 | <return type="PackedStringArray" /> |
189 | 189 | <description> |
190 | | - Returns the command-line arguments passed to the engine. |
| 190 | + Returns the command-line arguments passed to the engine, excluding arguments processed by the engine, such as [code]--headless[/code] and [code]--fullscreen[/code]. |
| 191 | + [codeblock] |
| 192 | + # Godot has been executed with the following command: |
| 193 | + # godot --headless --verbose --scene my_scene.tscn --custom |
| 194 | + OS.get_cmdline_args() # Returns ["--scene", "my_scene.tscn", "--custom"] |
| 195 | + [/codeblock] |
191 | 196 | Command-line arguments can be written in any form, including both [code]--key value[/code] and [code]--key=value[/code] forms so they can be properly parsed, as long as custom command-line arguments do not conflict with engine arguments. |
192 | 197 | You can also incorporate environment variables using the [method get_environment] method. |
193 | 198 | You can set [member ProjectSettings.editor/run/main_run_args] to define command-line arguments to be passed by the editor when running the project. |
|
231 | 236 | Returns the command-line user arguments passed to the engine. User arguments are ignored by the engine and reserved for the user. They are passed after the double dash [code]--[/code] argument. [code]++[/code] may be used when [code]--[/code] is intercepted by another program (such as [code]startx[/code]). |
232 | 237 | [codeblock] |
233 | 238 | # Godot has been executed with the following command: |
234 | | - # godot --fullscreen -- --level=2 --hardcore |
| 239 | + # godot --fullscreen --custom -- --level=2 --hardcore |
235 | 240 |
|
236 | | - OS.get_cmdline_args() # Returns ["--fullscreen", "--level=2", "--hardcore"] |
| 241 | + OS.get_cmdline_args() # Returns ["--custom"] |
237 | 242 | OS.get_cmdline_user_args() # Returns ["--level=2", "--hardcore"] |
238 | 243 | [/codeblock] |
239 | | - To get all passed arguments, use [method get_cmdline_args]. |
| 244 | + To get arguments passed before [code]--[/code] or [code]++[/code], use [method get_cmdline_args]. |
240 | 245 | </description> |
241 | 246 | </method> |
242 | 247 | <method name="get_config_dir" qualifiers="const"> |
|
0 commit comments