You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: classes/[email protected]
+3-1Lines changed: 3 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -538,6 +538,8 @@ See also :ref:`@GlobalScope.PROPERTY_HINT_NODE_PATH_VALID_TYPES<class_@GlobalSco
538
538
539
539
@export_node_path("Button", "TouchScreenButton") var some_button
540
540
541
+
\ **Note:** The type must be a native class or a globally registered script (using the ``class_name`` keyword) that inherits :ref:`Node<class_Node>`.
542
+
541
543
.. rst-class:: classref-item-separator
542
544
543
545
----
@@ -665,7 +667,7 @@ Mark the following method for remote procedure calls. See :doc:`High-level multi
665
667
666
668
If ``mode`` is set as ``"any_peer"``, allows any peer to call this RPC function. Otherwise, only the authority peer is allowed to call it and ``mode`` should be kept as ``"authority"``. When configuring functions as RPCs with :ref:`Node.rpc_config<class_Node_method_rpc_config>`, each of these modes respectively corresponds to the :ref:`MultiplayerAPI.RPC_MODE_AUTHORITY<class_MultiplayerAPI_constant_RPC_MODE_AUTHORITY>` and :ref:`MultiplayerAPI.RPC_MODE_ANY_PEER<class_MultiplayerAPI_constant_RPC_MODE_ANY_PEER>` RPC modes. See :ref:`RPCMode<enum_MultiplayerAPI_RPCMode>`. If a peer that is not the authority tries to call a function that is only allowed for the authority, the function will not be executed. If the error can be detected locally (when the RPC configuration is consistent between the local and the remote peer), an error message will be displayed on the sender peer. Otherwise, the remote peer will detect the error and print an error there.
667
669
668
-
If ``sync`` is set as ``"call_remote"``, the function will only be executed on the remote peer, but not locally. To run this function locally too, set ``sync`` to ``"call_local"``. When configuring functions as RPCs with :ref:`Node.rpc_config<class_Node_method_rpc_config>`, this is equivalent to setting `call_local` to `true`.
670
+
If ``sync`` is set as ``"call_remote"``, the function will only be executed on the remote peer, but not locally. To run this function locally too, set ``sync`` to ``"call_local"``. When configuring functions as RPCs with :ref:`Node.rpc_config<class_Node_method_rpc_config>`, this is equivalent to setting ``call_local`` to ``true``.
669
671
670
672
The ``transfer_mode`` accepted values are ``"unreliable"``, ``"unreliable_ordered"``, or ``"reliable"``. It sets the transfer mode of the underlying :ref:`MultiplayerPeer<class_MultiplayerPeer>`. See :ref:`MultiplayerPeer.transfer_mode<class_MultiplayerPeer_property_transfer_mode>`.
Copy file name to clipboardExpand all lines: classes/class_area3d.rst
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -23,7 +23,7 @@ Description
23
23
24
24
This node can also locally alter or override physics parameters (gravity, damping) and route audio to custom audio buses.
25
25
26
-
\ **Warning:** Using a :ref:`ConcavePolygonShape3D<class_ConcavePolygonShape3D>` inside a :ref:`CollisionShape3D<class_CollisionShape3D>` child of this node (created e.g. by using the *Create Trimesh Collision Sibling* option in the *Mesh* menu that appears when selecting a :ref:`MeshInstance3D<class_MeshInstance3D>` node) may give unexpected results, since this collision shape is hollow. If this is not desired, it has to be split into multiple :ref:`ConvexPolygonShape3D<class_ConvexPolygonShape3D>`\ s or primitive shapes like :ref:`BoxShape3D<class_BoxShape3D>`, or in some cases it may be replaceable by a :ref:`CollisionPolygon3D<class_CollisionPolygon3D>`.
26
+
\ **Warning:** Using a :ref:`ConcavePolygonShape3D<class_ConcavePolygonShape3D>` inside a :ref:`CollisionShape3D<class_CollisionShape3D>` child of this node (created e.g. by using the **Create Trimesh Collision Sibling** option in the **Mesh** menu that appears when selecting a :ref:`MeshInstance3D<class_MeshInstance3D>` node) may give unexpected results, since this collision shape is hollow. If this is not desired, it has to be split into multiple :ref:`ConvexPolygonShape3D<class_ConvexPolygonShape3D>`\ s or primitive shapes like :ref:`BoxShape3D<class_BoxShape3D>`, or in some cases it may be replaceable by a :ref:`CollisionPolygon3D<class_CollisionPolygon3D>`.
Emitted when the button was just toggled between pressed and normal states (only if :ref:`toggle_mode<class_BaseButton_property_toggle_mode>` is active). The new state is contained in the ``button_pressed`` argument.
131
+
Emitted when the button was just toggled between pressed and normal states (only if :ref:`toggle_mode<class_BaseButton_property_toggle_mode>` is active). The new state is contained in the ``toggled_on`` argument.
132
132
133
133
.. rst-class:: classref-section-separator
134
134
@@ -419,7 +419,7 @@ Called when the button is pressed. If you need to know the button's pressed stat
Sets the bone angle for the **Bone2D**. This is typically set to the rotation from the **Bone2D** to a child **Bone2D** node.
194
194
195
-
\ **Note:** **Note:** This is different from the **Bone2D**'s rotation. The bone's angle is the rotation of the bone shown by the gizmo, which is unaffected by the **Bone2D**'s :ref:`Node2D.transform<class_Node2D_property_transform>`.
195
+
\ **Note:** This is different from the **Bone2D**'s rotation. The bone's angle is the rotation of the bone shown by the gizmo, which is unaffected by the **Bone2D**'s :ref:`Node2D.transform<class_Node2D_property_transform>`.
Copy file name to clipboardExpand all lines: classes/class_bool.rst
+22-16Lines changed: 22 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,56 +17,62 @@ A built-in boolean type.
17
17
Description
18
18
-----------
19
19
20
-
A **bool** is always one of two values: ``true`` or ``false``, similar to a switch that is either on or off. Booleans are used in programming for logic in condition statements.
20
+
The **bool** is a built-in :ref:`Variant<class_Variant>` type that may only store one of two values: ``true`` or ``false``. You can imagine it as a switch that can be either turned on or off, or as a binary digit that can either be 1 or 0.
21
21
22
-
Booleans can be directly used in ``if`` and ``elif`` statements. You don't need to add ``== true`` or ``== false``:
22
+
Booleans can be directly used in ``if``, and other conditional statements:
23
23
24
24
25
25
.. tabs::
26
26
27
27
.. code-tab:: gdscript
28
28
29
+
var can_shoot = true
29
30
if can_shoot:
30
31
launch_bullet()
31
32
32
33
.. code-tab:: csharp
33
34
35
+
bool canShoot = true;
34
36
if (canShoot)
35
37
{
36
-
launchBullet();
38
+
LaunchBullet();
37
39
}
38
40
39
41
40
42
41
-
Many common methods and operations return **bool**\ s, for example, ``shooting_cooldown <= 0.0`` may evaluate to ``true`` or ``false`` depending on the number's value.
43
+
All comparison operators return booleans (``==``, ``>``, ``<=``, etc.). As such, it is not necessary to compare booleans themselves. You do not need to add ``== true`` or ``== false``.
42
44
43
-
\ **bool**\ s are usually used with the logical operators ``and``, ``or``, and ``not`` to create complex conditions:
45
+
Booleans can be combined with the logical operators ``and``, ``or``, ``not`` to create complex conditions:
44
46
45
47
46
48
.. tabs::
47
49
48
50
.. code-tab:: gdscript
49
51
50
-
if bullets > 0 and not is_reloading:
52
+
if bullets > 0 and not is_reloading():
51
53
launch_bullet()
52
54
53
-
if bullets == 0 or is_reloading:
55
+
if bullets == 0 or is_reloading():
54
56
play_clack_sound()
55
57
56
58
.. code-tab:: csharp
57
59
58
-
if (bullets > 0 && !isReloading)
60
+
if (bullets > 0 && !IsReloading())
59
61
{
60
-
launchBullet();
62
+
LaunchBullet();
61
63
}
62
64
63
-
if (bullets == 0 || isReloading)
65
+
if (bullets == 0 || IsReloading())
64
66
{
65
-
playClackSound();
67
+
PlayClackSound();
66
68
}
67
69
68
70
69
71
72
+
\ **Note:** In modern programming languages, logical operators are evaluated in order. All remaining conditions are skipped if their result would have no effect on the final value. This concept is known as `short-circuit evaluation <https://en.wikipedia.org/wiki/Short-circuit_evaluation>`__ and can be useful to avoid evaluating expensive conditions in some performance-critical cases.
73
+
74
+
\ **Note:** By convention, built-in methods and properties that return booleans are usually defined as yes-no questions, single adjectives, or similar (:ref:`String.is_empty<class_String_method_is_empty>`, :ref:`Node.can_process<class_Node_method_can_process>`, :ref:`Camera2D.enabled<class_Camera2D_property_enabled>`, etc.).
75
+
70
76
.. rst-class:: classref-reftable-group
71
77
72
78
Constructors
@@ -118,7 +124,7 @@ Constructor Descriptions
118
124
119
125
:ref:`bool<class_bool>` **bool** **(** **)**
120
126
121
-
Constructs a default-initialized **bool** set to ``false``.
127
+
Constructs a **bool** set to ``false``.
122
128
123
129
.. rst-class:: classref-item-separator
124
130
@@ -138,7 +144,7 @@ Constructs a **bool** as a copy of the given **bool**.
138
144
139
145
:ref:`bool<class_bool>` **bool** **(** :ref:`float<class_float>` from **)**
140
146
141
-
Cast a :ref:`float<class_float>` value to a boolean value. This method will return ``false`` if ``0.0`` is passed in, and ``true`` for all other values.
147
+
Cast a :ref:`float<class_float>` value to a boolean value. Returns ``false`` if ``from`` is equal to ``0.0`` (including ``-0.0``), and ``true`` for all other values (including :ref:`@GDScript.INF<class_@GDScript_constant_INF>` and :ref:`@GDScript.NAN<class_@GDScript_constant_NAN>`).
142
148
143
149
.. rst-class:: classref-item-separator
144
150
@@ -148,7 +154,7 @@ Cast a :ref:`float<class_float>` value to a boolean value. This method will retu
148
154
149
155
:ref:`bool<class_bool>` **bool** **(** :ref:`int<class_int>` from **)**
150
156
151
-
Cast an :ref:`int<class_int>` value to a boolean value. This method will return ``false`` if ``0`` is passed in, and ``true`` for all other values.
157
+
Cast an :ref:`int<class_int>` value to a boolean value. Returns ``false`` if ``from`` is equal to ``0``, and ``true`` for all other values.
152
158
153
159
.. rst-class:: classref-section-separator
154
160
@@ -165,7 +171,7 @@ Operator Descriptions
165
171
166
172
:ref:`bool<class_bool>` **operator !=** **(** :ref:`bool<class_bool>` right **)**
167
173
168
-
Returns ``true`` if two bools are different, i.e. one is ``true`` and the other is ``false``.
174
+
Returns ``true`` if the two booleans are not equal. That is, one is ``true`` and the other is ``false``. This operation can be seen as a logical XOR.
169
175
170
176
.. rst-class:: classref-item-separator
171
177
@@ -189,7 +195,7 @@ Returns ``true`` if the left operand is ``false`` and the right operand is ``tru
189
195
190
196
:ref:`bool<class_bool>` **operator ==** **(** :ref:`bool<class_bool>` right **)**
191
197
192
-
Returns ``true`` if two bools are equal, i.e. both are ``true`` or both are ``false``.
198
+
Returns ``true`` if the two booleans are equal. That is, both are ``true`` or both are ``false``. This operation can be seen as a logical EQ or XNOR.
0 commit comments