diff --git a/classes/class_editorimportplugin.rst b/classes/class_editorimportplugin.rst index 7771076a0..49cbd5d01 100644 --- a/classes/class_editorimportplugin.rst +++ b/classes/class_editorimportplugin.rst @@ -272,19 +272,19 @@ Gets whether the import option specified by ``option_name`` should be visible in .. code-tab:: gdscript - func _get_option_visibility(option, options): + func _get_option_visibility(path, option_name, options): # Only show the lossy quality setting if the compression mode is set to "Lossy". - if option == "compress/lossy_quality" and options.has("compress/mode"): + if option_name == "compress/lossy_quality" and options.has("compress/mode"): return int(options["compress/mode"]) == COMPRESS_LOSSY # This is a constant that you set return true .. code-tab:: csharp - public void _GetOptionVisibility(string option, Godot.Collections.Dictionary options) + public override bool _GetOptionVisibility(string path, StringName optionName, Godot.Collections.Dictionary options) { // Only show the lossy quality setting if the compression mode is set to "Lossy". - if (option == "compress/lossy_quality" && options.ContainsKey("compress/mode")) + if (optionName == "compress/lossy_quality" && options.ContainsKey("compress/mode")) { return (int)options["compress/mode"] == CompressLossy; // This is a constant you set } diff --git a/classes/class_editorsettings.rst b/classes/class_editorsettings.rst index 832ad2e01..036da48a3 100644 --- a/classes/class_editorsettings.rst +++ b/classes/class_editorsettings.rst @@ -5492,7 +5492,15 @@ If ``true``, uses :ref:`StringName` instead of :ref:`String` **text_editor/completion/add_type_hints** :ref:`🔗` -If ``true``, adds :doc:`GDScript static typing <../tutorials/scripting/gdscript/static_typing>` hints such as ``-> void`` and ``: int`` when using code autocompletion or when creating onready variables by drag and dropping nodes into the script editor while pressing the :kbd:`Ctrl` key. If ``true``, newly created scripts will also automatically have type hints added to their method parameters and return types. +If ``true``, automatically adds :doc:`GDScript static typing <../tutorials/scripting/gdscript/static_typing>` (such as ``-> void`` and ``: int``) in many situations where it's possible to, including when: + +- Accepting a suggestion from code autocompletion; + +- Creating a new script from a template; + +- Connecting signals from the Node dock; + +- Creating variables prefixed with :ref:`@GDScript.@onready`, by dropping nodes from the Scene dock into the script editor while holding :kbd:`Ctrl`. .. rst-class:: classref-item-separator diff --git a/classes/class_fileaccess.rst b/classes/class_fileaccess.rst index ad5a7f8e0..fd8152ebf 100644 --- a/classes/class_fileaccess.rst +++ b/classes/class_fileaccess.rst @@ -1104,7 +1104,7 @@ Sets file UNIX permissions. :ref:`bool` **store_8**\ (\ value\: :ref:`int`\ ) :ref:`🔗` -Stores an integer as 8 bits in the file. This advances the file cursor by 1 byte. +Stores an integer as 8 bits in the file. This advances the file cursor by 1 byte. Returns ``true`` if the operation is successful. \ **Note:** The ``value`` should lie in the interval ``[0, 255]``. Any other value will overflow and wrap around. @@ -1122,7 +1122,7 @@ To store a signed integer, use :ref:`store_64()` **store_16**\ (\ value\: :ref:`int`\ ) :ref:`🔗` -Stores an integer as 16 bits in the file. This advances the file cursor by 2 bytes. +Stores an integer as 16 bits in the file. This advances the file cursor by 2 bytes. Returns ``true`` if the operation is successful. \ **Note:** The ``value`` should lie in the interval ``[0, 2^16 - 1]``. Any other value will overflow and wrap around. @@ -1177,7 +1177,7 @@ To store a signed integer, use :ref:`store_64()` **store_32**\ (\ value\: :ref:`int`\ ) :ref:`🔗` -Stores an integer as 32 bits in the file. This advances the file cursor by 4 bytes. +Stores an integer as 32 bits in the file. This advances the file cursor by 4 bytes. Returns ``true`` if the operation is successful. \ **Note:** The ``value`` should lie in the interval ``[0, 2^32 - 1]``. Any other value will overflow and wrap around. @@ -1195,7 +1195,7 @@ To store a signed integer, use :ref:`store_64()` **store_64**\ (\ value\: :ref:`int`\ ) :ref:`🔗` -Stores an integer as 64 bits in the file. This advances the file cursor by 8 bytes. +Stores an integer as 64 bits in the file. This advances the file cursor by 8 bytes. Returns ``true`` if the operation is successful. \ **Note:** The ``value`` must lie in the interval ``[-2^63, 2^63 - 1]`` (i.e. be a valid :ref:`int` value). @@ -1211,7 +1211,7 @@ Stores an integer as 64 bits in the file. This advances the file cursor by 8 byt :ref:`bool` **store_buffer**\ (\ buffer\: :ref:`PackedByteArray`\ ) :ref:`🔗` -Stores the given array of bytes in the file. This advances the file cursor by the number of bytes written. +Stores the given array of bytes in the file. This advances the file cursor by the number of bytes written. Returns ``true`` if the operation is successful. \ **Note:** If an error occurs, the resulting value of the file position indicator is indeterminate. @@ -1227,7 +1227,7 @@ Stores the given array of bytes in the file. This advances the file cursor by th Store the given :ref:`PackedStringArray` in the file as a line formatted in the CSV (Comma-Separated Values) format. You can pass a different delimiter ``delim`` to use other than the default ``","`` (comma). This delimiter must be one-character long. -Text will be encoded as UTF-8. +Text will be encoded as UTF-8. Returns ``true`` if the operation is successful. \ **Note:** If an error occurs, the resulting value of the file position indicator is indeterminate. @@ -1241,7 +1241,7 @@ Text will be encoded as UTF-8. :ref:`bool` **store_double**\ (\ value\: :ref:`float`\ ) :ref:`🔗` -Stores a floating-point number as 64 bits in the file. This advances the file cursor by 8 bytes. +Stores a floating-point number as 64 bits in the file. This advances the file cursor by 8 bytes. Returns ``true`` if the operation is successful. \ **Note:** If an error occurs, the resulting value of the file position indicator is indeterminate. @@ -1255,7 +1255,7 @@ Stores a floating-point number as 64 bits in the file. This advances the file cu :ref:`bool` **store_float**\ (\ value\: :ref:`float`\ ) :ref:`🔗` -Stores a floating-point number as 32 bits in the file. This advances the file cursor by 4 bytes. +Stores a floating-point number as 32 bits in the file. This advances the file cursor by 4 bytes. Returns ``true`` if the operation is successful. \ **Note:** If an error occurs, the resulting value of the file position indicator is indeterminate. @@ -1269,7 +1269,7 @@ Stores a floating-point number as 32 bits in the file. This advances the file cu :ref:`bool` **store_half**\ (\ value\: :ref:`float`\ ) :ref:`🔗` -Stores a half-precision floating-point number as 16 bits in the file. This advances the file cursor by 2 bytes. +Stores a half-precision floating-point number as 16 bits in the file. This advances the file cursor by 2 bytes. Returns ``true`` if the operation is successful. \ **Note:** If an error occurs, the resulting value of the file position indicator is indeterminate. @@ -1283,7 +1283,7 @@ Stores a half-precision floating-point number as 16 bits in the file. This advan :ref:`bool` **store_line**\ (\ line\: :ref:`String`\ ) :ref:`🔗` -Stores ``line`` in the file followed by a newline character (``\n``), encoding the text as UTF-8. This advances the file cursor by the length of the line, after the newline character. The amount of bytes written depends on the UTF-8 encoded bytes, which may be different from :ref:`String.length()` which counts the number of UTF-32 codepoints. +Stores ``line`` in the file followed by a newline character (``\n``), encoding the text as UTF-8. This advances the file cursor by the length of the line, after the newline character. The amount of bytes written depends on the UTF-8 encoded bytes, which may be different from :ref:`String.length()` which counts the number of UTF-32 codepoints. Returns ``true`` if the operation is successful. \ **Note:** If an error occurs, the resulting value of the file position indicator is indeterminate. @@ -1297,7 +1297,7 @@ Stores ``line`` in the file followed by a newline character (``\n``), encoding t :ref:`bool` **store_pascal_string**\ (\ string\: :ref:`String`\ ) :ref:`🔗` -Stores the given :ref:`String` as a line in the file in Pascal format (i.e. also store the length of the string). Text will be encoded as UTF-8. This advances the file cursor by the number of bytes written depending on the UTF-8 encoded bytes, which may be different from :ref:`String.length()` which counts the number of UTF-32 codepoints. +Stores the given :ref:`String` as a line in the file in Pascal format (i.e. also store the length of the string). Text will be encoded as UTF-8. This advances the file cursor by the number of bytes written depending on the UTF-8 encoded bytes, which may be different from :ref:`String.length()` which counts the number of UTF-32 codepoints. Returns ``true`` if the operation is successful. \ **Note:** If an error occurs, the resulting value of the file position indicator is indeterminate. @@ -1313,7 +1313,7 @@ Stores the given :ref:`String` as a line in the file in Pascal for Stores a floating-point number in the file. This advances the file cursor by either 4 or 8 bytes, depending on the precision used by the current Godot build. -If using a Godot build compiled with the ``precision=single`` option (the default), this method will save a 32-bit float. Otherwise, if compiled with the ``precision=double`` option, this will save a 64-bit float. +If using a Godot build compiled with the ``precision=single`` option (the default), this method will save a 32-bit float. Otherwise, if compiled with the ``precision=double`` option, this will save a 64-bit float. Returns ``true`` if the operation is successful. \ **Note:** If an error occurs, the resulting value of the file position indicator is indeterminate. @@ -1327,7 +1327,7 @@ If using a Godot build compiled with the ``precision=single`` option (the defaul :ref:`bool` **store_string**\ (\ string\: :ref:`String`\ ) :ref:`🔗` -Stores ``string`` in the file without a newline character (``\n``), encoding the text as UTF-8. This advances the file cursor by the length of the string in UTF-8 encoded bytes, which may be different from :ref:`String.length()` which counts the number of UTF-32 codepoints. +Stores ``string`` in the file without a newline character (``\n``), encoding the text as UTF-8. This advances the file cursor by the length of the string in UTF-8 encoded bytes, which may be different from :ref:`String.length()` which counts the number of UTF-32 codepoints. Returns ``true`` if the operation is successful. \ **Note:** This method is intended to be used to write text files. The string is stored as a UTF-8 encoded buffer without string length or terminating zero, which means that it can't be loaded back easily. If you want to store a retrievable string in a binary file, consider using :ref:`store_pascal_string()` instead. For retrieving strings from a text file, you can use ``get_buffer(length).get_string_from_utf8()`` (if you know the length) or :ref:`get_as_text()`. @@ -1343,7 +1343,7 @@ Stores ``string`` in the file without a newline character (``\n``), encoding the :ref:`bool` **store_var**\ (\ value\: :ref:`Variant`, full_objects\: :ref:`bool` = false\ ) :ref:`🔗` -Stores any Variant value in the file. If ``full_objects`` is ``true``, encoding objects is allowed (and can potentially include code). This advances the file cursor by the number of bytes written. +Stores any Variant value in the file. If ``full_objects`` is ``true``, encoding objects is allowed (and can potentially include code). This advances the file cursor by the number of bytes written. Returns ``true`` if the operation is successful. Internally, this uses the same encoding mechanism as the :ref:`@GlobalScope.var_to_bytes()` method, as described in the :doc:`Binary serialization API <../tutorials/io/binary_serialization_api>` documentation. diff --git a/classes/class_graphedit.rst b/classes/class_graphedit.rst index df8bf1050..fb5e2bd22 100644 --- a/classes/class_graphedit.rst +++ b/classes/class_graphedit.rst @@ -1272,6 +1272,27 @@ A connection is represented as a :ref:`Dictionary` in the form keep_alive: bool } +\ **Example:** Get all connections on a specific port: + +:: + + func get_connection_list_from_port(node, port): + var connections = get_connection_list_from_node(node) + var result = [] + for connection in connections: + var dict = {} + if connection["from_node"] == node and connection["from_port"] == port: + dict["node"] = connection["to_node"] + dict["port"] = connection["to_port"] + dict["type"] = "left" + result.push_back(dict) + elif connection["to_node"] == node and connection["to_port"] == port: + dict["node"] = connection["from_node"] + dict["port"] = connection["from_port"] + dict["type"] = "right" + result.push_back(dict) + return result + .. rst-class:: classref-item-separator ---- diff --git a/classes/class_navigationmesh.rst b/classes/class_navigationmesh.rst index 05fbc5ad8..797b18520 100644 --- a/classes/class_navigationmesh.rst +++ b/classes/class_navigationmesh.rst @@ -330,6 +330,8 @@ The distance to erode/shrink the walkable area of the heightfield away from obst \ **Note:** While baking, this value will be rounded up to the nearest multiple of :ref:`cell_size`. +\ **Note:** The radius must be equal or higher than ``0.0``. If the radius is ``0.0``, it won't be possible to fix invalid outline overlaps and other precision errors during the baking process. As a result, some obstacles may be excluded incorrectly from the final navigation mesh, or may delete the navigation mesh's polygons. + .. rst-class:: classref-item-separator ---- @@ -349,7 +351,7 @@ The size of the non-navigable border around the bake bounding area. In conjunction with the :ref:`filter_baking_aabb` and a :ref:`edge_max_error` value at ``1.0`` or below the border size can be used to bake tile aligned navigation meshes without the tile edges being shrunk by :ref:`agent_radius`. -\ **Note:** While baking and not zero, this value will be rounded up to the nearest multiple of :ref:`cell_size`. +\ **Note:** If this value is not ``0.0``, it will be rounded up to the nearest multiple of :ref:`cell_size` during baking. .. rst-class:: classref-item-separator diff --git a/classes/class_navigationpolygon.rst b/classes/class_navigationpolygon.rst index d882b1cbf..f273124bc 100644 --- a/classes/class_navigationpolygon.rst +++ b/classes/class_navigationpolygon.rst @@ -303,6 +303,8 @@ Property Descriptions The distance to erode/shrink the walkable surface when baking the navigation mesh. +\ **Note:** The radius must be equal or higher than ``0.0``. If the radius is ``0.0``, it won't be possible to fix invalid outline overlaps and other precision errors during the baking process. As a result, some obstacles may be excluded incorrectly from the final navigation mesh, or may delete the navigation mesh's polygons. + .. rst-class:: classref-item-separator ---- diff --git a/classes/class_projectsettings.rst b/classes/class_projectsettings.rst index c59e9d34b..754336000 100644 --- a/classes/class_projectsettings.rst +++ b/classes/class_projectsettings.rst @@ -3430,8 +3430,6 @@ Editor-only override for :ref:`debug/settings/crash_handler/message` to function. -Enabling this comes at the cost of roughly 40 KiB for every thread that runs any GDScript code. - \ **Note:** This setting has no effect on editor builds or debug builds, where GDScript call stacks are tracked regardless. .. rst-class:: classref-item-separator diff --git a/classes/class_resource.rst b/classes/class_resource.rst index 2562b568a..77a6ea7d0 100644 --- a/classes/class_resource.rst +++ b/classes/class_resource.rst @@ -284,7 +284,7 @@ Override this method to return a custom :ref:`RID` when :ref:`get_rid |void| **_reset_state**\ (\ ) |virtual| :ref:`🔗` -For resources that use a variable number of properties, either via :ref:`Object._validate_property()` or :ref:`Object._get_property_list()`, this method should be implemented to correctly clear the resource's state. +For resources that store state in non-exported properties, such as via :ref:`Object._validate_property()` or :ref:`Object._get_property_list()`, this method must be implemented to clear them. .. rst-class:: classref-item-separator @@ -296,7 +296,7 @@ For resources that use a variable number of properties, either via :ref:`Object. |void| **_set_path_cache**\ (\ path\: :ref:`String`\ ) |virtual| |const| :ref:`🔗` -Sets the resource's path to ``path`` without involving the resource cache. +Override this method to execute additional logic after :ref:`set_path_cache()` is called on this object. .. rst-class:: classref-item-separator @@ -405,7 +405,7 @@ Generates a unique identifier for a resource to be contained inside a :ref:`Pack :ref:`String` **get_id_for_path**\ (\ path\: :ref:`String`\ ) |const| :ref:`🔗` -Returns the unique identifier for the resource with the given ``path`` from the resource cache. If the resource is not loaded and cached, an empty string is returned. +From the internal cache for scene-unique IDs, returns the ID of this resource for the scene at ``path``. If there is no entry, an empty string is returned. Useful to keep scene-unique IDs the same when implementing a VCS-friendly custom resource format by extending :ref:`ResourceFormatLoader` and :ref:`ResourceFormatSaver`. \ **Note:** This method is only implemented when running in an editor context. At runtime, it returns an empty string. @@ -443,7 +443,7 @@ Returns the :ref:`RID` of this resource (or an empty RID). Many resou :ref:`bool` **is_built_in**\ (\ ) |const| :ref:`🔗` -Returns ``true`` if the resource is built-in (from the engine) or ``false`` if it is user-defined. +Returns ``true`` if the resource is saved on disk as a part of another resource's file. .. rst-class:: classref-item-separator @@ -455,7 +455,7 @@ Returns ``true`` if the resource is built-in (from the engine) or ``false`` if i |void| **reset_state**\ (\ ) :ref:`🔗` -For resources that use a variable number of properties, either via :ref:`Object._validate_property()` or :ref:`Object._get_property_list()`, override :ref:`_reset_state()` to correctly clear the resource's state. +Makes the resource clear its non-exported properties. See also :ref:`_reset_state()`. Useful when implementing a custom resource format by extending :ref:`ResourceFormatLoader` and :ref:`ResourceFormatSaver`. .. rst-class:: classref-item-separator @@ -467,7 +467,7 @@ For resources that use a variable number of properties, either via :ref:`Object. |void| **set_id_for_path**\ (\ path\: :ref:`String`, id\: :ref:`String`\ ) :ref:`🔗` -Sets the unique identifier to ``id`` for the resource with the given ``path`` in the resource cache. If the unique identifier is empty, the cache entry using ``path`` is removed if it exists. +In the internal cache for scene-unique IDs, sets the ID of this resource to ``id`` for the scene at ``path``. If ``id`` is empty, the cache entry for ``path`` is cleared. Useful to keep scene-unique IDs the same when implementing a VCS-friendly custom resource format by extending :ref:`ResourceFormatLoader` and :ref:`ResourceFormatSaver`. \ **Note:** This method is only implemented when running in an editor context. @@ -481,7 +481,7 @@ Sets the unique identifier to ``id`` for the resource with the given ``path`` in |void| **set_path_cache**\ (\ path\: :ref:`String`\ ) :ref:`🔗` -Sets the resource's path to ``path`` without involving the resource cache. +Sets the resource's path to ``path`` without involving the resource cache. Useful for handling :ref:`CacheMode` values when implementing a custom resource format by extending :ref:`ResourceFormatLoader` and :ref:`ResourceFormatSaver`. .. rst-class:: classref-item-separator diff --git a/classes/class_tilemaplayer.rst b/classes/class_tilemaplayer.rst index 75ac9ee73..a818f2a4d 100644 --- a/classes/class_tilemaplayer.rst +++ b/classes/class_tilemaplayer.rst @@ -21,7 +21,7 @@ Description Node for 2D tile-based maps. A **TileMapLayer** uses a :ref:`TileSet` which contain a list of tiles which are used to create grid-based maps. Unlike the :ref:`TileMap` node, which is deprecated, **TileMapLayer** has only one layer of tiles. You can use several **TileMapLayer** to achieve the same result as a :ref:`TileMap` node. -For performance reasons, all TileMap updates are batched at the end of a frame. Notably, this means that scene tiles from a :ref:`TileSetScenesCollectionSource` may be initialized after their parent. This is only queued when inside the scene tree. +For performance reasons, all TileMap updates are batched at the end of a frame. Notably, this means that scene tiles from a :ref:`TileSetScenesCollectionSource` are initialized after their parent. This is only queued when inside the scene tree. To force an update earlier on, call :ref:`update_internals()`. diff --git a/classes/class_tilesetscenescollectionsource.rst b/classes/class_tilesetscenescollectionsource.rst index e671c0e0d..73b20c4d3 100644 --- a/classes/class_tilesetscenescollectionsource.rst +++ b/classes/class_tilesetscenescollectionsource.rst @@ -21,7 +21,7 @@ Description When placed on a :ref:`TileMapLayer`, tiles from **TileSetScenesCollectionSource** will automatically instantiate an associated scene at the cell's position in the TileMapLayer. -Scenes are instantiated as children of the :ref:`TileMapLayer` when it enters the tree. If you add/remove a scene tile in the :ref:`TileMapLayer` that is already inside the tree, the :ref:`TileMapLayer` will automatically instantiate/free the scene accordingly. +Scenes are instantiated as children of the :ref:`TileMapLayer` after it enters the tree, at the end of the frame (their creation is deferred). If you add/remove a scene tile in the :ref:`TileMapLayer` that is already inside the tree, the :ref:`TileMapLayer` will automatically instantiate/free the scene accordingly. \ **Note:** Scene tiles all occupy one tile slot and instead use alternate tile ID to identify scene index. :ref:`TileSetSource.get_tiles_count()` will always return ``1``. Use :ref:`get_scene_tiles_count()` to get a number of scenes in a **TileSetScenesCollectionSource**.