Skip to content

Commit eab235f

Browse files
author
Godot Organization
committed
classref: Sync with current master branch (bdf625b)
1 parent cb6eb02 commit eab235f

37 files changed

+485
-334
lines changed

classes/[email protected]

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -950,6 +950,8 @@ Method Descriptions
950950

951951
:ref:`Color<class_Color>` **Color8**\ (\ r8\: :ref:`int<class_int>`, g8\: :ref:`int<class_int>`, b8\: :ref:`int<class_int>`, a8\: :ref:`int<class_int>` = 255\ ) :ref:`🔗<class_@GDScript_method_Color8>`
952952

953+
**Deprecated:** Use :ref:`Color.from_rgba8<class_Color_method_from_rgba8>` instead.
954+
953955
Returns a :ref:`Color<class_Color>` constructed from red (``r8``), green (``g8``), blue (``b8``), and optionally alpha (``a8``) integer channels, each divided by ``255.0`` for their final value. Using :ref:`Color8<class_@GDScript_method_Color8>` instead of the standard :ref:`Color<class_Color>` constructor is useful when you need to match exact color values in an :ref:`Image<class_Image>`.
954956

955957
::

classes/[email protected]

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -5767,9 +5767,9 @@ Returns a human-readable name for the given :ref:`Error<enum_@GlobalScope_Error>
57675767
::
57685768

57695769
print(OK) # Prints 0
5770-
print(error_string(OK)) # Prints OK
5771-
print(error_string(ERR_BUSY)) # Prints Busy
5772-
print(error_string(ERR_OUT_OF_MEMORY)) # Prints Out of memory
5770+
print(error_string(OK)) # Prints "OK"
5771+
print(error_string(ERR_BUSY)) # Prints "Busy"
5772+
print(error_string(ERR_OUT_OF_MEMORY)) # Prints "Out of memory"
57735773

57745774
.. rst-class:: classref-item-separator
57755775

@@ -5934,24 +5934,24 @@ Returns the :ref:`Object<class_Object>` that corresponds to ``instance_id``. All
59345934

59355935
.. code-tab:: gdscript
59365936

5937-
var foo = "bar"
5937+
var drink = "water"
59385938

59395939
func _ready():
59405940
var id = get_instance_id()
5941-
var inst = instance_from_id(id)
5942-
print(inst.foo) # Prints bar
5941+
var instance = instance_from_id(id)
5942+
print(instance.foo) # Prints "water"
59435943

59445944
.. code-tab:: csharp
59455945

59465946
public partial class MyNode : Node
59475947
{
5948-
public string Foo { get; set; } = "bar";
5948+
public string Drink { get; set; } = "water";
59495949

59505950
public override void _Ready()
59515951
{
59525952
ulong id = GetInstanceId();
5953-
var inst = (MyNode)InstanceFromId(Id);
5954-
GD.Print(inst.Foo); // Prints bar
5953+
var instance = (MyNode)InstanceFromId(Id);
5954+
GD.Print(instance.Drink); // Prints "water"
59555955
}
59565956
}
59575957

@@ -6448,12 +6448,12 @@ Converts one or more arguments of any type to string in the best way possible an
64486448
.. code-tab:: gdscript
64496449

64506450
var a = [1, 2, 3]
6451-
print("a", "b", a) # Prints ab[1, 2, 3]
6451+
print("a", "b", a) # Prints "ab[1, 2, 3]"
64526452

64536453
.. code-tab:: csharp
64546454

64556455
Godot.Collections.Array a = [1, 2, 3];
6456-
GD.Print("a", "b", a); // Prints ab[1, 2, 3]
6456+
GD.Print("a", "b", a); // Prints "ab[1, 2, 3]"
64576457

64586458

64596459

@@ -6482,11 +6482,11 @@ When printing to standard output, the supported subset of BBCode is converted to
64826482

64836483
.. code-tab:: gdscript
64846484

6485-
print_rich("[color=green][b]Hello world![/b][/color]") # Prints out "Hello world!" in green with a bold font
6485+
print_rich("[color=green][b]Hello world![/b][/color]") # Prints "Hello world!", in green with a bold font.
64866486

64876487
.. code-tab:: csharp
64886488

6489-
GD.PrintRich("[color=green][b]Hello world![/b][/color]"); // Prints out "Hello world!" in green with a bold font
6489+
GD.PrintRich("[color=green][b]Hello world![/b][/color]"); // Prints "Hello world!", in green with a bold font.
64906490

64916491

64926492

@@ -6552,17 +6552,17 @@ Prints one or more arguments to strings in the best way possible to the OS termi
65526552

65536553
.. code-tab:: gdscript
65546554

6555+
# Prints "ABC" to terminal.
65556556
printraw("A")
65566557
printraw("B")
65576558
printraw("C")
6558-
# Prints ABC to terminal
65596559

65606560
.. code-tab:: csharp
65616561

6562+
// Prints "ABC" to terminal.
65626563
GD.PrintRaw("A");
65636564
GD.PrintRaw("B");
65646565
GD.PrintRaw("C");
6565-
// Prints ABC to terminal
65666566

65676567

65686568

@@ -6583,11 +6583,11 @@ Prints one or more arguments to the console with a space between each argument.
65836583

65846584
.. code-tab:: gdscript
65856585

6586-
prints("A", "B", "C") # Prints A B C
6586+
prints("A", "B", "C") # Prints "A B C"
65876587

65886588
.. code-tab:: csharp
65896589

6590-
GD.PrintS("A", "B", "C"); // Prints A B C
6590+
GD.PrintS("A", "B", "C"); // Prints "A B C"
65916591

65926592

65936593

@@ -6608,11 +6608,11 @@ Prints one or more arguments to the console with a tab between each argument.
66086608

66096609
.. code-tab:: gdscript
66106610

6611-
printt("A", "B", "C") # Prints A B C
6611+
printt("A", "B", "C") # Prints "A B C"
66126612

66136613
.. code-tab:: csharp
66146614

6615-
GD.PrintT("A", "B", "C"); // Prints A B C
6615+
GD.PrintT("A", "B", "C"); // Prints "A B C"
66166616

66176617

66186618

@@ -6633,11 +6633,11 @@ Pushes an error message to Godot's built-in debugger and to the OS terminal.
66336633

66346634
.. code-tab:: gdscript
66356635

6636-
push_error("test error") # Prints "test error" to debugger and terminal as error call
6636+
push_error("test error") # Prints "test error" to debugger and terminal as an error.
66376637

66386638
.. code-tab:: csharp
66396639

6640-
GD.PushError("test error"); // Prints "test error" to debugger and terminal as error call
6640+
GD.PushError("test error"); // Prints "test error" to debugger and terminal as an error.
66416641

66426642

66436643

@@ -6660,11 +6660,11 @@ Pushes a warning message to Godot's built-in debugger and to the OS terminal.
66606660

66616661
.. code-tab:: gdscript
66626662

6663-
push_warning("test warning") # Prints "test warning" to debugger and terminal as warning call
6663+
push_warning("test warning") # Prints "test warning" to debugger and terminal as a warning.
66646664

66656665
.. code-tab:: csharp
66666666

6667-
GD.PushWarning("test warning"); // Prints "test warning" to debugger and terminal as warning call
6667+
GD.PushWarning("test warning"); // Prints "test warning" to debugger and terminal as a warning.
66686668

66696669

66706670

@@ -7337,9 +7337,9 @@ Returns a human-readable name of the given ``type``, using the :ref:`Variant.Typ
73377337

