diff options
Diffstat (limited to 'modules/gdscript/doc_classes')
-rw-r--r-- | modules/gdscript/doc_classes/@GDScript.xml | 77 |
1 files changed, 60 insertions, 17 deletions
diff --git a/modules/gdscript/doc_classes/@GDScript.xml b/modules/gdscript/doc_classes/@GDScript.xml index 7ececce613..4869573972 100644 --- a/modules/gdscript/doc_classes/@GDScript.xml +++ b/modules/gdscript/doc_classes/@GDScript.xml @@ -43,6 +43,7 @@ assert(speed >= 0 and speed < 20) # You can also combine the two conditional statements in one check. assert(speed < 20, "the speed limit is 20") # Show a message. [/codeblock] + [b]Note:[/b] [method assert] is a keyword, not a function. So you cannot access it as a [Callable] or use it inside expressions. </description> </method> <method name="char"> @@ -95,7 +96,7 @@ print(get_stack()) [/codeblock] Starting from [code]_ready()[/code], [code]bar()[/code] would print: - [codeblock] + [codeblock lang=text] [{function:bar, line:12, source:res://script.gd}, {function:foo, line:9, source:res://script.gd}, {function:_ready, line:6, source:res://script.gd}] [/codeblock] [b]Note:[/b] This function only works if the running instance is connected to a debugging server (i.e. an editor instance). [method get_stack] will not work in projects exported in release mode, or in projects exported in debug mode if not connected to a debugging server. @@ -116,7 +117,7 @@ print(d.values()) [/codeblock] Prints out: - [codeblock] + [codeblock lang=text] [@subpath, @path, foo] [, res://test.gd, bar] [/codeblock] @@ -131,7 +132,7 @@ - A constant from the [enum Variant.Type] enumeration, for example [constant TYPE_INT]. - An [Object]-derived class which exists in [ClassDB], for example [Node]. - A [Script] (you can use any class, including inner one). - Unlike the right operand of the [code]is[/code] operator, [param type] can be a non-constant value. The [code]is[/code] operator supports more features (such as typed arrays) and is more performant. Use the operator instead of this method if you do not need dynamic type checking. + Unlike the right operand of the [code]is[/code] operator, [param type] can be a non-constant value. The [code]is[/code] operator supports more features (such as typed arrays). Use the operator instead of this method if you do not need dynamic type checking. Examples: [codeblock] print(is_instance_of(a, TYPE_INT)) @@ -183,6 +184,7 @@ # Create instance of a scene. var diamond = preload("res://diamond.tscn").instantiate() [/codeblock] + [b]Note:[/b] [method preload] is a keyword, not a function. So you cannot access it as a [Callable]. </description> </method> <method name="print_debug" qualifiers="vararg"> @@ -190,7 +192,7 @@ <description> Like [method @GlobalScope.print], but includes the current stack frame when running with the debugger turned on. The output in the console may look like the following: - [codeblock] + [codeblock lang=text] Test print At: res://test.gd:15:_process() [/codeblock] @@ -202,7 +204,7 @@ <description> Prints a stack trace at the current code location. See also [method get_stack]. The output in the console may look like the following: - [codeblock] + [codeblock lang=text] Frame 0 - res://test.gd:16 in function '_process' [/codeblock] [b]Note:[/b] This function only works if the running instance is connected to a debugging server (i.e. an editor instance). [method print_stack] will not work in projects exported in release mode, or in projects exported in debug mode if not connected to a debugging server. @@ -232,7 +234,7 @@ print(array[i]) [/codeblock] Output: - [codeblock] + [codeblock lang=text] 9 6 3 @@ -243,7 +245,7 @@ print(i / 10.0) [/codeblock] Output: - [codeblock] + [codeblock lang=text] 0.3 0.2 0.1 @@ -333,20 +335,34 @@ <annotation name="@export_color_no_alpha"> <return type="void" /> <description> - Export a [Color] property without allowing its transparency ([member Color.a]) to be edited. + Export a [Color], [Array][lb][Color][rb], or [PackedColorArray] property without allowing its transparency ([member Color.a]) to be edited. See also [constant PROPERTY_HINT_COLOR_NO_ALPHA]. [codeblock] @export_color_no_alpha var dye_color: Color + @export_color_no_alpha var dye_colors: Array[Color] + [/codeblock] + </description> + </annotation> + <annotation name="@export_custom"> + <return type="void" /> + <param index="0" name="hint" type="int" enum="PropertyHint" /> + <param index="1" name="hint_string" type="String" /> + <param index="2" name="usage" type="int" enum="PropertyUsageFlags" is_bitfield="true" default="6" /> + <description> + Allows you to set a custom hint, hint string, and usage flags for the exported property. Note that there's no validation done in GDScript, it will just pass the hint along to the editor. + [codeblock] + @export_custom(PROPERTY_HINT_NONE, "suffix:m") var suffix: Vector3 [/codeblock] </description> </annotation> <annotation name="@export_dir"> <return type="void" /> <description> - Export a [String] property as a path to a directory. The path will be limited to the project folder and its subfolders. See [annotation @export_global_dir] to allow picking from the entire filesystem. + Export a [String], [Array][lb][String][rb], or [PackedStringArray] property as a path to a directory. The path will be limited to the project folder and its subfolders. See [annotation @export_global_dir] to allow picking from the entire filesystem. See also [constant PROPERTY_HINT_DIR]. [codeblock] @export_dir var sprite_folder_path: String + @export_dir var sprite_folder_paths: Array[String] [/codeblock] </description> </annotation> @@ -354,12 +370,15 @@ <return type="void" /> <param index="0" name="names" type="String" /> <description> - Export an [int] or [String] property as an enumerated list of options. If the property is an [int], then the index of the value is stored, in the same order the values are provided. You can add explicit values using a colon. If the property is a [String], then the value is stored. + Export an [int], [String], [Array][lb][int][rb], [Array][lb][String][rb], [PackedByteArray], [PackedInt32Array], [PackedInt64Array], or [PackedStringArray] property as an enumerated list of options (or an array of options). If the property is an [int], then the index of the value is stored, in the same order the values are provided. You can add explicit values using a colon. If the property is a [String], then the value is stored. See also [constant PROPERTY_HINT_ENUM]. [codeblock] @export_enum("Warrior", "Magician", "Thief") var character_class: int @export_enum("Slow:30", "Average:60", "Very Fast:200") var character_speed: int @export_enum("Rebecca", "Mary", "Leah") var character_name: String + + @export_enum("Sword", "Spear", "Mace") var character_items: Array[int] + @export_enum("double_jump", "climb", "dash") var character_skills: Array[String] [/codeblock] If you want to set an initial value, you must specify it explicitly: [codeblock] @@ -369,6 +388,9 @@ [codeblock] enum CharacterName {REBECCA, MARY, LEAH} @export var character_name: CharacterName + + enum CharacterItem {SWORD, SPEAR, MACE} + @export var character_items: Array[CharacterItem] [/codeblock] </description> </annotation> @@ -382,6 +404,7 @@ @export_exp_easing var transition_speed @export_exp_easing("attenuation") var fading_attenuation @export_exp_easing("positive_only") var effect_power + @export_exp_easing var speeds: Array[float] [/codeblock] </description> </annotation> @@ -389,12 +412,13 @@ <return type="void" /> <param index="0" name="filter" type="String" default="""" /> <description> - Export a [String] property as a path to a file. The path will be limited to the project folder and its subfolders. See [annotation @export_global_file] to allow picking from the entire filesystem. + Export a [String], [Array][lb][String][rb], or [PackedStringArray] property as a path to a file. The path will be limited to the project folder and its subfolders. See [annotation @export_global_file] to allow picking from the entire filesystem. If [param filter] is provided, only matching files will be available for picking. See also [constant PROPERTY_HINT_FILE]. [codeblock] @export_file var sound_effect_path: String @export_file("*.txt") var notes_path: String + @export_file var level_paths: Array[String] [/codeblock] </description> </annotation> @@ -421,6 +445,10 @@ [codeblock] @export_flags("A:16", "B", "C") var x [/codeblock] + You can also use the annotation on [Array][lb][int][rb], [PackedByteArray], [PackedInt32Array], and [PackedInt64Array] + [codeblock] + @export_flags("Fire", "Water", "Earth", "Wind") var phase_elements: Array[int] + [/codeblock] </description> </annotation> <annotation name="@export_flags_2d_navigation"> @@ -430,6 +458,7 @@ See also [constant PROPERTY_HINT_LAYERS_2D_NAVIGATION]. [codeblock] @export_flags_2d_navigation var navigation_layers: int + @export_flags_2d_navigation var navigation_layers_array: Array[int] [/codeblock] </description> </annotation> @@ -440,6 +469,7 @@ See also [constant PROPERTY_HINT_LAYERS_2D_PHYSICS]. [codeblock] @export_flags_2d_physics var physics_layers: int + @export_flags_2d_physics var physics_layers_array: Array[int] [/codeblock] </description> </annotation> @@ -450,6 +480,7 @@ See also [constant PROPERTY_HINT_LAYERS_2D_RENDER]. [codeblock] @export_flags_2d_render var render_layers: int + @export_flags_2d_render var render_layers_array: Array[int] [/codeblock] </description> </annotation> @@ -460,6 +491,7 @@ See also [constant PROPERTY_HINT_LAYERS_3D_NAVIGATION]. [codeblock] @export_flags_3d_navigation var navigation_layers: int + @export_flags_3d_navigation var navigation_layers_array: Array[int] [/codeblock] </description> </annotation> @@ -470,6 +502,7 @@ See also [constant PROPERTY_HINT_LAYERS_3D_PHYSICS]. [codeblock] @export_flags_3d_physics var physics_layers: int + @export_flags_3d_physics var physics_layers_array: Array[int] [/codeblock] </description> </annotation> @@ -480,6 +513,7 @@ See also [constant PROPERTY_HINT_LAYERS_3D_RENDER]. [codeblock] @export_flags_3d_render var render_layers: int + @export_flags_3d_render var render_layers_array: Array[int] [/codeblock] </description> </annotation> @@ -490,16 +524,18 @@ See also [constant PROPERTY_HINT_LAYERS_AVOIDANCE]. [codeblock] @export_flags_avoidance var avoidance_layers: int + @export_flags_avoidance var avoidance_layers_array: Array[int] [/codeblock] </description> </annotation> <annotation name="@export_global_dir"> <return type="void" /> <description> - Export a [String] property as an absolute path to a directory. The path can be picked from the entire filesystem. See [annotation @export_dir] to limit it to the project folder and its subfolders. + Export a [String], [Array][lb][String][rb], or [PackedStringArray] property as an absolute path to a directory. The path can be picked from the entire filesystem. See [annotation @export_dir] to limit it to the project folder and its subfolders. See also [constant PROPERTY_HINT_GLOBAL_DIR]. [codeblock] @export_global_dir var sprite_folder_path: String + @export_global_dir var sprite_folder_paths: Array[String] [/codeblock] </description> </annotation> @@ -507,12 +543,13 @@ <return type="void" /> <param index="0" name="filter" type="String" default="""" /> <description> - Export a [String] property as an absolute path to a file. The path can be picked from the entire filesystem. See [annotation @export_file] to limit it to the project folder and its subfolders. + Export a [String], [Array][lb][String][rb], or [PackedStringArray] property as an absolute path to a file. The path can be picked from the entire filesystem. See [annotation @export_file] to limit it to the project folder and its subfolders. If [param filter] is provided, only matching files will be available for picking. See also [constant PROPERTY_HINT_GLOBAL_FILE]. [codeblock] @export_global_file var sound_effect_path: String @export_global_file("*.txt") var notes_path: String + @export_global_file var multiple_paths: Array[String] [/codeblock] </description> </annotation> @@ -542,10 +579,11 @@ <annotation name="@export_multiline"> <return type="void" /> <description> - Export a [String] property with a large [TextEdit] widget instead of a [LineEdit]. This adds support for multiline content and makes it easier to edit large amount of text stored in the property. + Export a [String], [Array][lb][String][rb], [PackedStringArray], [Dictionary] or [Array][lb][Dictionary][rb] property with a large [TextEdit] widget instead of a [LineEdit]. This adds support for multiline content and makes it easier to edit large amount of text stored in the property. See also [constant PROPERTY_HINT_MULTILINE_TEXT]. [codeblock] @export_multiline var character_biography + @export_multiline var npc_dialogs: Array[String] [/codeblock] </description> </annotation> @@ -553,10 +591,11 @@ <return type="void" /> <param index="0" name="type" type="String" default="""" /> <description> - Export a [NodePath] property with a filter for allowed node types. + Export a [NodePath] or [Array][lb][NodePath][rb] property with a filter for allowed node types. See also [constant PROPERTY_HINT_NODE_PATH_VALID_TYPES]. [codeblock] @export_node_path("Button", "TouchScreenButton") var some_button + @export_node_path("Button", "TouchScreenButton") var many_buttons: Array[NodePath] [/codeblock] [b]Note:[/b] The type must be a native class or a globally registered script (using the [code]class_name[/code] keyword) that inherits [Node]. </description> @@ -565,10 +604,11 @@ <return type="void" /> <param index="0" name="placeholder" type="String" /> <description> - Export a [String] property with a placeholder text displayed in the editor widget when no value is present. + Export a [String], [Array][lb][String][rb], or [PackedStringArray] property with a placeholder text displayed in the editor widget when no value is present. See also [constant PROPERTY_HINT_PLACEHOLDER_TEXT]. [codeblock] @export_placeholder("Name in lowercase") var character_id: String + @export_placeholder("Name in lowercase") var friend_ids: Array[String] [/codeblock] </description> </annotation> @@ -579,7 +619,7 @@ <param index="2" name="step" type="float" default="1.0" /> <param index="3" name="extra_hints" type="String" default="""" /> <description> - Export an [int] or [float] property as a range value. The range must be defined by [param min] and [param max], as well as an optional [param step] and a variety of extra hints. The [param step] defaults to [code]1[/code] for integer properties. For floating-point numbers this value depends on your [member EditorSettings.interface/inspector/default_float_step] setting. + Export an [int], [float], [Array][lb][int][rb], [Array][lb][float][rb], [PackedByteArray], [PackedInt32Array], [PackedInt64Array], [PackedFloat32Array], or [PackedFloat64Array] property as a range value. The range must be defined by [param min] and [param max], as well as an optional [param step] and a variety of extra hints. The [param step] defaults to [code]1[/code] for integer properties. For floating-point numbers this value depends on your [member EditorSettings.interface/inspector/default_float_step] setting. If hints [code]"or_greater"[/code] and [code]"or_less"[/code] are provided, the editor widget will not cap the value at range boundaries. The [code]"exp"[/code] hint will make the edited values on range to change exponentially. The [code]"hide_slider"[/code] hint will hide the slider element of the editor widget. Hints also allow to indicate the units for the edited value. Using [code]"radians_as_degrees"[/code] you can specify that the actual value is in radians, but should be displayed in degrees in the Inspector dock (the range values are also in degrees). [code]"degrees"[/code] allows to add a degree sign as a unit suffix (the value is unchanged). Finally, a custom suffix can be provided using [code]"suffix:unit"[/code], where "unit" can be any string. See also [constant PROPERTY_HINT_RANGE]. @@ -587,6 +627,7 @@ @export_range(0, 20) var number @export_range(-10, 20) var number @export_range(-10, 20, 0.2) var number: float + @export_range(0, 20) var numbers: Array[float] @export_range(0, 100, 1, "or_greater") var power_percent @export_range(0, 100, 1, "or_greater", "or_less") var health_delta @@ -678,6 +719,8 @@ <return type="void" /> <description> Make a script with static variables to not persist after all references are lost. If the script is loaded again the static variables will revert to their default values. + [b]Note:[/b] As annotations describe their subject, the [annotation @static_unload] annotation must be placed before the class definition and inheritance. + [b]Warning:[/b] Currently, due to a bug, scripts are never freed, even if [annotation @static_unload] annotation is used. </description> </annotation> <annotation name="@tool"> |