diff options
Diffstat (limited to 'modules/gdscript/doc_classes')
-rw-r--r-- | modules/gdscript/doc_classes/@GDScript.xml | 58 | ||||
-rw-r--r-- | modules/gdscript/doc_classes/GDScript.xml | 2 |
2 files changed, 47 insertions, 13 deletions
diff --git a/modules/gdscript/doc_classes/@GDScript.xml b/modules/gdscript/doc_classes/@GDScript.xml index 840971dcf8..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"> @@ -208,7 +210,7 @@ <argument index="1" name="type" type="int"> </argument> <description> - Converts from a type to another in the best way possible. The [code]type[/code] parameter uses the enum [code]TYPE_*[/code] in [@GlobalScope]. + Converts from a type to another in the best way possible. The [code]type[/code] parameter uses the [enum Variant.Type] values. [codeblock] a = Vector2(1, 0) # Prints 1 @@ -336,11 +338,12 @@ <description> Rounds [code]s[/code] to the closest smaller integer and returns it. [codeblock] - # a is 2 + # a is 2.0 a = floor(2.99) - # a is -3 + # a is -3.0 a = floor(-2.99) [/codeblock] + [b]Note:[/b] This method returns a float. If you need an integer, you can use [code]int(s)[/code] directly. </description> </method> <method name="fmod"> @@ -502,7 +505,7 @@ <argument index="1" name="b" type="float"> </argument> <description> - Returns True/False whether [code]a[/code] and [code]b[/code] are approximately equal to each other. + Returns [code]true[/code] if [code]a[/code] and [code]b[/code] are approximately equal to each other. </description> </method> <method name="is_inf"> @@ -538,7 +541,7 @@ <argument index="0" name="s" type="float"> </argument> <description> - Returns True/False whether [code]s[/code] is zero or almost zero. + Returns [code]true[/code] if [code]s[/code] is zero or almost zero. </description> </method> <method name="len"> @@ -615,9 +618,10 @@ Loads a resource from the filesystem located at [code]path[/code]. [b]Note:[/b] Resource paths can be obtained by right-clicking on a resource in the FileSystem dock and choosing [b]Copy Path[/b]. [codeblock] - # Load a scene called main located in the root of the project directory + # Load a scene called main located in the root of the project directory. var main = load("res://main.tscn") [/codeblock] + [b]Important:[/b] The path must be absolute, a local path will just return [code]null[/code]. </description> </method> <method name="log"> @@ -700,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"> @@ -785,7 +796,7 @@ Returns a resource from the filesystem that is loaded during script parsing. [b]Note:[/b] Resource paths can be obtained by right clicking on a resource in the Assets Panel and choosing "Copy Path". [codeblock] - # Load a scene called main located in the root of the project directory + # Load a scene called main located in the root of the project directory. var main = preload("res://main.tscn") [/codeblock] </description> @@ -935,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 @@ -1216,7 +1227,7 @@ <argument index="0" name="what" type="Variant"> </argument> <description> - Returns the internal type of the given Variant object, using the [code]TYPE_*[/code] enum in [@GlobalScope]. + Returns the internal type of the given Variant object, using the [enum Variant.Type] values. [codeblock] p = parse_json('["a", "b", "c"]') if typeof(p) == TYPE_ARRAY: @@ -1232,7 +1243,7 @@ <argument index="0" name="json" type="String"> </argument> <description> - Checks that [code]json[/code] is valid JSON data. Returns empty string if valid. Returns error message if not valid. + Checks that [code]json[/code] is valid JSON data. Returns an empty string if valid, or an error message otherwise. [codeblock] j = to_json([1, 2, 3]) v = validate_json(j) @@ -1363,6 +1374,29 @@ Stops the function execution and returns the current suspended state to the calling function. From the caller, call [method GDScriptFunctionState.resume] on the state to resume execution. This invalidates the state. Within the resumed function, [code]yield()[/code] returns whatever was passed to the [code]resume()[/code] function call. If passed an object and a signal, the execution is resumed when the object emits the given signal. In this case, [code]yield()[/code] returns the argument passed to [code]emit_signal()[/code] if the signal takes only one argument, or an array containing all the arguments passed to [code]emit_signal()[/code] if the signal takes multiple arguments. + You can also use [code]yield[/code] to wait for a function to finish: + [codeblock] + func _ready(): + yield(countdown(), "completed") # waiting for the countdown() function to complete + print('Ready') + + 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: + # 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. + 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> diff --git a/modules/gdscript/doc_classes/GDScript.xml b/modules/gdscript/doc_classes/GDScript.xml index 6f43361914..8e175a7ab8 100644 --- a/modules/gdscript/doc_classes/GDScript.xml +++ b/modules/gdscript/doc_classes/GDScript.xml @@ -4,7 +4,7 @@ A script implemented in the GDScript programming language. </brief_description> <description> - A script implemented in the GDScript programming language. The script exends the functionality of all objects that instance it. + A script implemented in the GDScript programming language. The script extends the functionality of all objects that instance it. [method new] creates a new instance of the script. [method Object.set_script] extends an existing object, if that object's class matches one of the script's base classes. </description> <tutorials> |