feat: updated engine version to 4.4-rc1
This commit is contained in:
parent
ee00efde1f
commit
21ba8e33af
5459 changed files with 1128836 additions and 198305 deletions
|
|
@ -9,7 +9,7 @@
|
|||
See also [NodePath], which is a similar concept specifically designed to store pre-parsed scene tree paths.
|
||||
All of [String]'s methods are available in this class too. They convert the [StringName] into a string, and they also return a string. This is highly inefficient and should only be used if the string is desired.
|
||||
[b]Note:[/b] In C#, an explicit conversion to [code]System.String[/code] is required to use the methods listed on this page. Use the [code]ToString()[/code] method to cast a [StringName] to a string, and then use the equivalent methods in [code]System.String[/code] or [code]StringExtensions[/code].
|
||||
[b]Note:[/b] In a boolean context, a [StringName] will evaluate to [code]false[/code] if it is empty ([code]StringName("")[/code]). Otherwise, a [StringName] will always evaluate to [code]true[/code]. The [code]not[/code] operator cannot be used. Instead, [method is_empty] should be used to check for empty [StringName]s.
|
||||
[b]Note:[/b] In a boolean context, a [StringName] will evaluate to [code]false[/code] if it is empty ([code]StringName("")[/code]). Otherwise, a [StringName] will always evaluate to [code]true[/code].
|
||||
</description>
|
||||
<tutorials>
|
||||
</tutorials>
|
||||
|
|
@ -122,8 +122,8 @@
|
|||
print("I" in "team") # Prints false
|
||||
[/gdscript]
|
||||
[csharp]
|
||||
GD.Print("Node".Contains("de")); // Prints true
|
||||
GD.Print("team".Contains("I")); // Prints false
|
||||
GD.Print("Node".Contains("de")); // Prints True
|
||||
GD.Print("team".Contains("I")); // Prints False
|
||||
[/csharp]
|
||||
[/codeblocks]
|
||||
If you need to know where [param what] is within the string, use [method find]. See also [method containsn].
|
||||
|
|
@ -231,7 +231,7 @@
|
|||
<param index="1" name="placeholder" type="String" default=""{_}"" />
|
||||
<description>
|
||||
Formats the string by replacing all occurrences of [param placeholder] with the elements of [param values].
|
||||
[param values] can be a [Dictionary] or an [Array]. Any underscores in [param placeholder] will be replaced with the corresponding keys in advance. Array elements use their index as keys.
|
||||
[param values] can be a [Dictionary], an [Array], or an [Object]. Any underscores in [param placeholder] will be replaced with the corresponding keys in advance. Array elements use their index as keys.
|
||||
[codeblock]
|
||||
# Prints "Waiting for Godot is a play by Samuel Beckett, and Godot Engine is named after it."
|
||||
var use_array_values = "Waiting for {0} is a play by {1}, and {0} Engine is named after it."
|
||||
|
|
@ -246,7 +246,20 @@
|
|||
print("User {} is {}.".format([42, "Godot"], "{}"))
|
||||
print("User {id} is {name}.".format([["id", 42], ["name", "Godot"]]))
|
||||
[/codeblock]
|
||||
When passing an [Object], the property names from [method Object.get_property_list] are used as keys.
|
||||
[codeblock]
|
||||
# Prints "Visible true, position (0, 0)"
|
||||
var node = Node2D.new()
|
||||
print("Visible {visible}, position {position}".format(node))
|
||||
[/codeblock]
|
||||
See also the [url=$DOCS_URL/tutorials/scripting/gdscript/gdscript_format_string.html]GDScript format string[/url] tutorial.
|
||||
[b]Note:[/b] Each replacement is done sequentially for each element of [param values], [b]not[/b] all at once. This means that if any element is inserted and it contains another placeholder, it may be changed by the next replacement. While this can be very useful, it often causes unexpected results. If not necessary, make sure [param values]'s elements do not contain placeholders.
|
||||
[codeblock]
|
||||
print("{0} {1}".format(["{1}", "x"])) # Prints "x x"
|
||||
print("{0} {1}".format(["x", "{0}"])) # Prints "x {0}"
|
||||
print("{a} {b}".format({"a": "{b}", "b": "c"})) # Prints "c c"
|
||||
print("{a} {b}".format({"b": "c", "a": "{b}"})) # Prints "{b} c"
|
||||
[/codeblock]
|
||||
[b]Note:[/b] In C#, it's recommended to [url=https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/tokens/interpolated]interpolate strings with "$"[/url], instead.
|
||||
</description>
|
||||
</method>
|
||||
|
|
@ -299,9 +312,8 @@
|
|||
<param index="0" name="delimiter" type="String" />
|
||||
<param index="1" name="slice" type="int" />
|
||||
<description>
|
||||
Splits the string using a [param delimiter] and returns the substring at index [param slice]. Returns an empty string if the [param slice] does not exist.
|
||||
Splits the string using a [param delimiter] and returns the substring at index [param slice]. Returns the original string if [param delimiter] does not occur in the string. Returns an empty string if the [param slice] does not exist.
|
||||
This is faster than [method split], if you only need one substring.
|
||||
[b]Example:[/b]
|
||||
[codeblock]
|
||||
print("i/am/example/hi".get_slice("/", 2)) # Prints "example"
|
||||
[/codeblock]
|
||||
|
|
@ -421,6 +433,19 @@
|
|||
Returns [code]true[/code] if all characters of this string can be found in [param text] in their original order, [b]ignoring case[/b].
|
||||
</description>
|
||||
</method>
|
||||
<method name="is_valid_ascii_identifier" qualifiers="const">
|
||||
<return type="bool" />
|
||||
<description>
|
||||
Returns [code]true[/code] if this string is a valid ASCII identifier. A valid ASCII identifier may contain only letters, digits, and underscores ([code]_[/code]), and the first character may not be a digit.
|
||||
[codeblock]
|
||||
print("node_2d".is_valid_ascii_identifier()) # Prints true
|
||||
print("TYPE_FLOAT".is_valid_ascii_identifier()) # Prints true
|
||||
print("1st_method".is_valid_ascii_identifier()) # Prints false
|
||||
print("MyMethod#2".is_valid_ascii_identifier()) # Prints false
|
||||
[/codeblock]
|
||||
See also [method is_valid_unicode_identifier].
|
||||
</description>
|
||||
</method>
|
||||
<method name="is_valid_filename" qualifiers="const">
|
||||
<return type="bool" />
|
||||
<description>
|
||||
|
|
@ -460,7 +485,7 @@
|
|||
Returns [code]true[/code] if this string is a valid color in hexadecimal HTML notation. The string must be a hexadecimal value (see [method is_valid_hex_number]) of either 3, 4, 6 or 8 digits, and may be prefixed by a hash sign ([code]#[/code]). Other HTML notations for colors, such as names or [code]hsl()[/code], are not considered valid. See also [method Color.html].
|
||||
</description>
|
||||
</method>
|
||||
<method name="is_valid_identifier" qualifiers="const">
|
||||
<method name="is_valid_identifier" qualifiers="const" deprecated="Use [method is_valid_ascii_identifier] instead.">
|
||||
<return type="bool" />
|
||||
<description>
|
||||
Returns [code]true[/code] if this string is a valid identifier. A valid identifier may contain only letters, digits and underscores ([code]_[/code]), and the first character may not be a digit.
|
||||
|
|
@ -491,12 +516,28 @@
|
|||
Returns [code]true[/code] if this string represents a well-formatted IPv4 or IPv6 address. This method considers [url=https://en.wikipedia.org/wiki/Reserved_IP_addresses]reserved IP addresses[/url] such as [code]"0.0.0.0"[/code] and [code]"ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff"[/code] as valid.
|
||||
</description>
|
||||
</method>
|
||||
<method name="is_valid_unicode_identifier" qualifiers="const">
|
||||
<return type="bool" />
|
||||
<description>
|
||||
Returns [code]true[/code] if this string is a valid Unicode identifier.
|
||||
A valid Unicode identifier must begin with a Unicode character of class [code]XID_Start[/code] or [code]"_"[/code], and may contain Unicode characters of class [code]XID_Continue[/code] in the other positions.
|
||||
[codeblock]
|
||||
print("node_2d".is_valid_unicode_identifier()) # Prints true
|
||||
print("1st_method".is_valid_unicode_identifier()) # Prints false
|
||||
print("MyMethod#2".is_valid_unicode_identifier()) # Prints false
|
||||
print("állóképesség".is_valid_unicode_identifier()) # Prints true
|
||||
print("выносливость".is_valid_unicode_identifier()) # Prints true
|
||||
print("体力".is_valid_unicode_identifier()) # Prints true
|
||||
[/codeblock]
|
||||
See also [method is_valid_ascii_identifier].
|
||||
[b]Note:[/b] This method checks identifiers the same way as GDScript. See [method TextServer.is_valid_identifier] for more advanced checks.
|
||||
</description>
|
||||
</method>
|
||||
<method name="join" qualifiers="const">
|
||||
<return type="String" />
|
||||
<param index="0" name="parts" type="PackedStringArray" />
|
||||
<description>
|
||||
Returns the concatenation of [param parts]' elements, with each element separated by the string calling this method. This method is the opposite of [method split].
|
||||
[b]Example:[/b]
|
||||
[codeblocks]
|
||||
[gdscript]
|
||||
var fruits = ["Apple", "Orange", "Pear", "Kiwi"]
|
||||
|
|
@ -505,7 +546,7 @@
|
|||
print("---".join(fruits)) # Prints "Apple---Orange---Pear---Kiwi"
|
||||
[/gdscript]
|
||||
[csharp]
|
||||
var fruits = new string[] {"Apple", "Orange", "Pear", "Kiwi"};
|
||||
string[] fruits = ["Apple", "Orange", "Pear", "Kiwi"];
|
||||
|
||||
// In C#, this method is static.
|
||||
GD.Print(string.Join(", ", fruits)); // Prints "Apple, Orange, Pear, Kiwi"
|
||||
|
|
@ -703,7 +744,6 @@
|
|||
Splits the string using a [param delimiter] and returns an array of the substrings, starting from the end of the string. The splits in the returned array appear in the same order as the original string. If [param delimiter] is an empty string, each substring will be a single character.
|
||||
If [param allow_empty] is [code]false[/code], empty strings between adjacent delimiters are excluded from the array.
|
||||
If [param maxsplit] is greater than [code]0[/code], the number of splits may not exceed [param maxsplit]. By default, the entire string is split, which is mostly identical to [method split].
|
||||
[b]Example:[/b]
|
||||
[codeblocks]
|
||||
[gdscript]
|
||||
var some_string = "One,Two,Three,Four"
|
||||
|
|
@ -755,7 +795,7 @@
|
|||
<return type="float" />
|
||||
<param index="0" name="text" type="String" />
|
||||
<description>
|
||||
Returns the similarity index ([url=https://en.wikipedia.org/wiki/S%C3%B8rensen%E2%80%93Dice_coefficient]Sorensen-Dice coefficient[/url]) of this string compared to another. A result of [code]1.0[/code] means totally similar, while [code]0.0[/code] means totally dissimilar.
|
||||
Returns the similarity index ([url=https://en.wikipedia.org/wiki/S%C3%B8rensen%E2%80%93Dice_coefficient]Sørensen-Dice coefficient[/url]) of this string compared to another. A result of [code]1.0[/code] means totally similar, while [code]0.0[/code] means totally dissimilar.
|
||||
[codeblock]
|
||||
print("ABC123".similarity("ABC123")) # Prints 1.0
|
||||
print("ABC123".similarity("XYZ456")) # Prints 0.0
|
||||
|
|
@ -783,7 +823,6 @@
|
|||
Splits the string using a [param delimiter] and returns an array of the substrings. If [param delimiter] is an empty string, each substring will be a single character. This method is the opposite of [method join].
|
||||
If [param allow_empty] is [code]false[/code], empty strings between adjacent delimiters are excluded from the array.
|
||||
If [param maxsplit] is greater than [code]0[/code], the number of splits may not exceed [param maxsplit]. By default, the entire string is split.
|
||||
[b]Example:[/b]
|
||||
[codeblocks]
|
||||
[gdscript]
|
||||
var some_array = "One,Two,Three,Four".split(",", true, 2)
|
||||
|
|
@ -845,7 +884,7 @@
|
|||
<method name="to_ascii_buffer" qualifiers="const">
|
||||
<return type="PackedByteArray" />
|
||||
<description>
|
||||
Converts the string to an [url=https://en.wikipedia.org/wiki/ASCII]ASCII[/url]/Latin-1 encoded [PackedByteArray]. This method is slightly faster than [method to_utf8_buffer], but replaces all unsupported characters with spaces.
|
||||
Converts the string to an [url=https://en.wikipedia.org/wiki/ASCII]ASCII[/url]/Latin-1 encoded [PackedByteArray]. This method is slightly faster than [method to_utf8_buffer], but replaces all unsupported characters with spaces. This is the inverse of [method PackedByteArray.get_string_from_ascii].
|
||||
</description>
|
||||
</method>
|
||||
<method name="to_camel_case" qualifiers="const">
|
||||
|
|
@ -859,11 +898,11 @@
|
|||
<description>
|
||||
Converts the string representing a decimal number into a [float]. This method stops on the first non-number character, except the first decimal point ([code].[/code]) and the exponent letter ([code]e[/code]). See also [method is_valid_float].
|
||||
[codeblock]
|
||||
var a = "12.35".to_float() # a is 12.35
|
||||
var b = "1.2.3".to_float() # b is 1.2
|
||||
var c = "12xy3".to_float() # c is 12.0
|
||||
var d = "1e3".to_float() # d is 1000.0
|
||||
var e = "Hello!".to_int() # e is 0.0
|
||||
var a = "12.35".to_float() # a is 12.35
|
||||
var b = "1.2.3".to_float() # b is 1.2
|
||||
var c = "12xy3".to_float() # c is 12.0
|
||||
var d = "1e3".to_float() # d is 1000.0
|
||||
var e = "Hello!".to_float() # e is 0.0
|
||||
[/codeblock]
|
||||
</description>
|
||||
</method>
|
||||
|
|
@ -919,25 +958,25 @@
|
|||
<method name="to_utf8_buffer" qualifiers="const">
|
||||
<return type="PackedByteArray" />
|
||||
<description>
|
||||
Converts the string to a [url=https://en.wikipedia.org/wiki/UTF-8]UTF-8[/url] encoded [PackedByteArray]. This method is slightly slower than [method to_ascii_buffer], but supports all UTF-8 characters. For most cases, prefer using this method.
|
||||
Converts the string to a [url=https://en.wikipedia.org/wiki/UTF-8]UTF-8[/url] encoded [PackedByteArray]. This method is slightly slower than [method to_ascii_buffer], but supports all UTF-8 characters. For most cases, prefer using this method. This is the inverse of [method PackedByteArray.get_string_from_utf8].
|
||||
</description>
|
||||
</method>
|
||||
<method name="to_utf16_buffer" qualifiers="const">
|
||||
<return type="PackedByteArray" />
|
||||
<description>
|
||||
Converts the string to a [url=https://en.wikipedia.org/wiki/UTF-16]UTF-16[/url] encoded [PackedByteArray].
|
||||
Converts the string to a [url=https://en.wikipedia.org/wiki/UTF-16]UTF-16[/url] encoded [PackedByteArray]. This is the inverse of [method PackedByteArray.get_string_from_utf16].
|
||||
</description>
|
||||
</method>
|
||||
<method name="to_utf32_buffer" qualifiers="const">
|
||||
<return type="PackedByteArray" />
|
||||
<description>
|
||||
Converts the string to a [url=https://en.wikipedia.org/wiki/UTF-32]UTF-32[/url] encoded [PackedByteArray].
|
||||
Converts the string to a [url=https://en.wikipedia.org/wiki/UTF-32]UTF-32[/url] encoded [PackedByteArray]. This is the inverse of [method PackedByteArray.get_string_from_utf32].
|
||||
</description>
|
||||
</method>
|
||||
<method name="to_wchar_buffer" qualifiers="const">
|
||||
<return type="PackedByteArray" />
|
||||
<description>
|
||||
Converts the string to a [url=https://en.wikipedia.org/wiki/Wide_character]wide character[/url] ([code]wchar_t[/code], UTF-16 on Windows, UTF-32 on other platforms) encoded [PackedByteArray].
|
||||
Converts the string to a [url=https://en.wikipedia.org/wiki/Wide_character]wide character[/url] ([code]wchar_t[/code], UTF-16 on Windows, UTF-32 on other platforms) encoded [PackedByteArray]. This is the inverse of [method PackedByteArray.get_string_from_wchar].
|
||||
</description>
|
||||
</method>
|
||||
<method name="trim_prefix" qualifiers="const">
|
||||
|
|
@ -964,7 +1003,7 @@
|
|||
<method name="uri_decode" qualifiers="const">
|
||||
<return type="String" />
|
||||
<description>
|
||||
Decodes the string from its URL-encoded format. This method is meant to properly decode the parameters in a URL when receiving an HTTP request.
|
||||
Decodes the string from its URL-encoded format. This method is meant to properly decode the parameters in a URL when receiving an HTTP request. See also [method uri_encode].
|
||||
[codeblocks]
|
||||
[gdscript]
|
||||
var url = "$DOCS_URL/?highlight=Godot%20Engine%3%docs"
|
||||
|
|
@ -980,7 +1019,7 @@
|
|||
<method name="uri_encode" qualifiers="const">
|
||||
<return type="String" />
|
||||
<description>
|
||||
Encodes the string to URL-friendly format. This method is meant to properly encode the parameters in a URL when sending an HTTP request.
|
||||
Encodes the string to URL-friendly format. This method is meant to properly encode the parameters in a URL when sending an HTTP request. See also [method uri_decode].
|
||||
[codeblocks]
|
||||
[gdscript]
|
||||
var prefix = "$DOCS_URL/?highlight="
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue