|
@@ -4,7 +4,7 @@
|
|
Built-in GDScript functions.
|
|
Built-in GDScript functions.
|
|
</brief_description>
|
|
</brief_description>
|
|
<description>
|
|
<description>
|
|
- A list of GDScript-specific utility functions accessed in any script.
|
|
|
|
|
|
+ A list of GDScript-specific utility functions and annotations accessible from any script.
|
|
For the list of the global functions and constants see [@GlobalScope].
|
|
For the list of the global functions and constants see [@GlobalScope].
|
|
</description>
|
|
</description>
|
|
<tutorials>
|
|
<tutorials>
|
|
@@ -20,7 +20,7 @@
|
|
<description>
|
|
<description>
|
|
Returns a [Color] constructed from red ([param r8]), green ([param g8]), blue ([param b8]), and optionally alpha ([param a8]) integer channels, each divided by [code]255.0[/code] for their final value.
|
|
Returns a [Color] constructed from red ([param r8]), green ([param g8]), blue ([param b8]), and optionally alpha ([param a8]) integer channels, each divided by [code]255.0[/code] for their final value.
|
|
[codeblock]
|
|
[codeblock]
|
|
- var red = Color8(255, 0, 0) # Same as Color(1, 0, 0)
|
|
|
|
|
|
+ var red = Color8(255, 0, 0) # Same as Color(1, 0, 0).
|
|
var dark_blue = Color8(0, 0, 51) # Same as Color(0, 0, 0.2).
|
|
var dark_blue = Color8(0, 0, 51) # Same as Color(0, 0, 0.2).
|
|
var my_color = Color8(306, 255, 0, 102) # Same as Color(1.2, 1, 0, 0.4).
|
|
var my_color = Color8(306, 255, 0, 102) # Same as Color(1.2, 1, 0, 0.4).
|
|
[/codeblock]
|
|
[/codeblock]
|
|
@@ -37,10 +37,10 @@
|
|
[codeblock]
|
|
[codeblock]
|
|
# Imagine we always want speed to be between 0 and 20.
|
|
# Imagine we always want speed to be between 0 and 20.
|
|
var speed = -10
|
|
var speed = -10
|
|
- assert(speed < 20) # True, the program will continue
|
|
|
|
- assert(speed >= 0) # False, the program will stop
|
|
|
|
- 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
|
|
|
|
|
|
+ assert(speed < 20) # True, the program will continue.
|
|
|
|
+ assert(speed >= 0) # False, the program will stop.
|
|
|
|
+ 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]
|
|
[/codeblock]
|
|
</description>
|
|
</description>
|
|
</method>
|
|
</method>
|
|
@@ -140,7 +140,7 @@
|
|
<param index="0" name="path" type="String" />
|
|
<param index="0" name="path" type="String" />
|
|
<description>
|
|
<description>
|
|
Returns a [Resource] from the filesystem located at the absolute [param path]. Unless it's already referenced elsewhere (such as in another script or in the scene), the resource is loaded from disk on function call, which might cause a slight delay, especially when loading large scenes. To avoid unnecessary delays when loading something multiple times, either store the resource in a variable or use [method preload].
|
|
Returns a [Resource] from the filesystem located at the absolute [param path]. Unless it's already referenced elsewhere (such as in another script or in the scene), the resource is loaded from disk on function call, which might cause a slight delay, especially when loading large scenes. To avoid unnecessary delays when loading something multiple times, either store the resource in a variable or use [method preload].
|
|
- [b]Note:[/b] Resource paths can be obtained by right-clicking on a resource in the FileSystem dock and choosing "Copy Path" or by dragging the file from the FileSystem dock into the script.
|
|
|
|
|
|
+ [b]Note:[/b] Resource paths can be obtained by right-clicking on a resource in the FileSystem dock and choosing "Copy Path", or by dragging the file from the FileSystem dock into the current script.
|
|
[codeblock]
|
|
[codeblock]
|
|
# Load a scene called "main" located in the root of the project directory and cache it in a variable.
|
|
# Load a scene called "main" located in the root of the project directory and cache it in a variable.
|
|
var main = load("res://main.tscn") # main will contain a PackedScene resource.
|
|
var main = load("res://main.tscn") # main will contain a PackedScene resource.
|
|
@@ -155,7 +155,7 @@
|
|
<param index="0" name="path" type="String" />
|
|
<param index="0" name="path" type="String" />
|
|
<description>
|
|
<description>
|
|
Returns a [Resource] from the filesystem located at [param path]. During run-time, the resource is loaded when the script is being parsed. This function effectively acts as a reference to that resource. Note that this function requires [param path] to be a constant [String]. If you want to load a resource from a dynamic/variable path, use [method load].
|
|
Returns a [Resource] from the filesystem located at [param path]. During run-time, the resource is loaded when the script is being parsed. This function effectively acts as a reference to that resource. Note that this function requires [param path] to be a constant [String]. If you want to load a resource from a dynamic/variable path, use [method load].
|
|
- [b]Note:[/b] Resource paths can be obtained by right clicking on a resource in the Assets Panel and choosing "Copy Path" or by dragging the file from the FileSystem dock into the script.
|
|
|
|
|
|
+ [b]Note:[/b] Resource paths can be obtained by right-clicking on a resource in the Assets Panel and choosing "Copy Path", or by dragging the file from the FileSystem dock into the current script.
|
|
[codeblock]
|
|
[codeblock]
|
|
# Create instance of a scene.
|
|
# Create instance of a scene.
|
|
var diamond = preload("res://diamond.tscn").instantiate()
|
|
var diamond = preload("res://diamond.tscn").instantiate()
|
|
@@ -259,10 +259,12 @@
|
|
<annotation name="@export">
|
|
<annotation name="@export">
|
|
<return type="void" />
|
|
<return type="void" />
|
|
<description>
|
|
<description>
|
|
- Mark the following property as exported (editable in the Inspector dock and saved to disk). To control the type of the exported property use the type hint notation.
|
|
|
|
|
|
+ Mark the following property as exported (editable in the Inspector dock and saved to disk). To control the type of the exported property, use the type hint notation.
|
|
[codeblock]
|
|
[codeblock]
|
|
|
|
+ @export var string = ""
|
|
@export var int_number = 5
|
|
@export var int_number = 5
|
|
@export var float_number: float = 5
|
|
@export var float_number: float = 5
|
|
|
|
+ @export var image : Image
|
|
[/codeblock]
|
|
[/codeblock]
|
|
</description>
|
|
</description>
|
|
</annotation>
|
|
</annotation>
|
|
@@ -273,20 +275,20 @@
|
|
Define a new category for the following exported properties. This helps to organize properties in the Inspector dock.
|
|
Define a new category for the following exported properties. This helps to organize properties in the Inspector dock.
|
|
See also [constant PROPERTY_USAGE_CATEGORY].
|
|
See also [constant PROPERTY_USAGE_CATEGORY].
|
|
[codeblock]
|
|
[codeblock]
|
|
- @export_category("My Properties")
|
|
|
|
- @export var number = 3
|
|
|
|
- @export var string = ""
|
|
|
|
|
|
+ @export_category("Statistics")
|
|
|
|
+ @export var hp = 30
|
|
|
|
+ @export var speed = 1.25
|
|
[/codeblock]
|
|
[/codeblock]
|
|
- [b]Note:[/b] Categories in the property list are supposed to indicate different base types, so the use of this annotation is not encouraged. See [annotation @export_group] and [annotation @export_subgroup] instead.
|
|
|
|
|
|
+ [b]Note:[/b] Categories in the Inspector dock's list usually divide properties coming from different classes (Node, Node2D, Sprite, etc.). For better clarity, it's recommended to use [annotation @export_group] and [annotation @export_subgroup], instead.
|
|
</description>
|
|
</description>
|
|
</annotation>
|
|
</annotation>
|
|
<annotation name="@export_color_no_alpha">
|
|
<annotation name="@export_color_no_alpha">
|
|
<return type="void" />
|
|
<return type="void" />
|
|
<description>
|
|
<description>
|
|
- Export a [Color] property without transparency (its alpha fixed as [code]1.0[/code]).
|
|
|
|
|
|
+ Export a [Color] property without allowing its transparency ([member Color.a]) to be edited.
|
|
See also [constant PROPERTY_HINT_COLOR_NO_ALPHA].
|
|
See also [constant PROPERTY_HINT_COLOR_NO_ALPHA].
|
|
[codeblock]
|
|
[codeblock]
|
|
- @export_color_no_alpha var modulate_color: Color
|
|
|
|
|
|
+ @export_color_no_alpha var dye_color : Color
|
|
[/codeblock]
|
|
[/codeblock]
|
|
</description>
|
|
</description>
|
|
</annotation>
|
|
</annotation>
|
|
@@ -296,7 +298,7 @@
|
|
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] 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].
|
|
See also [constant PROPERTY_HINT_DIR].
|
|
[codeblock]
|
|
[codeblock]
|
|
- @export_dir var sprite_folder: String
|
|
|
|
|
|
+ @export_dir var sprite_folder_path: String
|
|
[/codeblock]
|
|
[/codeblock]
|
|
</description>
|
|
</description>
|
|
</annotation>
|
|
</annotation>
|
|
@@ -343,8 +345,8 @@
|
|
If [param filter] is provided, only matching files will be available for picking.
|
|
If [param filter] is provided, only matching files will be available for picking.
|
|
See also [constant PROPERTY_HINT_FILE].
|
|
See also [constant PROPERTY_HINT_FILE].
|
|
[codeblock]
|
|
[codeblock]
|
|
- @export_file var sound_effect_file: String
|
|
|
|
- @export_file("*.txt") var notes_file: String
|
|
|
|
|
|
+ @export_file var sound_effect_path: String
|
|
|
|
+ @export_file("*.txt") var notes_path: String
|
|
[/codeblock]
|
|
[/codeblock]
|
|
</description>
|
|
</description>
|
|
</annotation>
|
|
</annotation>
|
|
@@ -436,10 +438,10 @@
|
|
<annotation name="@export_global_dir">
|
|
<annotation name="@export_global_dir">
|
|
<return type="void" />
|
|
<return type="void" />
|
|
<description>
|
|
<description>
|
|
- Export a [String] property as a 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] 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].
|
|
See also [constant PROPERTY_HINT_GLOBAL_DIR].
|
|
[codeblock]
|
|
[codeblock]
|
|
- @export_global_dir var sprite_folder: String
|
|
|
|
|
|
+ @export_global_dir var sprite_folder_path: String
|
|
[/codeblock]
|
|
[/codeblock]
|
|
</description>
|
|
</description>
|
|
</annotation>
|
|
</annotation>
|
|
@@ -447,12 +449,12 @@
|
|
<return type="void" />
|
|
<return type="void" />
|
|
<param index="0" name="filter" type="String" default="""" />
|
|
<param index="0" name="filter" type="String" default="""" />
|
|
<description>
|
|
<description>
|
|
- Export a [String] property as a 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] 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.
|
|
If [param filter] is provided, only matching files will be available for picking.
|
|
See also [constant PROPERTY_HINT_GLOBAL_FILE].
|
|
See also [constant PROPERTY_HINT_GLOBAL_FILE].
|
|
[codeblock]
|
|
[codeblock]
|
|
- @export_global_file var sound_effect_file: String
|
|
|
|
- @export_global_file("*.txt") var notes_file: String
|
|
|
|
|
|
+ @export_global_file var sound_effect_path: String
|
|
|
|
+ @export_global_file("*.txt") var notes_path: String
|
|
[/codeblock]
|
|
[/codeblock]
|
|
</description>
|
|
</description>
|
|
</annotation>
|
|
</annotation>
|
|
@@ -466,13 +468,13 @@
|
|
Groups cannot be nested, use [annotation @export_subgroup] to add subgroups within groups.
|
|
Groups cannot be nested, use [annotation @export_subgroup] to add subgroups within groups.
|
|
See also [constant PROPERTY_USAGE_GROUP].
|
|
See also [constant PROPERTY_USAGE_GROUP].
|
|
[codeblock]
|
|
[codeblock]
|
|
- @export_group("My Properties")
|
|
|
|
- @export var number = 3
|
|
|
|
- @export var string = ""
|
|
|
|
|
|
+ @export_group("Racer Properties")
|
|
|
|
+ @export var nickname = "Nick"
|
|
|
|
+ @export var age = 26
|
|
|
|
|
|
- @export_group("Prefixed Properties", "prefix_")
|
|
|
|
- @export var prefix_number = 3
|
|
|
|
- @export var prefix_string = ""
|
|
|
|
|
|
+ @export_group("Car Properties", "car_")
|
|
|
|
+ @export var car_label = "Speedy"
|
|
|
|
+ @export var car_number = 3
|
|
|
|
|
|
@export_group("", "")
|
|
@export_group("", "")
|
|
@export var ungrouped_number = 3
|
|
@export var ungrouped_number = 3
|
|
@@ -544,13 +546,13 @@
|
|
Define a new subgroup for the following exported properties. This helps to organize properties in the Inspector dock. Subgroups work exactly like groups, except they need a parent group to exist. See [annotation @export_group].
|
|
Define a new subgroup for the following exported properties. This helps to organize properties in the Inspector dock. Subgroups work exactly like groups, except they need a parent group to exist. See [annotation @export_group].
|
|
See also [constant PROPERTY_USAGE_SUBGROUP].
|
|
See also [constant PROPERTY_USAGE_SUBGROUP].
|
|
[codeblock]
|
|
[codeblock]
|
|
- @export_group("My Properties")
|
|
|
|
- @export var number = 3
|
|
|
|
- @export var string = ""
|
|
|
|
|
|
+ @export_group("Racer Properties")
|
|
|
|
+ @export var nickname = "Nick"
|
|
|
|
+ @export var age = 26
|
|
|
|
|
|
- @export_subgroup("My Prefixed Properties", "prefix_")
|
|
|
|
- @export var prefix_number = 3
|
|
|
|
- @export var prefix_string = ""
|
|
|
|
|
|
+ @export_subgroup("Car Properties", "car_")
|
|
|
|
+ @export var car_label = "Speedy"
|
|
|
|
+ @export var car_number = 3
|
|
[/codeblock]
|
|
[/codeblock]
|
|
[b]Note:[/b] Subgroups cannot be nested, they only provide one extra level of depth. Just like the next group ends the previous group, so do the subsequent subgroups.
|
|
[b]Note:[/b] Subgroups cannot be nested, they only provide one extra level of depth. Just like the next group ends the previous group, so do the subsequent subgroups.
|
|
</description>
|
|
</description>
|
|
@@ -571,7 +573,7 @@
|
|
<annotation name="@onready">
|
|
<annotation name="@onready">
|
|
<return type="void" />
|
|
<return type="void" />
|
|
<description>
|
|
<description>
|
|
- Mark the following property as assigned on [Node]'s ready state change. Values for these properties are not assigned immediately upon the node's creation, and instead are computed and stored right before [method Node._ready].
|
|
|
|
|
|
+ Mark the following property as assigned when the [Node] is ready. Values for these properties are not assigned immediately when the node is initialized ([method Object._init]), and instead are computed and stored right before [method Node._ready].
|
|
[codeblock]
|
|
[codeblock]
|
|
@onready var character_name: Label = $Label
|
|
@onready var character_name: Label = $Label
|
|
[/codeblock]
|
|
[/codeblock]
|