73387338
::
73397339

7340-
print(TYPE_INT) # Prints 2.
7341-
print(type_string(TYPE_INT)) # Prints "int".
7342-
print(type_string(TYPE_STRING)) # Prints "String".
7340+
print(TYPE_INT) # Prints 2
7341+
print(type_string(TYPE_INT)) # Prints "int"
7342+
print(type_string(TYPE_STRING)) # Prints "String"
73437343

73447344
See also :ref:`typeof<class_@GlobalScope_method_typeof>`.
73457345

@@ -7360,10 +7360,10 @@ Returns the internal type of the given ``variable``, using the :ref:`Variant.Typ
73607360
var json = JSON.new()
73617361
json.parse('["a", "b", "c"]')
73627362
var result = json.get_data()
7363-
if typeof(result) == TYPE_ARRAY:
7364-
print(result[0]) # Prints a
7363+
if result is Array:
7364+
print(result[0]) # Prints "a"
73657365
else:
7366-
print("Unexpected result")
7366+
print("Unexpected result!")
73677367

73687368
See also :ref:`type_string<class_@GlobalScope_method_type_string>`.
73697369

classes/class_array.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -784,7 +784,7 @@ Returns the index of the **first** element in the array that causes ``method`` t
784784
return number % 2 == 0
785785

786786
func _ready():
787-
print([1, 3, 4, 7].find_custom(is_even.bind())) # prints 2
787+
print([1, 3, 4, 7].find_custom(is_even.bind())) # Prints 2
788788

789789

790790

@@ -1172,10 +1172,10 @@ If :ref:`max<class_Array_method_max>` is not desirable, this method may also be
11721172
::
11731173

11741174
func _ready():
1175-
var arr = [Vector2(5, 0), Vector2(3, 4), Vector2(1, 2)]
1175+
var arr = [Vector2i(5, 0), Vector2i(3, 4), Vector2i(1, 2)]
11761176
11771177
var longest_vec = arr.reduce(func(max, vec): return vec if is_length_greater(vec, max) else max)
1178-
print(longest_vec) # Prints Vector2(3, 4).
1178+
print(longest_vec) # Prints (3, 4)
11791179
11801180
func is_length_greater(a, b):
11811181
return a.length() > b.length()
@@ -1189,11 +1189,11 @@ This method can also be used to count how many elements in an array satisfy a ce
11891189
11901190
func _ready():
11911191
var arr = [1, 2, 3, 4, 5]
1192-
# Increment count if it's even, else leaves count the same.
1192+
# If the current element is even, increment count, otherwise leave count the same.
11931193
var even_count = arr.reduce(func(count, next): return count + 1 if is_even(next) else count, 0)
11941194
print(even_count) # Prints 2
11951195

1196-
See also :ref:`map<class_Array_method_map>`, :ref:`filter<class_Array_method_filter>`, :ref:`any<class_Array_method_any>` and :ref:`all<class_Array_method_all>`.
1196+
See also :ref:`map<class_Array_method_map>`, :ref:`filter<class_Array_method_filter>`, :ref:`any<class_Array_method_any>`, and :ref:`all<class_Array_method_all>`.
11971197

11981198
.. rst-class:: classref-item-separator
11991199

classes/class_arraymesh.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ The ``blend_shapes`` argument is an array of vertex data for each blend shape. E
240240

241241
The ``lods`` argument is a dictionary with :ref:`float<class_float>` keys and :ref:`PackedInt32Array<class_PackedInt32Array>` values. Each entry in the dictionary represents an LOD level of the surface, where the value is the :ref:`Mesh.ARRAY_INDEX<class_Mesh_constant_ARRAY_INDEX>` array to use for the LOD level and the key is roughly proportional to the distance at which the LOD stats being used. I.e., increasing the key of an LOD also increases the distance that the objects has to be from the camera before the LOD is used.
242242

243-
The ``flags`` argument is the bitwise or of, as required: One value of :ref:`ArrayCustomFormat<enum_Mesh_ArrayCustomFormat>` left shifted by ``ARRAY_FORMAT_CUSTOMn_SHIFT`` for each custom channel in use, :ref:`Mesh.ARRAY_FLAG_USE_DYNAMIC_UPDATE<class_Mesh_constant_ARRAY_FLAG_USE_DYNAMIC_UPDATE>`, :ref:`Mesh.ARRAY_FLAG_USE_8_BONE_WEIGHTS<class_Mesh_constant_ARRAY_FLAG_USE_8_BONE_WEIGHTS>`, or :ref:`Mesh.ARRAY_FLAG_USES_EMPTY_VERTEX_ARRAY<class_Mesh_constant_ARRAY_FLAG_USES_EMPTY_VERTEX_ARRAY>`.
243+
The ``flags`` argument is the bitwise OR of, as required: One value of :ref:`ArrayCustomFormat<enum_Mesh_ArrayCustomFormat>` left shifted by ``ARRAY_FORMAT_CUSTOMn_SHIFT`` for each custom channel in use, :ref:`Mesh.ARRAY_FLAG_USE_DYNAMIC_UPDATE<class_Mesh_constant_ARRAY_FLAG_USE_DYNAMIC_UPDATE>`, :ref:`Mesh.ARRAY_FLAG_USE_8_BONE_WEIGHTS<class_Mesh_constant_ARRAY_FLAG_USE_8_BONE_WEIGHTS>`, or :ref:`Mesh.ARRAY_FLAG_USES_EMPTY_VERTEX_ARRAY<class_Mesh_constant_ARRAY_FLAG_USES_EMPTY_VERTEX_ARRAY>`.
244244

245245
\ **Note:** When using indices, it is recommended to only use points, lines, or triangles.
246246

classes/class_astargrid2d.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ To use **AStarGrid2D**, you only need to set the :ref:`region<class_AStarGrid2D_
4141
astarGrid.Region = new Rect2I(0, 0, 32, 32);
4242
astarGrid.CellSize = new Vector2I(16, 16);
4343
astarGrid.Update();
44-
GD.Print(astarGrid.GetIdPath(Vector2I.Zero, new Vector2I(3, 4))); // prints (0, 0), (1, 1), (2, 2), (3, 3), (3, 4)
45-
GD.Print(astarGrid.GetPointPath(Vector2I.Zero, new Vector2I(3, 4))); // prints (0, 0), (16, 16), (32, 32), (48, 48), (48, 64)
44+
GD.Print(astarGrid.GetIdPath(Vector2I.Zero, new Vector2I(3, 4))); // Prints [(0, 0), (1, 1), (2, 2), (3, 3), (3, 4)]
45+
GD.Print(astarGrid.GetPointPath(Vector2I.Zero, new Vector2I(3, 4))); // Prints [(0, 0), (16, 16), (32, 32), (48, 48), (48, 64)]
4646

