diff options
Diffstat (limited to 'modules/gdscript/doc_classes/@GDScript.xml')
-rw-r--r-- | modules/gdscript/doc_classes/@GDScript.xml | 60 |
1 files changed, 36 insertions, 24 deletions
diff --git a/modules/gdscript/doc_classes/@GDScript.xml b/modules/gdscript/doc_classes/@GDScript.xml index 2a8453116e..b947d95fac 100644 --- a/modules/gdscript/doc_classes/@GDScript.xml +++ b/modules/gdscript/doc_classes/@GDScript.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="@GDScript" category="Core" version="3.2"> +<class name="@GDScript" version="4.0"> <brief_description> Built-in GDScript functions. </brief_description> @@ -39,12 +39,11 @@ <argument index="1" name="alpha" type="float" default="1.0"> </argument> <description> - Returns a color according to the standardised [code]name[/code] with [code]alpha[/code] ranging from 0 to 1. + Returns a color according to the standardized [code]name[/code] with [code]alpha[/code] ranging from 0 to 1. [codeblock] red = ColorN("red", 1) [/codeblock] - Supported color names: - "aliceblue", "antiquewhite", "aqua", "aquamarine", "azure", "beige", "bisque", "black", "blanchedalmond", "blue", "blueviolet", "brown", "burlywood", "cadetblue", "chartreuse", "chocolate", "coral", "cornflower", "cornsilk", "crimson", "cyan", "darkblue", "darkcyan", "darkgoldenrod", "darkgray", "darkgreen", "darkkhaki", "darkmagenta", "darkolivegreen", "darkorange", "darkorchid", "darkred", "darksalmon", "darkseagreen", "darkslateblue", "darkslategray", "darkturquoise", "darkviolet", "deeppink", "deepskyblue", "dimgray", "dodgerblue", "firebrick", "floralwhite", "forestgreen", "fuchsia", "gainsboro", "ghostwhite", "gold", "goldenrod", "gray", "webgray", "green", "webgreen", "greenyellow", "honeydew", "hotpink", "indianred", "indigo", "ivory", "khaki", "lavender", "lavenderblush", "lawngreen", "lemonchiffon", "lightblue", "lightcoral", "lightcyan", "lightgoldenrod", "lightgray", "lightgreen", "lightpink", "lightsalmon", "lightseagreen", "lightskyblue", "lightslategray", "lightsteelblue", "lightyellow", "lime", "limegreen", "linen", "magenta", "maroon", "webmaroon", "mediumaquamarine", "mediumblue", "mediumorchid", "mediumpurple", "mediumseagreen", "mediumslateblue", "mediumspringgreen", "mediumturquoise", "mediumvioletred", "midnightblue", "mintcream", "mistyrose", "moccasin", "navajowhite", "navyblue", "oldlace", "olive", "olivedrab", "orange", "orangered", "orchid", "palegoldenrod", "palegreen", "paleturquoise", "palevioletred", "papayawhip", "peachpuff", "peru", "pink", "plum", "powderblue", "purple", "webpurple", "rebeccapurple", "red", "rosybrown", "royalblue", "saddlebrown", "salmon", "sandybrown", "seagreen", "seashell", "sienna", "silver", "skyblue", "slateblue", "slategray", "snow", "springgreen", "steelblue", "tan", "teal", "thistle", "tomato", "turquoise", "violet", "wheat", "white", "whitesmoke", "yellow", "yellowgreen". + Supported color names are the same as the constants defined in [Color]. </description> </method> <method name="abs"> @@ -168,14 +167,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 +209,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 @@ -616,9 +617,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"> @@ -701,6 +703,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"> @@ -786,7 +795,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> @@ -936,7 +945,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 @@ -1217,7 +1226,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: @@ -1233,7 +1242,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) @@ -1367,23 +1376,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> |