Parcourir la source

tutorials/scripting: Mention % literal syntax

It was unclear to me what that '%' literal syntax does, add
examples in the appropriate places.
mara il y a 2 ans
Parent
commit
2b271ba33e

+ 23 - 21
tutorials/scripting/gdscript/gdscript_basics.rst

@@ -289,27 +289,29 @@ The following is the list of supported operators and their precedence.
 Literals
 ~~~~~~~~
 
-+--------------------------+----------------------------------------+
-| **Literal**              | **Type**                               |
-+--------------------------+----------------------------------------+
-| ``45``                   | Base 10 integer                        |
-+--------------------------+----------------------------------------+
-| ``0x8f51``               | Base 16 (hexadecimal) integer          |
-+--------------------------+----------------------------------------+
-| ``0b101010``             | Base 2 (binary) integer                |
-+--------------------------+----------------------------------------+
-| ``3.14``, ``58.1e-10``   | Floating-point number (real)           |
-+--------------------------+----------------------------------------+
-| ``"Hello"``, ``'Hi'``    | Strings                                |
-+--------------------------+----------------------------------------+
-| ``"""Hello"""``          | Multiline string                       |
-+--------------------------+----------------------------------------+
-| ``&"name"``              | :ref:`StringName <class_StringName>`   |
-+--------------------------+----------------------------------------+
-| ``^"Node/Label"``        | :ref:`NodePath <class_NodePath>`       |
-+--------------------------+----------------------------------------+
-| ``$NodePath``            | Shorthand for ``get_node("NodePath")`` |
-+--------------------------+----------------------------------------+
++--------------------------+-------------------------------------------+
+| **Literal**              | **Type**                                  |
++--------------------------+-------------------------------------------+
+| ``45``                   | Base 10 integer                           |
++--------------------------+-------------------------------------------+
+| ``0x8f51``               | Base 16 (hexadecimal) integer             |
++--------------------------+-------------------------------------------+
+| ``0b101010``             | Base 2 (binary) integer                   |
++--------------------------+-------------------------------------------+
+| ``3.14``, ``58.1e-10``   | Floating-point number (real)              |
++--------------------------+-------------------------------------------+
+| ``"Hello"``, ``'Hi'``    | Strings                                   |
++--------------------------+-------------------------------------------+
+| ``"""Hello"""``          | Multiline string                          |
++--------------------------+-------------------------------------------+
+| ``&"name"``              | :ref:`StringName <class_StringName>`      |
++--------------------------+-------------------------------------------+
+| ``^"Node/Label"``        | :ref:`NodePath <class_NodePath>`          |
++--------------------------+-------------------------------------------+
+| ``$NodePath``            | Shorthand for ``get_node("NodePath")``    |
++--------------------------+-------------------------------------------+
+| ``%UniqueNode``          | Shorthand for ``get_node("%UniqueNode")`` |
++--------------------------+-------------------------------------------+
 
 Integers and floats can have their numbers separated with ``_`` to make them more readable.
 The following ways to write numbers are all valid::

+ 1 - 0
tutorials/scripting/scene_unique_nodes.rst

@@ -36,6 +36,7 @@ name in the path for ``get_node()``. For example:
  .. code-tab:: gdscript GDScript
 
     get_node("%RedButton").text = "Hello"
+    %RedButton.text = "Hello" # Shorter syntax
 
  .. code-tab:: csharp