Explorar o código

Fix headless check in Exporting for dedicated servers (#8362)

The example didn't work as `--headless` isn't part of `OS.get_cmdline_args()`' return value.

This new approach also works if the binary automatically uses headless mode
because it's the only display server built in the binary (which can be the case
for custom builds).

Co-authored-by: Hugo Locurcio <[email protected]>
Michael Weibel hai 1 ano
pai
achega
383a70e17c
Modificáronse 1 ficheiros con 2 adicións e 2 borrados
  1. 2 2
      tutorials/export/exporting_for_dedicated_servers.rst

+ 2 - 2
tutorials/export/exporting_for_dedicated_servers.rst

@@ -217,7 +217,7 @@ main scene (or an autoload)'s ``_ready()`` method:
 .. tabs::
 .. tabs::
  .. code-tab:: gdscript
  .. code-tab:: gdscript
 
 
-    if "--headless" in OS.get_cmdline_args():
+    if DisplayServer.get_name() == "headless":
         # Run your server startup code here...
         # Run your server startup code here...
         #
         #
         # Using this check, you can start a dedicated server by running
         # Using this check, you can start a dedicated server by running
@@ -229,7 +229,7 @@ main scene (or an autoload)'s ``_ready()`` method:
 
 
     using System.Linq;
     using System.Linq;
 
 
-    if (OS.GetCmdlineArgs().Contains("--headless"))
+    if (DisplayServer.GetName() == "headless")
     {
     {
         // Run your server startup code here...
         // Run your server startup code here...
         //
         //