4747

4848

classes/class_basis.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -598,7 +598,9 @@ Creates a new **Basis** with a rotation such that the forward axis (-Z) points t
598598

599599
By default, the -Z axis (camera forward) is treated as forward (implies +X is right). If ``use_model_front`` is ``true``, the +Z axis (asset front) is treated as forward (implies +X is left) and points toward the ``target`` position.
600600

601-
The up axis (+Y) points as close to the ``up`` vector as possible while staying perpendicular to the forward axis. The returned basis is orthonormalized (see :ref:`orthonormalized<class_Basis_method_orthonormalized>`). The ``target`` and ``up`` vectors cannot be :ref:`Vector3.ZERO<class_Vector3_constant_ZERO>`, and cannot be parallel to each other.
601+
The up axis (+Y) points as close to the ``up`` vector as possible while staying perpendicular to the forward axis. The returned basis is orthonormalized (see :ref:`orthonormalized<class_Basis_method_orthonormalized>`).
602+
603+
The ``target`` and the ``up`` cannot be :ref:`Vector3.ZERO<class_Vector3_constant_ZERO>`, and shouldn't be colinear to avoid unintended rotation around local Z axis.
602604

603605
.. rst-class:: classref-item-separator
604606

classes/class_callable.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ Description
3030
func test():
3131
var callable = Callable(self, "print_args")
3232
callable.call("hello", "world") # Prints "hello world ".
33-
callable.call(Vector2.UP, 42, callable) # Prints "(0.0, -1.0) 42 Node(node.gd)::print_args".
33+
callable.call(Vector2.UP, 42, callable) # Prints "(0.0, -1.0) 42 Node(node.gd)::print_args"
3434
callable.call("invalid") # Invalid call, should have at least 2 arguments.
3535

