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
|
|
@ -6,7 +6,8 @@
|
|||
<description>
|
||||
This is the built-in string Variant type (and the one used by GDScript). Strings may contain any number of Unicode characters, and expose methods useful for manipulating and generating strings. Strings are reference-counted and use a copy-on-write approach (every modification to a string returns a new [String]), so passing them around is cheap in resources.
|
||||
Some string methods have corresponding variations. Variations suffixed with [code]n[/code] ([method countn], [method findn], [method replacen], etc.) are [b]case-insensitive[/b] (they make no distinction between uppercase and lowercase letters). Method variations prefixed with [code]r[/code] ([method rfind], [method rsplit], etc.) are reversed, and start from the end of the string, instead of the beginning.
|
||||
[b]Note:[/b] In a boolean context, a string will evaluate to [code]false[/code] if it is empty ([code]""[/code]). Otherwise, a string 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 strings.
|
||||
To convert any [Variant] to or from a string, see [method @GlobalScope.str], [method @GlobalScope.str_to_var], and [method @GlobalScope.var_to_str].
|
||||
[b]Note:[/b] In a boolean context, a string will evaluate to [code]false[/code] if it is empty ([code]""[/code]). Otherwise, a string will always evaluate to [code]true[/code].
|
||||
</description>
|
||||
<tutorials>
|
||||
<link title="GDScript format strings">$DOCS_URL/tutorials/scripting/gdscript/gdscript_format_string.html</link>
|
||||
|
|
@ -138,8 +139,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].
|
||||
|
|
@ -247,7 +248,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."
|
||||
|
|
@ -262,13 +263,19 @@
|
|||
print("User {} is {}.".format([42, "Godot"], "{}"))
|
||||
print("User {id} is {name}.".format([["id", 42], ["name", "Godot"]]))
|
||||
[/codeblock]
|
||||
See also the [url=$DOCS_URL/tutorials/scripting/gdscript/gdscript_format_string.html]GDScript format string[/url] tutorial.
|
||||
[b]Note:[/b] The replacement of placeholders is not done all at once, instead each placeholder is replaced in the order they are passed, this means that if one of the replacement strings contains a key it will also be replaced. This can be very powerful, but can also cause unexpected results if you are not careful. If you do not need to perform replacement in the replacement strings, make sure your replacements do not contain placeholders to ensure reliable results.
|
||||
When passing an [Object], the property names from [method Object.get_property_list] are used as keys.
|
||||
[codeblock]
|
||||
print("{0} {1}".format(["{1}", "x"])) # Prints "x x".
|
||||
print("{0} {1}".format(["x", "{0}"])) # Prints "x {0}".
|
||||
print("{foo} {bar}".format({"foo": "{bar}", "bar": "baz"})) # Prints "baz baz".
|
||||
print("{foo} {bar}".format({"bar": "baz", "foo": "{bar}"})) # Prints "{bar} baz".
|
||||
# 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>
|
||||
|
|
@ -324,7 +331,6 @@
|
|||
<description>
|
||||
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]
|
||||
|
|
@ -452,6 +458,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>
|
||||
|
|
@ -491,7 +510,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.
|
||||
|
|
@ -522,12 +541,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"]
|
||||
|
|
@ -536,7 +571,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"
|
||||
|
|
@ -647,7 +682,6 @@
|
|||
Converts a [float] to a string representation of a decimal number, with the number of decimal places specified in [param decimals].
|
||||
If [param decimals] is [code]-1[/code] as by default, the string representation may only have up to 14 significant digits, with digits before the decimal point having priority over digits after.
|
||||
Trailing zeros are not included in the string. The last digit is rounded, not truncated.
|
||||
[b]Example:[/b]
|
||||
[codeblock]
|
||||
String.num(3.141593) # Returns "3.141593"
|
||||
String.num(3.141593, 3) # Returns "3.142"
|
||||
|
|
@ -802,7 +836,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"
|
||||
|
|
@ -854,7 +887,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
|
||||
|
|
@ -882,7 +915,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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue