tutorials/scripting: Mention % literal syntax

It was unclear to me what that '%' literal syntax does, add
examples in the appropriate places.
This commit is contained in:
mara
2023-01-25 20:16:48 +01:00
parent 8c3746e2f2
commit 2b271ba33e
2 changed files with 24 additions and 21 deletions

View File

@@ -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::