classref: Sync with current master branch (bdf625b)

This commit is contained in:
Godot Organization
2025-01-04 03:20:59 +00:00
parent cb6eb02112
commit eab235f772
37 changed files with 496 additions and 345 deletions

View File

@@ -5767,9 +5767,9 @@ Returns a human-readable name for the given :ref:`Error<enum_@GlobalScope_Error>
::
print(OK) # Prints 0
print(error_string(OK)) # Prints OK
print(error_string(ERR_BUSY)) # Prints Busy
print(error_string(ERR_OUT_OF_MEMORY)) # Prints Out of memory
print(error_string(OK)) # Prints "OK"
print(error_string(ERR_BUSY)) # Prints "Busy"
print(error_string(ERR_OUT_OF_MEMORY)) # Prints "Out of memory"
.. rst-class:: classref-item-separator
@@ -5934,24 +5934,24 @@ Returns the :ref:`Object<class_Object>` that corresponds to ``instance_id``. All
.. code-tab:: gdscript
var foo = "bar"
var drink = "water"
func _ready():
var id = get_instance_id()
var inst = instance_from_id(id)
print(inst.foo) # Prints bar
var instance = instance_from_id(id)
print(instance.foo) # Prints "water"
.. code-tab:: csharp
public partial class MyNode : Node
{
public string Foo { get; set; } = "bar";
public string Drink { get; set; } = "water";
public override void _Ready()
{
ulong id = GetInstanceId();
var inst = (MyNode)InstanceFromId(Id);
GD.Print(inst.Foo); // Prints bar
var instance = (MyNode)InstanceFromId(Id);
GD.Print(instance.Drink); // Prints "water"
}
}
@@ -6448,12 +6448,12 @@ Converts one or more arguments of any type to string in the best way possible an
.. code-tab:: gdscript
var a = [1, 2, 3]
print("a", "b", a) # Prints ab[1, 2, 3]
print("a", "b", a) # Prints "ab[1, 2, 3]"
.. code-tab:: csharp
Godot.Collections.Array a = [1, 2, 3];
GD.Print("a", "b", a); // Prints ab[1, 2, 3]
GD.Print("a", "b", a); // Prints "ab[1, 2, 3]"
@@ -6482,11 +6482,11 @@ When printing to standard output, the supported subset of BBCode is converted to
.. code-tab:: gdscript
print_rich("[color=green][b]Hello world![/b][/color]") # Prints out "Hello world!" in green with a bold font
print_rich("[color=green][b]Hello world![/b][/color]") # Prints "Hello world!", in green with a bold font.
.. code-tab:: csharp
GD.PrintRich("[color=green][b]Hello world![/b][/color]"); // Prints out "Hello world!" in green with a bold font
GD.PrintRich("[color=green][b]Hello world![/b][/color]"); // Prints "Hello world!", in green with a bold font.
@@ -6552,17 +6552,17 @@ Prints one or more arguments to strings in the best way possible to the OS termi
.. code-tab:: gdscript
# Prints "ABC" to terminal.
printraw("A")
printraw("B")
printraw("C")
# Prints ABC to terminal
.. code-tab:: csharp
// Prints "ABC" to terminal.
GD.PrintRaw("A");
GD.PrintRaw("B");
GD.PrintRaw("C");
// Prints ABC to terminal
@@ -6583,11 +6583,11 @@ Prints one or more arguments to the console with a space between each argument.
.. code-tab:: gdscript
prints("A", "B", "C") # Prints A B C
prints("A", "B", "C") # Prints "A B C"
.. code-tab:: csharp
GD.PrintS("A", "B", "C"); // Prints A B C
GD.PrintS("A", "B", "C"); // Prints "A B C"
@@ -6608,11 +6608,11 @@ Prints one or more arguments to the console with a tab between each argument.
.. code-tab:: gdscript
printt("A", "B", "C") # Prints A B C
printt("A", "B", "C") # Prints "A B C"
.. code-tab:: csharp
GD.PrintT("A", "B", "C"); // Prints A B C
GD.PrintT("A", "B", "C"); // Prints "A B C"
@@ -6633,11 +6633,11 @@ Pushes an error message to Godot's built-in debugger and to the OS terminal.
.. code-tab:: gdscript
push_error("test error") # Prints "test error" to debugger and terminal as error call
push_error("test error") # Prints "test error" to debugger and terminal as an error.
.. code-tab:: csharp
GD.PushError("test error"); // Prints "test error" to debugger and terminal as error call
GD.PushError("test error"); // Prints "test error" to debugger and terminal as an error.
@@ -6660,11 +6660,11 @@ Pushes a warning message to Godot's built-in debugger and to the OS terminal.
.. code-tab:: gdscript
push_warning("test warning") # Prints "test warning" to debugger and terminal as warning call
push_warning("test warning") # Prints "test warning" to debugger and terminal as a warning.
.. code-tab:: csharp
GD.PushWarning("test warning"); // Prints "test warning" to debugger and terminal as warning call
GD.PushWarning("test warning"); // Prints "test warning" to debugger and terminal as a warning.
@@ -7337,9 +7337,9 @@ Returns a human-readable name of the given ``type``, using the :ref:`Variant.Typ
::
print(TYPE_INT) # Prints 2.
print(type_string(TYPE_INT)) # Prints "int".
print(type_string(TYPE_STRING)) # Prints "String".
print(TYPE_INT) # Prints 2
print(type_string(TYPE_INT)) # Prints "int"
print(type_string(TYPE_STRING)) # Prints "String"
See also :ref:`typeof<class_@GlobalScope_method_typeof>`.
@@ -7360,10 +7360,10 @@ Returns the internal type of the given ``variable``, using the :ref:`Variant.Typ
var json = JSON.new()
json.parse('["a", "b", "c"]')
var result = json.get_data()
if typeof(result) == TYPE_ARRAY:
print(result[0]) # Prints a
if result is Array:
print(result[0]) # Prints "a"
else:
print("Unexpected result")
print("Unexpected result!")
See also :ref:`type_string<class_@GlobalScope_method_type_string>`.