GDScript: Re-add ord() function

This commit is contained in:
Danil Alexeev
2024-11-12 16:21:52 +03:00
parent 51b0379e55
commit f864d0ce11
5 changed files with 36 additions and 11 deletions

View File

@@ -48,14 +48,14 @@
</method>
<method name="char">
<return type="String" />
<param index="0" name="char" type="int" />
<param index="0" name="code" type="int" />
<description>
Returns a single character (as a [String]) of the given Unicode code point (which is compatible with ASCII code).
Returns a single character (as a [String] of length 1) of the given Unicode code point [param code].
[codeblock]
var upper = char(65) # upper is "A"
var lower = char(65 + 32) # lower is "a"
var euro = char(8364) # euro is "€"
print(char(65)) # Prints "A"
print(char(129302)) # Prints "🤖" (robot face emoji)
[/codeblock]
This is the inverse of [method ord]. See also [method String.chr] and [method String.unicode_at].
</description>
</method>
<method name="convert" deprecated="Use [method @GlobalScope.type_convert] instead.">
@@ -175,6 +175,18 @@
[b]Note:[/b] If [member ProjectSettings.editor/export/convert_text_resources_to_binary] is [code]true[/code], [method @GDScript.load] will not be able to read converted files in an exported project. If you rely on run-time loading of files present within the PCK, set [member ProjectSettings.editor/export/convert_text_resources_to_binary] to [code]false[/code].
</description>
</method>
<method name="ord">
<return type="int" />
<param index="0" name="char" type="String" />
<description>
Returns an integer representing the Unicode code point of the given character [param char], which should be a string of length 1.
[codeblock]
print(ord("A")) # Prints 65
print(ord("🤖")) # Prints 129302
[/codeblock]
This is the inverse of [method char]. See also [method String.chr] and [method String.unicode_at].
</description>
</method>
<method name="preload">
<return type="Resource" />
<param index="0" name="path" type="String" />