summaryrefslogtreecommitdiff
path: root/modules/gdscript/doc_classes/@GDScript.xml
diff options
context:
space:
mode:
Diffstat (limited to 'modules/gdscript/doc_classes/@GDScript.xml')
-rw-r--r--modules/gdscript/doc_classes/@GDScript.xml42
1 files changed, 27 insertions, 15 deletions
diff --git a/modules/gdscript/doc_classes/@GDScript.xml b/modules/gdscript/doc_classes/@GDScript.xml
index 502a68cd61..c4b7e4887e 100644
--- a/modules/gdscript/doc_classes/@GDScript.xml
+++ b/modules/gdscript/doc_classes/@GDScript.xml
@@ -168,14 +168,16 @@
<method name="char">
<return type="String">
</return>
- <argument index="0" name="ascii" type="int">
+ <argument index="0" name="code" type="int">
</argument>
<description>
- Returns a character as a String of the given ASCII code.
+ Returns a character as a String of the given Unicode code point (which is compatible with ASCII code).
[codeblock]
a = char(65) # a is "A"
a = char(65 + 32) # a is "a"
+ a = char(8364) # a is "€"
[/codeblock]
+ This is the inverse of [method ord].
</description>
</method>
<method name="clamp">
@@ -702,6 +704,13 @@
<argument index="0" name="char" type="String">
</argument>
<description>
+ Returns an integer representing the Unicode code point of the given Unicode character [code]char[/code].
+ [codeblock]
+ a = ord("A") # a is 65
+ a = ord("a") # a is 97
+ a = ord("€") # a is 8364
+ [/codeblock]
+ This is the inverse of [method char].
</description>
</method>
<method name="parse_json">
@@ -937,7 +946,7 @@
<return type="int">
</return>
<description>
- Returns a random unsigned 32 bit integer. Use remainder to obtain a random value in the interval [code][0, N][/code] (where N is smaller than 2^32 -1).
+ Returns a random unsigned 32 bit integer. Use remainder to obtain a random value in the interval [code][0, N - 1][/code] (where N is smaller than 2^32).
[codeblock]
randi() # Returns random integer between 0 and 2^32 - 1
randi() % 20 # Returns random integer between 0 and 19
@@ -1368,23 +1377,26 @@
You can also use [code]yield[/code] to wait for a function to finish:
[codeblock]
func _ready():
- yield(do_something(), "completed")
- yield(do_something_else(), "completed")
- print("All functions are done!")
-
- func do_something():
- print("Something is done!")
+ yield(countdown(), "completed") # waiting for the countdown() function to complete
+ print('Ready')
- func do_something_else():
- print("Something else is done!")
+ func countdown():
+ yield(get_tree(), "idle_frame") # returns a GDScriptFunctionState object to _ready()
+ print(3)
+ yield(get_tree().create_timer(1.0), "timeout")
+ print(2)
+ yield(get_tree().create_timer(1.0), "timeout")
+ print(1)
+ yield(get_tree().create_timer(1.0), "timeout")
# prints:
- # Something is done!
- # Something else is done!
- # All functions are done!
+ # 3
+ # 2
+ # 1
+ # Ready
[/codeblock]
When yielding on a function, the [code]completed[/code] signal will be emitted automatically when the function returns. It can, therefore, be used as the [code]signal[/code] parameter of the [code]yield[/code] method to resume.
- If you are planning on calling the same function within a loop, you should consider using [code]yield(get_tree(), "idle_frame")[/code] also.
+ In order to yield on a function, the resulting function should also return a [code]GDScriptFunctionState[/code]. Notice [code]yield(get_tree(), "idle_frame")[/code] from the above example.
</description>
</method>
</methods>