Skip to content

Commit 16e513e

Browse files
authored
Merge pull request godotengine#6167 from Calinou/update-common-engine-methods
Update `print_line()` and add `print_rich()` in Common engine methods and macros
2 parents 59636f7 + 28cfb8a commit 16e513e

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

development/cpp/common_engine_methods_and_macros.rst

+17-5
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,21 @@ Print text
1515
// Prints a message to standard output.
1616
print_line("Message");
1717
18+
// Non-String arguments are automatically converted to String for printing.
19+
// If passing several arguments, they will be concatenated together with a
20+
// space between each argument.
21+
print_line("There are", 123, "nodes");
22+
1823
// Prints a message to standard output, but only when the engine
1924
// is started with the `--verbose` command line argument.
2025
print_verbose("Message");
2126
27+
// Prints a rich-formatted message using BBCode to standard output.
28+
// This supports a subset of BBCode tags supported by RichTextLabel
29+
// and will also appear formatted in the editor Output panel.
30+
// On Windows, this requires Windows 10 or later to work in the terminal.
31+
print_line_rich("[b]Bold[/b], [color=red]Red text[/color]")
32+
2233
// Prints a formatted error or warning message with a trace.
2334
ERR_PRINT("Message");
2435
WARN_PRINT("Message");
@@ -54,15 +65,16 @@ makes for more readable code.
5465
Convert an integer or float to a string
5566
---------------------------------------
5667

57-
This is mainly useful when printing numbers directly.
68+
This is not needed when printing numbers using ``print_line()``, but you may
69+
still need to perform manual conversion for some other use cases.
5870

5971
.. code-block:: cpp
6072
61-
// Prints "42" using integer-to-string conversion.
62-
print_line(itos(42));
73+
// Stores the string "42" using integer-to-string conversion.
74+
String int_to_string = itos(42);
6375
64-
// Prints "123.45" using real-to-string conversion.
65-
print_line(rtos(123.45));
76+
// Stores the string "123.45" using real-to-string conversion.
77+
String real_to_string = rtos(123.45);
6678
6779
Internationalize a string
6880
-------------------------

0 commit comments

Comments
 (0)