3636
.. code-tab:: csharp
@@ -46,7 +46,7 @@ Description
4646
// Invalid calls fail silently.
4747
Callable callable = new Callable(this, MethodName.PrintArgs);
4848
callable.Call("hello", "world"); // Default parameter values are not supported, should have 3 arguments.
49-
callable.Call(Vector2.Up, 42, callable); // Prints "(0, -1) 42 Node(Node.cs)::PrintArgs".
49+
callable.Call(Vector2.Up, 42, callable); // Prints "(0, -1) 42 Node(Node.cs)::PrintArgs"
5050
callable.Call("invalid"); // Invalid call, should have 3 arguments.
5151
}
5252

@@ -60,7 +60,7 @@ In GDScript, it's possible to create lambda functions within a method. Lambda fu
6060
var my_lambda = func (message):
6161
print(message)
6262
63-
# Prints Hello everyone!
63+
# Prints "Hello everyone!"
6464
my_lambda.call("Hello everyone!")
6565
6666
# Prints "Attack!", when the button_pressed signal is emitted.

classes/class_color.rst

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,8 @@ Methods
121121
+-----------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
122122
| :ref:`Color<class_Color>` | :ref:`from_ok_hsl<class_Color_method_from_ok_hsl>`\ (\ h\: :ref:`float<class_float>`, s\: :ref:`float<class_float>`, l\: :ref:`float<class_float>`, alpha\: :ref:`float<class_float>` = 1.0\ ) |static| |
123123
+-----------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
124+
| :ref:`Color<class_Color>` | :ref:`from_rgba8<class_Color_method_from_rgba8>`\ (\ r8\: :ref:`int<class_int>`, g8\: :ref:`int<class_int>`, b8\: :ref:`int<class_int>`, a8\: :ref:`int<class_int>` = 255\ ) |static| |
125+
+-----------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
124126
| :ref:`Color<class_Color>` | :ref:`from_rgbe9995<class_Color_method_from_rgbe9995>`\ (\ rgbe\: :ref:`int<class_int>`\ ) |static| |
125127
+-----------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
126128
| :ref:`Color<class_Color>` | :ref:`from_string<class_Color_method_from_string>`\ (\ str\: :ref:`String<class_String>`, default\: :ref:`Color<class_Color>`\ ) |static| |
@@ -1789,6 +1791,26 @@ Constructs a color from an `OK HSL profile <https://bottosson.github.io/posts/co
17891791

17901792

17911793

1794+
.. rst-class:: classref-item-separator
1795+
1796+
----
1797+
1798+
.. _class_Color_method_from_rgba8:
1799+
1800+
.. rst-class:: classref-method
1801+
1802+
:ref:`Color<class_Color>` **from_rgba8**\ (\ r8\: :ref:`int<class_int>`, g8\: :ref:`int<class_int>`, b8\: :ref:`int<class_int>`, a8\: :ref:`int<class_int>` = 255\ ) |static| :ref:`🔗<class_Color_method_from_rgba8>`
1803+
1804+
Returns a **Color** constructed from red (``r8``), green (``g8``), blue (``b8``), and optionally alpha (``a8``) integer channels, each divided by ``255.0`` for their final value.
1805+
1806+
::
1807+
1808+
var red = Color.from_rgba8(255, 0, 0) # Same as Color(1, 0, 0).
1809+
var dark_blue = Color.from_rgba8(0, 0, 51) # Same as Color(0, 0, 0.2).
1810+
var my_color = Color.from_rgba8(306, 255, 0, 102) # Same as Color(1.2, 1, 0, 0.4).
1811+
1812+
\ **Note:** Due to the lower precision of :ref:`from_rgba8<class_Color_method_from_rgba8>` compared to the standard **Color** constructor, a color created with :ref:`from_rgba8<class_Color_method_from_rgba8>` will generally not be equal to the same color created with the standard **Color** constructor. Use :ref:`is_equal_approx<class_Color_method_is_equal_approx>` for comparisons to avoid issues with floating-point precision error.
1813+
17921814
.. rst-class:: classref-item-separator
17931815

17941816
----

classes/class_editorcontextmenuplugin.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ Add a submenu to the context menu of the plugin's specified slot. The submenu is
166166
popup_menu.add_item("White")
167167
popup_menu.id_pressed.connect(_on_color_submenu_option)
168168
169-
add_context_menu_item("Set Node Color", popup_menu)
169+
add_context_submenu_item("Set Node Color", popup_menu)
170170

171171
.. rst-class:: classref-item-separator
172172

0 commit comments

Comments
 (0)