|
388 | 388 | Returns a human-readable name for the given [enum Error] code.
|
389 | 389 | [codeblock]
|
390 | 390 | print(OK) # Prints 0
|
391 |
| - print(error_string(OK)) # Prints OK |
392 |
| - print(error_string(ERR_BUSY)) # Prints Busy |
393 |
| - print(error_string(ERR_OUT_OF_MEMORY)) # Prints Out of memory |
| 391 | + print(error_string(OK)) # Prints "OK" |
| 392 | + print(error_string(ERR_BUSY)) # Prints "Busy" |
| 393 | + print(error_string(ERR_OUT_OF_MEMORY)) # Prints "Out of memory" |
394 | 394 | [/codeblock]
|
395 | 395 | </description>
|
396 | 396 | </method>
|
|
495 | 495 | Returns the [Object] that corresponds to [param instance_id]. All Objects have a unique instance ID. See also [method Object.get_instance_id].
|
496 | 496 | [codeblocks]
|
497 | 497 | [gdscript]
|
498 |
| - var foo = "bar" |
| 498 | + var drink = "water" |
499 | 499 |
|
500 | 500 | func _ready():
|
501 | 501 | var id = get_instance_id()
|
502 |
| - var inst = instance_from_id(id) |
503 |
| - print(inst.foo) # Prints bar |
| 502 | + var instance = instance_from_id(id) |
| 503 | + print(instance.foo) # Prints "water" |
504 | 504 | [/gdscript]
|
505 | 505 | [csharp]
|
506 | 506 | public partial class MyNode : Node
|
507 | 507 | {
|
508 |
| - public string Foo { get; set; } = "bar"; |
| 508 | + public string Drink { get; set; } = "water"; |
509 | 509 |
|
510 | 510 | public override void _Ready()
|
511 | 511 | {
|
512 | 512 | ulong id = GetInstanceId();
|
513 |
| - var inst = (MyNode)InstanceFromId(Id); |
514 |
| - GD.Print(inst.Foo); // Prints bar |
| 513 | + var instance = (MyNode)InstanceFromId(Id); |
| 514 | + GD.Print(instance.Drink); // Prints "water" |
515 | 515 | }
|
516 | 516 | }
|
517 | 517 | [/csharp]
|
|
850 | 850 | [codeblocks]
|
851 | 851 | [gdscript]
|
852 | 852 | var a = [1, 2, 3]
|
853 |
| - print("a", "b", a) # Prints ab[1, 2, 3] |
| 853 | + print("a", "b", a) # Prints "ab[1, 2, 3]" |
854 | 854 | [/gdscript]
|
855 | 855 | [csharp]
|
856 | 856 | Godot.Collections.Array a = [1, 2, 3];
|
857 |
| - GD.Print("a", "b", a); // Prints ab[1, 2, 3] |
| 857 | + GD.Print("a", "b", a); // Prints "ab[1, 2, 3]" |
858 | 858 | [/csharp]
|
859 | 859 | [/codeblocks]
|
860 | 860 | [b]Note:[/b] Consider using [method push_error] and [method push_warning] to print error and warning messages instead of [method print] or [method print_rich]. This distinguishes them from print messages used for debugging purposes, while also displaying a stack trace when an error or warning is printed. See also [member Engine.print_to_stdout] and [member ProjectSettings.application/run/disable_stdout].
|
|
869 | 869 | When printing to standard output, the supported subset of BBCode is converted to ANSI escape codes for the terminal emulator to display. Support for ANSI escape codes varies across terminal emulators, especially for italic and strikethrough. In standard output, [code]code[/code] is represented with faint text but without any font change. Unsupported tags are left as-is in standard output.
|
870 | 870 | [codeblocks]
|
871 | 871 | [gdscript skip-lint]
|
872 |
| - print_rich("[color=green][b]Hello world![/b][/color]") # Prints out "Hello world!" in green with a bold font |
| 872 | + print_rich("[color=green][b]Hello world![/b][/color]") # Prints "Hello world!", in green with a bold font. |
873 | 873 | [/gdscript]
|
874 | 874 | [csharp skip-lint]
|
875 |
| - GD.PrintRich("[color=green][b]Hello world![/b][/color]"); // Prints out "Hello world!" in green with a bold font |
| 875 | + GD.PrintRich("[color=green][b]Hello world![/b][/color]"); // Prints "Hello world!", in green with a bold font. |
876 | 876 | [/csharp]
|
877 | 877 | [/codeblocks]
|
878 | 878 | [b]Note:[/b] Consider using [method push_error] and [method push_warning] to print error and warning messages instead of [method print] or [method print_rich]. This distinguishes them from print messages used for debugging purposes, while also displaying a stack trace when an error or warning is printed.
|
|
907 | 907 | [b]Note:[/b] The OS terminal is [i]not[/i] the same as the editor's Output dock. The output sent to the OS terminal can be seen when running Godot from a terminal. On Windows, this requires using the [code]console.exe[/code] executable.
|
908 | 908 | [codeblocks]
|
909 | 909 | [gdscript]
|
| 910 | + # Prints "ABC" to terminal. |
910 | 911 | printraw("A")
|
911 | 912 | printraw("B")
|
912 | 913 | printraw("C")
|
913 |
| - # Prints ABC to terminal |
914 | 914 | [/gdscript]
|
915 | 915 | [csharp]
|
| 916 | + // Prints "ABC" to terminal. |
916 | 917 | GD.PrintRaw("A");
|
917 | 918 | GD.PrintRaw("B");
|
918 | 919 | GD.PrintRaw("C");
|
919 |
| - // Prints ABC to terminal |
920 | 920 | [/csharp]
|
921 | 921 | [/codeblocks]
|
922 | 922 | </description>
|
|
927 | 927 | Prints one or more arguments to the console with a space between each argument.
|
928 | 928 | [codeblocks]
|
929 | 929 | [gdscript]
|
930 |
| - prints("A", "B", "C") # Prints A B C |
| 930 | + prints("A", "B", "C") # Prints "A B C" |
931 | 931 | [/gdscript]
|
932 | 932 | [csharp]
|
933 |
| - GD.PrintS("A", "B", "C"); // Prints A B C |
| 933 | + GD.PrintS("A", "B", "C"); // Prints "A B C" |
934 | 934 | [/csharp]
|
935 | 935 | [/codeblocks]
|
936 | 936 | </description>
|
|
941 | 941 | Prints one or more arguments to the console with a tab between each argument.
|
942 | 942 | [codeblocks]
|
943 | 943 | [gdscript]
|
944 |
| - printt("A", "B", "C") # Prints A B C |
| 944 | + printt("A", "B", "C") # Prints "A B C" |
945 | 945 | [/gdscript]
|
946 | 946 | [csharp]
|
947 |
| - GD.PrintT("A", "B", "C"); // Prints A B C |
| 947 | + GD.PrintT("A", "B", "C"); // Prints "A B C" |
948 | 948 | [/csharp]
|
949 | 949 | [/codeblocks]
|
950 | 950 | </description>
|
|
955 | 955 | Pushes an error message to Godot's built-in debugger and to the OS terminal.
|
956 | 956 | [codeblocks]
|
957 | 957 | [gdscript]
|
958 |
| - push_error("test error") # Prints "test error" to debugger and terminal as error call |
| 958 | + push_error("test error") # Prints "test error" to debugger and terminal as an error. |
959 | 959 | [/gdscript]
|
960 | 960 | [csharp]
|
961 |
| - GD.PushError("test error"); // Prints "test error" to debugger and terminal as error call |
| 961 | + GD.PushError("test error"); // Prints "test error" to debugger and terminal as an error. |
962 | 962 | [/csharp]
|
963 | 963 | [/codeblocks]
|
964 | 964 | [b]Note:[/b] This function does not pause project execution. To print an error message and pause project execution in debug builds, use [code]assert(false, "test error")[/code] instead.
|
|
970 | 970 | Pushes a warning message to Godot's built-in debugger and to the OS terminal.
|
971 | 971 | [codeblocks]
|
972 | 972 | [gdscript]
|
973 |
| - push_warning("test warning") # Prints "test warning" to debugger and terminal as warning call |
| 973 | + push_warning("test warning") # Prints "test warning" to debugger and terminal as a warning. |
974 | 974 | [/gdscript]
|
975 | 975 | [csharp]
|
976 |
| - GD.PushWarning("test warning"); // Prints "test warning" to debugger and terminal as warning call |
| 976 | + GD.PushWarning("test warning"); // Prints "test warning" to debugger and terminal as a warning. |
977 | 977 | [/csharp]
|
978 | 978 | [/codeblocks]
|
979 | 979 | </description>
|
|
1413 | 1413 | <description>
|
1414 | 1414 | Returns a human-readable name of the given [param type], using the [enum Variant.Type] values.
|
1415 | 1415 | [codeblock]
|
1416 |
| - print(TYPE_INT) # Prints 2. |
1417 |
| - print(type_string(TYPE_INT)) # Prints "int". |
1418 |
| - print(type_string(TYPE_STRING)) # Prints "String". |
| 1416 | + print(TYPE_INT) # Prints 2 |
| 1417 | + print(type_string(TYPE_INT)) # Prints "int" |
| 1418 | + print(type_string(TYPE_STRING)) # Prints "String" |
1419 | 1419 | [/codeblock]
|
1420 | 1420 | See also [method typeof].
|
1421 | 1421 | </description>
|
|
1429 | 1429 | var json = JSON.new()
|
1430 | 1430 | json.parse('["a", "b", "c"]')
|
1431 | 1431 | var result = json.get_data()
|
1432 |
| - if typeof(result) == TYPE_ARRAY: |
1433 |
| - print(result[0]) # Prints a |
| 1432 | + if result is Array: |
| 1433 | + print(result[0]) # Prints "a" |
1434 | 1434 | else:
|
1435 |
| - print("Unexpected result") |
| 1435 | + print("Unexpected result!") |
1436 | 1436 | [/codeblock]
|
1437 | 1437 | See also [method type_string].
|
1438 | 1438 | </description>
|
|
0 commit comments