|
@@ -240,6 +240,8 @@ Returns a 32 bit color with red, green, blue and alpha channels. Each channel ha
|
|
|
|
|
|
red = Color8(255, 0, 0)
|
|
red = Color8(255, 0, 0)
|
|
|
|
|
|
|
|
+----
|
|
|
|
+
|
|
.. _class_@GDScript_method_ColorN:
|
|
.. _class_@GDScript_method_ColorN:
|
|
|
|
|
|
- :ref:`Color<class_Color>` **ColorN** **(** :ref:`String<class_String>` name, :ref:`float<class_float>` alpha=1.0 **)**
|
|
- :ref:`Color<class_Color>` **ColorN** **(** :ref:`String<class_String>` name, :ref:`float<class_float>` alpha=1.0 **)**
|
|
@@ -254,6 +256,8 @@ 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".
|
|
"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".
|
|
|
|
|
|
|
|
+----
|
|
|
|
+
|
|
.. _class_@GDScript_method_abs:
|
|
.. _class_@GDScript_method_abs:
|
|
|
|
|
|
- :ref:`float<class_float>` **abs** **(** :ref:`float<class_float>` s **)**
|
|
- :ref:`float<class_float>` **abs** **(** :ref:`float<class_float>` s **)**
|
|
@@ -265,6 +269,8 @@ Returns the absolute value of parameter ``s`` (i.e. unsigned value, works for in
|
|
# a is 1
|
|
# a is 1
|
|
a = abs(-1)
|
|
a = abs(-1)
|
|
|
|
|
|
|
|
+----
|
|
|
|
+
|
|
.. _class_@GDScript_method_acos:
|
|
.. _class_@GDScript_method_acos:
|
|
|
|
|
|
- :ref:`float<class_float>` **acos** **(** :ref:`float<class_float>` s **)**
|
|
- :ref:`float<class_float>` **acos** **(** :ref:`float<class_float>` s **)**
|
|
@@ -276,6 +282,8 @@ Returns the arc cosine of ``s`` in radians. Use to get the angle of cosine ``s``
|
|
# c is 0.523599 or 30 degrees if converted with rad2deg(s)
|
|
# c is 0.523599 or 30 degrees if converted with rad2deg(s)
|
|
c = acos(0.866025)
|
|
c = acos(0.866025)
|
|
|
|
|
|
|
|
+----
|
|
|
|
+
|
|
.. _class_@GDScript_method_asin:
|
|
.. _class_@GDScript_method_asin:
|
|
|
|
|
|
- :ref:`float<class_float>` **asin** **(** :ref:`float<class_float>` s **)**
|
|
- :ref:`float<class_float>` **asin** **(** :ref:`float<class_float>` s **)**
|
|
@@ -287,6 +295,8 @@ Returns the arc sine of ``s`` in radians. Use to get the angle of sine ``s``.
|
|
# s is 0.523599 or 30 degrees if converted with rad2deg(s)
|
|
# s is 0.523599 or 30 degrees if converted with rad2deg(s)
|
|
s = asin(0.5)
|
|
s = asin(0.5)
|
|
|
|
|
|
|
|
+----
|
|
|
|
+
|
|
.. _class_@GDScript_method_assert:
|
|
.. _class_@GDScript_method_assert:
|
|
|
|
|
|
- void **assert** **(** :ref:`bool<class_bool>` condition **)**
|
|
- void **assert** **(** :ref:`bool<class_bool>` condition **)**
|
|
@@ -301,6 +311,8 @@ Asserts that the ``condition`` is ``true`` . If the ``condition`` is ``false``,
|
|
assert(speed >= 0) # False, the program will stop
|
|
assert(speed >= 0) # False, the program will stop
|
|
assert(speed >= 0 && speed < 20) # You can also combine the two conditional statements in one check
|
|
assert(speed >= 0 && speed < 20) # You can also combine the two conditional statements in one check
|
|
|
|
|
|
|
|
+----
|
|
|
|
+
|
|
.. _class_@GDScript_method_atan:
|
|
.. _class_@GDScript_method_atan:
|
|
|
|
|
|
- :ref:`float<class_float>` **atan** **(** :ref:`float<class_float>` s **)**
|
|
- :ref:`float<class_float>` **atan** **(** :ref:`float<class_float>` s **)**
|
|
@@ -313,6 +325,8 @@ The method cannot know in which quadrant the angle should fall. See :ref:`atan2<
|
|
|
|
|
|
a = atan(0.5) # a is 0.463648
|
|
a = atan(0.5) # a is 0.463648
|
|
|
|
|
|
|
|
+----
|
|
|
|
+
|
|
.. _class_@GDScript_method_atan2:
|
|
.. _class_@GDScript_method_atan2:
|
|
|
|
|
|
- :ref:`float<class_float>` **atan2** **(** :ref:`float<class_float>` y, :ref:`float<class_float>` x **)**
|
|
- :ref:`float<class_float>` **atan2** **(** :ref:`float<class_float>` y, :ref:`float<class_float>` x **)**
|
|
@@ -323,6 +337,8 @@ Returns the arc tangent of ``y/x`` in radians. Use to get the angle of tangent `
|
|
|
|
|
|
a = atan2(0, -1) # a is 3.141593
|
|
a = atan2(0, -1) # a is 3.141593
|
|
|
|
|
|
|
|
+----
|
|
|
|
+
|
|
.. _class_@GDScript_method_bytes2var:
|
|
.. _class_@GDScript_method_bytes2var:
|
|
|
|
|
|
- :ref:`Variant<class_Variant>` **bytes2var** **(** :ref:`PoolByteArray<class_PoolByteArray>` bytes, :ref:`bool<class_bool>` allow_objects=false **)**
|
|
- :ref:`Variant<class_Variant>` **bytes2var** **(** :ref:`PoolByteArray<class_PoolByteArray>` bytes, :ref:`bool<class_bool>` allow_objects=false **)**
|
|
@@ -331,12 +347,16 @@ Decodes a byte array back to a value. When ``allow_objects`` is ``true`` decodin
|
|
|
|
|
|
**WARNING:** Deserialized object can contain code which gets executed. Do not use this option if the serialized object comes from untrusted sources to avoid potential security threats (remote code execution).
|
|
**WARNING:** Deserialized object can contain code which gets executed. Do not use this option if the serialized object comes from untrusted sources to avoid potential security threats (remote code execution).
|
|
|
|
|
|
|
|
+----
|
|
|
|
+
|
|
.. _class_@GDScript_method_cartesian2polar:
|
|
.. _class_@GDScript_method_cartesian2polar:
|
|
|
|
|
|
- :ref:`Vector2<class_Vector2>` **cartesian2polar** **(** :ref:`float<class_float>` x, :ref:`float<class_float>` y **)**
|
|
- :ref:`Vector2<class_Vector2>` **cartesian2polar** **(** :ref:`float<class_float>` x, :ref:`float<class_float>` y **)**
|
|
|
|
|
|
Converts a 2D point expressed in the cartesian coordinate system (x and y axis) to the polar coordinate system (a distance from the origin and an angle).
|
|
Converts a 2D point expressed in the cartesian coordinate system (x and y axis) to the polar coordinate system (a distance from the origin and an angle).
|
|
|
|
|
|
|
|
+----
|
|
|
|
+
|
|
.. _class_@GDScript_method_ceil:
|
|
.. _class_@GDScript_method_ceil:
|
|
|
|
|
|
- :ref:`float<class_float>` **ceil** **(** :ref:`float<class_float>` s **)**
|
|
- :ref:`float<class_float>` **ceil** **(** :ref:`float<class_float>` s **)**
|
|
@@ -348,6 +368,8 @@ Rounds ``s`` upward, returning the smallest integral value that is not less than
|
|
i = ceil(1.45) # i is 2
|
|
i = ceil(1.45) # i is 2
|
|
i = ceil(1.001) # i is 2
|
|
i = ceil(1.001) # i is 2
|
|
|
|
|
|
|
|
+----
|
|
|
|
+
|
|
.. _class_@GDScript_method_char:
|
|
.. _class_@GDScript_method_char:
|
|
|
|
|
|
- :ref:`String<class_String>` **char** **(** :ref:`int<class_int>` ascii **)**
|
|
- :ref:`String<class_String>` **char** **(** :ref:`int<class_int>` ascii **)**
|
|
@@ -361,6 +383,8 @@ Returns a character as a String of the given ASCII code.
|
|
# a is 'a'
|
|
# a is 'a'
|
|
a = char(65 + 32)
|
|
a = char(65 + 32)
|
|
|
|
|
|
|
|
+----
|
|
|
|
+
|
|
.. _class_@GDScript_method_clamp:
|
|
.. _class_@GDScript_method_clamp:
|
|
|
|
|
|
- :ref:`float<class_float>` **clamp** **(** :ref:`float<class_float>` value, :ref:`float<class_float>` min, :ref:`float<class_float>` max **)**
|
|
- :ref:`float<class_float>` **clamp** **(** :ref:`float<class_float>` value, :ref:`float<class_float>` min, :ref:`float<class_float>` max **)**
|
|
@@ -377,6 +401,8 @@ Clamps ``value`` and returns a value not less than ``min`` and not more than ``m
|
|
# a is 1
|
|
# a is 1
|
|
a = clamp(speed, 1, 20)
|
|
a = clamp(speed, 1, 20)
|
|
|
|
|
|
|
|
+----
|
|
|
|
+
|
|
.. _class_@GDScript_method_convert:
|
|
.. _class_@GDScript_method_convert:
|
|
|
|
|
|
- :ref:`Variant<class_Variant>` **convert** **(** :ref:`Variant<class_Variant>` what, :ref:`int<class_int>` type **)**
|
|
- :ref:`Variant<class_Variant>` **convert** **(** :ref:`Variant<class_Variant>` what, :ref:`int<class_int>` type **)**
|
|
@@ -393,6 +419,8 @@ Converts from a type to another in the best way possible. The ``type`` parameter
|
|
# (1, 0) is 6 characters
|
|
# (1, 0) is 6 characters
|
|
print(a.length())
|
|
print(a.length())
|
|
|
|
|
|
|
|
+----
|
|
|
|
+
|
|
.. _class_@GDScript_method_cos:
|
|
.. _class_@GDScript_method_cos:
|
|
|
|
|
|
- :ref:`float<class_float>` **cos** **(** :ref:`float<class_float>` s **)**
|
|
- :ref:`float<class_float>` **cos** **(** :ref:`float<class_float>` s **)**
|
|
@@ -405,6 +433,8 @@ Returns the cosine of angle ``s`` in radians.
|
|
print(cos(PI * 2))
|
|
print(cos(PI * 2))
|
|
print(cos(PI))
|
|
print(cos(PI))
|
|
|
|
|
|
|
|
+----
|
|
|
|
+
|
|
.. _class_@GDScript_method_cosh:
|
|
.. _class_@GDScript_method_cosh:
|
|
|
|
|
|
- :ref:`float<class_float>` **cosh** **(** :ref:`float<class_float>` s **)**
|
|
- :ref:`float<class_float>` **cosh** **(** :ref:`float<class_float>` s **)**
|
|
@@ -416,12 +446,16 @@ Returns the hyperbolic cosine of ``s`` in radians.
|
|
# prints 1.543081
|
|
# prints 1.543081
|
|
print(cosh(1))
|
|
print(cosh(1))
|
|
|
|
|
|
|
|
+----
|
|
|
|
+
|
|
.. _class_@GDScript_method_db2linear:
|
|
.. _class_@GDScript_method_db2linear:
|
|
|
|
|
|
- :ref:`float<class_float>` **db2linear** **(** :ref:`float<class_float>` db **)**
|
|
- :ref:`float<class_float>` **db2linear** **(** :ref:`float<class_float>` db **)**
|
|
|
|
|
|
Converts from decibels to linear energy (audio).
|
|
Converts from decibels to linear energy (audio).
|
|
|
|
|
|
|
|
+----
|
|
|
|
+
|
|
.. _class_@GDScript_method_decimals:
|
|
.. _class_@GDScript_method_decimals:
|
|
|
|
|
|
- :ref:`float<class_float>` **decimals** **(** :ref:`float<class_float>` step **)**
|
|
- :ref:`float<class_float>` **decimals** **(** :ref:`float<class_float>` step **)**
|
|
@@ -433,6 +467,8 @@ Returns the position of the first non-zero digit, after the decimal point.
|
|
# n is 2
|
|
# n is 2
|
|
n = decimals(0.035)
|
|
n = decimals(0.035)
|
|
|
|
|
|
|
|
+----
|
|
|
|
+
|
|
.. _class_@GDScript_method_dectime:
|
|
.. _class_@GDScript_method_dectime:
|
|
|
|
|
|
- :ref:`float<class_float>` **dectime** **(** :ref:`float<class_float>` value, :ref:`float<class_float>` amount, :ref:`float<class_float>` step **)**
|
|
- :ref:`float<class_float>` **dectime** **(** :ref:`float<class_float>` value, :ref:`float<class_float>` amount, :ref:`float<class_float>` step **)**
|
|
@@ -444,6 +480,8 @@ Returns the result of ``value`` decreased by ``step`` \* ``amount``.
|
|
# a = 59
|
|
# a = 59
|
|
a = dectime(60, 10, 0.1))
|
|
a = dectime(60, 10, 0.1))
|
|
|
|
|
|
|
|
+----
|
|
|
|
+
|
|
.. _class_@GDScript_method_deg2rad:
|
|
.. _class_@GDScript_method_deg2rad:
|
|
|
|
|
|
- :ref:`float<class_float>` **deg2rad** **(** :ref:`float<class_float>` deg **)**
|
|
- :ref:`float<class_float>` **deg2rad** **(** :ref:`float<class_float>` deg **)**
|
|
@@ -455,18 +493,24 @@ Returns degrees converted to radians.
|
|
# r is 3.141593
|
|
# r is 3.141593
|
|
r = deg2rad(180)
|
|
r = deg2rad(180)
|
|
|
|
|
|
|
|
+----
|
|
|
|
+
|
|
.. _class_@GDScript_method_dict2inst:
|
|
.. _class_@GDScript_method_dict2inst:
|
|
|
|
|
|
- :ref:`Object<class_Object>` **dict2inst** **(** :ref:`Dictionary<class_Dictionary>` dict **)**
|
|
- :ref:`Object<class_Object>` **dict2inst** **(** :ref:`Dictionary<class_Dictionary>` dict **)**
|
|
|
|
|
|
Converts a previously converted instance to a dictionary, back into an instance. Useful for deserializing.
|
|
Converts a previously converted instance to a dictionary, back into an instance. Useful for deserializing.
|
|
|
|
|
|
|
|
+----
|
|
|
|
+
|
|
.. _class_@GDScript_method_ease:
|
|
.. _class_@GDScript_method_ease:
|
|
|
|
|
|
- :ref:`float<class_float>` **ease** **(** :ref:`float<class_float>` s, :ref:`float<class_float>` curve **)**
|
|
- :ref:`float<class_float>` **ease** **(** :ref:`float<class_float>` s, :ref:`float<class_float>` curve **)**
|
|
|
|
|
|
Easing function, based on exponent. 0 is constant, 1 is linear, 0 to 1 is ease-in, 1+ is ease out. Negative values are in-out/out in.
|
|
Easing function, based on exponent. 0 is constant, 1 is linear, 0 to 1 is ease-in, 1+ is ease out. Negative values are in-out/out in.
|
|
|
|
|
|
|
|
+----
|
|
|
|
+
|
|
.. _class_@GDScript_method_exp:
|
|
.. _class_@GDScript_method_exp:
|
|
|
|
|
|
- :ref:`float<class_float>` **exp** **(** :ref:`float<class_float>` s **)**
|
|
- :ref:`float<class_float>` **exp** **(** :ref:`float<class_float>` s **)**
|
|
@@ -475,10 +519,14 @@ The natural exponential function. It raises the mathematical constant **e** to t
|
|
|
|
|
|
**e** has an approximate value of 2.71828.
|
|
**e** has an approximate value of 2.71828.
|
|
|
|
|
|
|
|
+For exponents to other bases use the method :ref:`pow<class_@GDScript_method_pow>`.
|
|
|
|
+
|
|
::
|
|
::
|
|
|
|
|
|
a = exp(2) # approximately 7.39
|
|
a = exp(2) # approximately 7.39
|
|
|
|
|
|
|
|
+----
|
|
|
|
+
|
|
.. _class_@GDScript_method_floor:
|
|
.. _class_@GDScript_method_floor:
|
|
|
|
|
|
- :ref:`float<class_float>` **floor** **(** :ref:`float<class_float>` s **)**
|
|
- :ref:`float<class_float>` **floor** **(** :ref:`float<class_float>` s **)**
|
|
@@ -492,6 +540,8 @@ Rounds ``s`` to the closest smaller integer and returns it.
|
|
# a is -3
|
|
# a is -3
|
|
a = floor(-2.99)
|
|
a = floor(-2.99)
|
|
|
|
|
|
|
|
+----
|
|
|
|
+
|
|
.. _class_@GDScript_method_fmod:
|
|
.. _class_@GDScript_method_fmod:
|
|
|
|
|
|
- :ref:`float<class_float>` **fmod** **(** :ref:`float<class_float>` x, :ref:`float<class_float>` y **)**
|
|
- :ref:`float<class_float>` **fmod** **(** :ref:`float<class_float>` x, :ref:`float<class_float>` y **)**
|
|
@@ -503,6 +553,8 @@ Returns the floating-point remainder of ``x/y``.
|
|
# remainder is 1.5
|
|
# remainder is 1.5
|
|
var remainder = fmod(7, 5.5)
|
|
var remainder = fmod(7, 5.5)
|
|
|
|
|
|
|
|
+----
|
|
|
|
+
|
|
.. _class_@GDScript_method_fposmod:
|
|
.. _class_@GDScript_method_fposmod:
|
|
|
|
|
|
- :ref:`float<class_float>` **fposmod** **(** :ref:`float<class_float>` x, :ref:`float<class_float>` y **)**
|
|
- :ref:`float<class_float>` **fposmod** **(** :ref:`float<class_float>` x, :ref:`float<class_float>` y **)**
|
|
@@ -531,6 +583,8 @@ Produces:
|
|
-2 8
|
|
-2 8
|
|
-1 9
|
|
-1 9
|
|
|
|
|
|
|
|
+----
|
|
|
|
+
|
|
.. _class_@GDScript_method_funcref:
|
|
.. _class_@GDScript_method_funcref:
|
|
|
|
|
|
- :ref:`FuncRef<class_FuncRef>` **funcref** **(** :ref:`Object<class_Object>` instance, :ref:`String<class_String>` funcname **)**
|
|
- :ref:`FuncRef<class_FuncRef>` **funcref** **(** :ref:`Object<class_Object>` instance, :ref:`String<class_String>` funcname **)**
|
|
@@ -545,6 +599,8 @@ Returns a reference to the specified function ``funcname`` in the ``instance`` n
|
|
a = funcref(self, "foo")
|
|
a = funcref(self, "foo")
|
|
print(a.call_func()) # prints bar
|
|
print(a.call_func()) # prints bar
|
|
|
|
|
|
|
|
+----
|
|
|
|
+
|
|
.. _class_@GDScript_method_get_stack:
|
|
.. _class_@GDScript_method_get_stack:
|
|
|
|
|
|
- :ref:`Array<class_Array>` **get_stack** **(** **)**
|
|
- :ref:`Array<class_Array>` **get_stack** **(** **)**
|
|
@@ -568,6 +624,8 @@ would print
|
|
|
|
|
|
[{function:bar, line:12, source:res://script.gd}, {function:foo, line:9, source:res://script.gd}, {function:_ready, line:6, source:res://script.gd}]
|
|
[{function:bar, line:12, source:res://script.gd}, {function:foo, line:9, source:res://script.gd}, {function:_ready, line:6, source:res://script.gd}]
|
|
|
|
|
|
|
|
+----
|
|
|
|
+
|
|
.. _class_@GDScript_method_hash:
|
|
.. _class_@GDScript_method_hash:
|
|
|
|
|
|
- :ref:`int<class_int>` **hash** **(** :ref:`Variant<class_Variant>` var **)**
|
|
- :ref:`int<class_int>` **hash** **(** :ref:`Variant<class_Variant>` var **)**
|
|
@@ -578,6 +636,8 @@ Returns the integer hash of the variable passed.
|
|
|
|
|
|
print(hash("a")) # prints 177670
|
|
print(hash("a")) # prints 177670
|
|
|
|
|
|
|
|
+----
|
|
|
|
+
|
|
.. _class_@GDScript_method_inst2dict:
|
|
.. _class_@GDScript_method_inst2dict:
|
|
|
|
|
|
- :ref:`Dictionary<class_Dictionary>` **inst2dict** **(** :ref:`Object<class_Object>` inst **)**
|
|
- :ref:`Dictionary<class_Dictionary>` **inst2dict** **(** :ref:`Object<class_Object>` inst **)**
|
|
@@ -599,6 +659,8 @@ Prints out:
|
|
[@subpath, @path, foo]
|
|
[@subpath, @path, foo]
|
|
[, res://test.gd, bar]
|
|
[, res://test.gd, bar]
|
|
|
|
|
|
|
|
+----
|
|
|
|
+
|
|
.. _class_@GDScript_method_instance_from_id:
|
|
.. _class_@GDScript_method_instance_from_id:
|
|
|
|
|
|
- :ref:`Object<class_Object>` **instance_from_id** **(** :ref:`int<class_int>` instance_id **)**
|
|
- :ref:`Object<class_Object>` **instance_from_id** **(** :ref:`int<class_int>` instance_id **)**
|
|
@@ -613,6 +675,8 @@ Returns the Object that corresponds to ``instance_id``. All Objects have a uniqu
|
|
var inst = instance_from_id(id)
|
|
var inst = instance_from_id(id)
|
|
print(inst.foo) # prints bar
|
|
print(inst.foo) # prints bar
|
|
|
|
|
|
|
|
+----
|
|
|
|
+
|
|
.. _class_@GDScript_method_inverse_lerp:
|
|
.. _class_@GDScript_method_inverse_lerp:
|
|
|
|
|
|
- :ref:`float<class_float>` **inverse_lerp** **(** :ref:`float<class_float>` from, :ref:`float<class_float>` to, :ref:`float<class_float>` weight **)**
|
|
- :ref:`float<class_float>` **inverse_lerp** **(** :ref:`float<class_float>` from, :ref:`float<class_float>` to, :ref:`float<class_float>` weight **)**
|
|
@@ -623,24 +687,32 @@ Returns a normalized value considering the given range.
|
|
|
|
|
|
inverse_lerp(3, 5, 4) # returns 0.5
|
|
inverse_lerp(3, 5, 4) # returns 0.5
|
|
|
|
|
|
|
|
+----
|
|
|
|
+
|
|
.. _class_@GDScript_method_is_inf:
|
|
.. _class_@GDScript_method_is_inf:
|
|
|
|
|
|
- :ref:`bool<class_bool>` **is_inf** **(** :ref:`float<class_float>` s **)**
|
|
- :ref:`bool<class_bool>` **is_inf** **(** :ref:`float<class_float>` s **)**
|
|
|
|
|
|
Returns whether ``s`` is an infinity value (either positive infinity or negative infinity).
|
|
Returns whether ``s`` is an infinity value (either positive infinity or negative infinity).
|
|
|
|
|
|
|
|
+----
|
|
|
|
+
|
|
.. _class_@GDScript_method_is_instance_valid:
|
|
.. _class_@GDScript_method_is_instance_valid:
|
|
|
|
|
|
- :ref:`bool<class_bool>` **is_instance_valid** **(** :ref:`Object<class_Object>` instance **)**
|
|
- :ref:`bool<class_bool>` **is_instance_valid** **(** :ref:`Object<class_Object>` instance **)**
|
|
|
|
|
|
Returns whether ``instance`` is a valid object (e.g. has not been deleted from memory).
|
|
Returns whether ``instance`` is a valid object (e.g. has not been deleted from memory).
|
|
|
|
|
|
|
|
+----
|
|
|
|
+
|
|
.. _class_@GDScript_method_is_nan:
|
|
.. _class_@GDScript_method_is_nan:
|
|
|
|
|
|
- :ref:`bool<class_bool>` **is_nan** **(** :ref:`float<class_float>` s **)**
|
|
- :ref:`bool<class_bool>` **is_nan** **(** :ref:`float<class_float>` s **)**
|
|
|
|
|
|
Returns whether ``s`` is a NaN (Not-A-Number) value.
|
|
Returns whether ``s`` is a NaN (Not-A-Number) value.
|
|
|
|
|
|
|
|
+----
|
|
|
|
+
|
|
.. _class_@GDScript_method_len:
|
|
.. _class_@GDScript_method_len:
|
|
|
|
|
|
- :ref:`int<class_int>` **len** **(** :ref:`Variant<class_Variant>` var **)**
|
|
- :ref:`int<class_int>` **len** **(** :ref:`Variant<class_Variant>` var **)**
|
|
@@ -654,6 +726,8 @@ Returns length of Variant ``var``. Length is the character count of String, elem
|
|
a = [1, 2, 3, 4]
|
|
a = [1, 2, 3, 4]
|
|
len(a) # returns 4
|
|
len(a) # returns 4
|
|
|
|
|
|
|
|
+----
|
|
|
|
+
|
|
.. _class_@GDScript_method_lerp:
|
|
.. _class_@GDScript_method_lerp:
|
|
|
|
|
|
- :ref:`Variant<class_Variant>` **lerp** **(** :ref:`Variant<class_Variant>` from, :ref:`Variant<class_Variant>` to, :ref:`float<class_float>` weight **)**
|
|
- :ref:`Variant<class_Variant>` **lerp** **(** :ref:`Variant<class_Variant>` from, :ref:`Variant<class_Variant>` to, :ref:`float<class_float>` weight **)**
|
|
@@ -669,12 +743,16 @@ If both are of the same vector type (:ref:`Vector2<class_Vector2>`, :ref:`Vector
|
|
lerp(0, 4, 0.75) # returns 3.0
|
|
lerp(0, 4, 0.75) # returns 3.0
|
|
lerp(Vector2(1, 5), Vector2(3, 2), 0.5) # returns Vector2(2, 3.5)
|
|
lerp(Vector2(1, 5), Vector2(3, 2), 0.5) # returns Vector2(2, 3.5)
|
|
|
|
|
|
|
|
+----
|
|
|
|
+
|
|
.. _class_@GDScript_method_linear2db:
|
|
.. _class_@GDScript_method_linear2db:
|
|
|
|
|
|
- :ref:`float<class_float>` **linear2db** **(** :ref:`float<class_float>` nrg **)**
|
|
- :ref:`float<class_float>` **linear2db** **(** :ref:`float<class_float>` nrg **)**
|
|
|
|
|
|
Converts from linear energy to decibels (audio).
|
|
Converts from linear energy to decibels (audio).
|
|
|
|
|
|
|
|
+----
|
|
|
|
+
|
|
.. _class_@GDScript_method_load:
|
|
.. _class_@GDScript_method_load:
|
|
|
|
|
|
- :ref:`Resource<class_Resource>` **load** **(** :ref:`String<class_String>` path **)**
|
|
- :ref:`Resource<class_Resource>` **load** **(** :ref:`String<class_String>` path **)**
|
|
@@ -688,6 +766,8 @@ Loads a resource from the filesystem located at ``path``.
|
|
# 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")
|
|
var main = load("res://main.tscn")
|
|
|
|
|
|
|
|
+----
|
|
|
|
+
|
|
.. _class_@GDScript_method_log:
|
|
.. _class_@GDScript_method_log:
|
|
|
|
|
|
- :ref:`float<class_float>` **log** **(** :ref:`float<class_float>` s **)**
|
|
- :ref:`float<class_float>` **log** **(** :ref:`float<class_float>` s **)**
|
|
@@ -700,6 +780,8 @@ Natural logarithm. The amount of time needed to reach a certain level of continu
|
|
|
|
|
|
log(10) # returns 2.302585
|
|
log(10) # returns 2.302585
|
|
|
|
|
|
|
|
+----
|
|
|
|
+
|
|
.. _class_@GDScript_method_max:
|
|
.. _class_@GDScript_method_max:
|
|
|
|
|
|
- :ref:`float<class_float>` **max** **(** :ref:`float<class_float>` a, :ref:`float<class_float>` b **)**
|
|
- :ref:`float<class_float>` **max** **(** :ref:`float<class_float>` a, :ref:`float<class_float>` b **)**
|
|
@@ -711,6 +793,8 @@ Returns the maximum of two values.
|
|
max(1, 2) # returns 2
|
|
max(1, 2) # returns 2
|
|
max(-3.99, -4) # returns -3.99
|
|
max(-3.99, -4) # returns -3.99
|
|
|
|
|
|
|
|
+----
|
|
|
|
+
|
|
.. _class_@GDScript_method_min:
|
|
.. _class_@GDScript_method_min:
|
|
|
|
|
|
- :ref:`float<class_float>` **min** **(** :ref:`float<class_float>` a, :ref:`float<class_float>` b **)**
|
|
- :ref:`float<class_float>` **min** **(** :ref:`float<class_float>` a, :ref:`float<class_float>` b **)**
|
|
@@ -722,6 +806,8 @@ Returns the minimum of two values.
|
|
min(1, 2) # returns 1
|
|
min(1, 2) # returns 1
|
|
min(-3.99, -4) # returns -4
|
|
min(-3.99, -4) # returns -4
|
|
|
|
|
|
|
|
+----
|
|
|
|
+
|
|
.. _class_@GDScript_method_nearest_po2:
|
|
.. _class_@GDScript_method_nearest_po2:
|
|
|
|
|
|
- :ref:`int<class_int>` **nearest_po2** **(** :ref:`int<class_int>` value **)**
|
|
- :ref:`int<class_int>` **nearest_po2** **(** :ref:`int<class_int>` value **)**
|
|
@@ -734,6 +820,8 @@ Returns the nearest larger power of 2 for integer ``value``.
|
|
nearest_po2(4) # returns 4
|
|
nearest_po2(4) # returns 4
|
|
nearest_po2(5) # returns 8
|
|
nearest_po2(5) # returns 8
|
|
|
|
|
|
|
|
+----
|
|
|
|
+
|
|
.. _class_@GDScript_method_parse_json:
|
|
.. _class_@GDScript_method_parse_json:
|
|
|
|
|
|
- :ref:`Variant<class_Variant>` **parse_json** **(** :ref:`String<class_String>` json **)**
|
|
- :ref:`Variant<class_Variant>` **parse_json** **(** :ref:`String<class_String>` json **)**
|
|
@@ -752,12 +840,16 @@ Note that JSON objects do not preserve key order like Godot dictionaries, thus y
|
|
else:
|
|
else:
|
|
print("unexpected results")
|
|
print("unexpected results")
|
|
|
|
|
|
|
|
+----
|
|
|
|
+
|
|
.. _class_@GDScript_method_polar2cartesian:
|
|
.. _class_@GDScript_method_polar2cartesian:
|
|
|
|
|
|
- :ref:`Vector2<class_Vector2>` **polar2cartesian** **(** :ref:`float<class_float>` r, :ref:`float<class_float>` th **)**
|
|
- :ref:`Vector2<class_Vector2>` **polar2cartesian** **(** :ref:`float<class_float>` r, :ref:`float<class_float>` th **)**
|
|
|
|
|
|
Converts a 2D point expressed in the polar coordinate system (a distance from the origin ``r`` and an angle ``th``) to the cartesian coordinate system (x and y axis).
|
|
Converts a 2D point expressed in the polar coordinate system (a distance from the origin ``r`` and an angle ``th``) to the cartesian coordinate system (x and y axis).
|
|
|
|
|
|
|
|
+----
|
|
|
|
+
|
|
.. _class_@GDScript_method_pow:
|
|
.. _class_@GDScript_method_pow:
|
|
|
|
|
|
- :ref:`float<class_float>` **pow** **(** :ref:`float<class_float>` x, :ref:`float<class_float>` y **)**
|
|
- :ref:`float<class_float>` **pow** **(** :ref:`float<class_float>` x, :ref:`float<class_float>` y **)**
|
|
@@ -768,6 +860,8 @@ Returns the result of ``x`` raised to the power of ``y``.
|
|
|
|
|
|
pow(2, 5) # returns 32
|
|
pow(2, 5) # returns 32
|
|
|
|
|
|
|
|
+----
|
|
|
|
+
|
|
.. _class_@GDScript_method_preload:
|
|
.. _class_@GDScript_method_preload:
|
|
|
|
|
|
- :ref:`Resource<class_Resource>` **preload** **(** :ref:`String<class_String>` path **)**
|
|
- :ref:`Resource<class_Resource>` **preload** **(** :ref:`String<class_String>` path **)**
|
|
@@ -781,6 +875,8 @@ Returns a resource from the filesystem that is loaded during script parsing.
|
|
# 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")
|
|
var main = preload("res://main.tscn")
|
|
|
|
|
|
|
|
+----
|
|
|
|
+
|
|
.. _class_@GDScript_method_print:
|
|
.. _class_@GDScript_method_print:
|
|
|
|
|
|
- void **print** **(** ... **)** vararg
|
|
- void **print** **(** ... **)** vararg
|
|
@@ -792,12 +888,16 @@ Converts one or more arguments to strings in the best way possible and prints th
|
|
a = [1, 2, 3]
|
|
a = [1, 2, 3]
|
|
print("a", "b", a) # prints ab[1, 2, 3]
|
|
print("a", "b", a) # prints ab[1, 2, 3]
|
|
|
|
|
|
|
|
+----
|
|
|
|
+
|
|
.. _class_@GDScript_method_print_debug:
|
|
.. _class_@GDScript_method_print_debug:
|
|
|
|
|
|
- void **print_debug** **(** ... **)** vararg
|
|
- void **print_debug** **(** ... **)** vararg
|
|
|
|
|
|
Like :ref:`print<class_@GDScript_method_print>`, but prints only when used in debug mode.
|
|
Like :ref:`print<class_@GDScript_method_print>`, but prints only when used in debug mode.
|
|
|
|
|
|
|
|
+----
|
|
|
|
+
|
|
.. _class_@GDScript_method_print_stack:
|
|
.. _class_@GDScript_method_print_stack:
|
|
|
|
|
|
- void **print_stack** **(** **)**
|
|
- void **print_stack** **(** **)**
|
|
@@ -810,6 +910,8 @@ Output in the console would look something like this:
|
|
|
|
|
|
Frame 0 - res://test.gd:16 in function '_process'
|
|
Frame 0 - res://test.gd:16 in function '_process'
|
|
|
|
|
|
|
|
+----
|
|
|
|
+
|
|
.. _class_@GDScript_method_printerr:
|
|
.. _class_@GDScript_method_printerr:
|
|
|
|
|
|
- void **printerr** **(** ... **)** vararg
|
|
- void **printerr** **(** ... **)** vararg
|
|
@@ -820,6 +922,8 @@ Prints one or more arguments to strings in the best way possible to standard err
|
|
|
|
|
|
printerr("prints to stderr")
|
|
printerr("prints to stderr")
|
|
|
|
|
|
|
|
+----
|
|
|
|
+
|
|
.. _class_@GDScript_method_printraw:
|
|
.. _class_@GDScript_method_printraw:
|
|
|
|
|
|
- void **printraw** **(** ... **)** vararg
|
|
- void **printraw** **(** ... **)** vararg
|
|
@@ -832,6 +936,8 @@ Prints one or more arguments to strings in the best way possible to console. No
|
|
printraw("B")
|
|
printraw("B")
|
|
# prints AB
|
|
# prints AB
|
|
|
|
|
|
|
|
+----
|
|
|
|
+
|
|
.. _class_@GDScript_method_prints:
|
|
.. _class_@GDScript_method_prints:
|
|
|
|
|
|
- void **prints** **(** ... **)** vararg
|
|
- void **prints** **(** ... **)** vararg
|
|
@@ -842,6 +948,8 @@ Prints one or more arguments to the console with a space between each argument.
|
|
|
|
|
|
prints("A", "B", "C") # prints A B C
|
|
prints("A", "B", "C") # prints A B C
|
|
|
|
|
|
|
|
+----
|
|
|
|
+
|
|
.. _class_@GDScript_method_printt:
|
|
.. _class_@GDScript_method_printt:
|
|
|
|
|
|
- void **printt** **(** ... **)** vararg
|
|
- void **printt** **(** ... **)** vararg
|
|
@@ -852,6 +960,8 @@ Prints one or more arguments to the console with a tab between each argument.
|
|
|
|
|
|
printt("A", "B", "C") # prints A B C
|
|
printt("A", "B", "C") # prints A B C
|
|
|
|
|
|
|
|
+----
|
|
|
|
+
|
|
.. _class_@GDScript_method_push_error:
|
|
.. _class_@GDScript_method_push_error:
|
|
|
|
|
|
- void **push_error** **(** :ref:`String<class_String>` message **)**
|
|
- void **push_error** **(** :ref:`String<class_String>` message **)**
|
|
@@ -862,6 +972,8 @@ Pushes an error message to Godot's built-in debugger and to the OS terminal.
|
|
|
|
|
|
push_error("test error") # prints "test error" to debugger and terminal as error call
|
|
push_error("test error") # prints "test error" to debugger and terminal as error call
|
|
|
|
|
|
|
|
+----
|
|
|
|
+
|
|
.. _class_@GDScript_method_push_warning:
|
|
.. _class_@GDScript_method_push_warning:
|
|
|
|
|
|
- void **push_warning** **(** :ref:`String<class_String>` message **)**
|
|
- void **push_warning** **(** :ref:`String<class_String>` message **)**
|
|
@@ -872,6 +984,8 @@ Pushes a warning message to Godot's built-in debugger and to the OS terminal.
|
|
|
|
|
|
push_warning("test warning") # prints "test warning" to debugger and terminal as warning call
|
|
push_warning("test warning") # prints "test warning" to debugger and terminal as warning call
|
|
|
|
|
|
|
|
+----
|
|
|
|
+
|
|
.. _class_@GDScript_method_rad2deg:
|
|
.. _class_@GDScript_method_rad2deg:
|
|
|
|
|
|
- :ref:`float<class_float>` **rad2deg** **(** :ref:`float<class_float>` rad **)**
|
|
- :ref:`float<class_float>` **rad2deg** **(** :ref:`float<class_float>` rad **)**
|
|
@@ -882,6 +996,8 @@ Converts from radians to degrees.
|
|
|
|
|
|
rad2deg(0.523599) # returns 30
|
|
rad2deg(0.523599) # returns 30
|
|
|
|
|
|
|
|
+----
|
|
|
|
+
|
|
.. _class_@GDScript_method_rand_range:
|
|
.. _class_@GDScript_method_rand_range:
|
|
|
|
|
|
- :ref:`float<class_float>` **rand_range** **(** :ref:`float<class_float>` from, :ref:`float<class_float>` to **)**
|
|
- :ref:`float<class_float>` **rand_range** **(** :ref:`float<class_float>` from, :ref:`float<class_float>` to **)**
|
|
@@ -892,12 +1008,16 @@ Random range, any floating point value between ``from`` and ``to``.
|
|
|
|
|
|
prints(rand_range(0, 1), rand_range(0, 1)) # prints e.g. 0.135591 0.405263
|
|
prints(rand_range(0, 1), rand_range(0, 1)) # prints e.g. 0.135591 0.405263
|
|
|
|
|
|
|
|
+----
|
|
|
|
+
|
|
.. _class_@GDScript_method_rand_seed:
|
|
.. _class_@GDScript_method_rand_seed:
|
|
|
|
|
|
- :ref:`Array<class_Array>` **rand_seed** **(** :ref:`int<class_int>` seed **)**
|
|
- :ref:`Array<class_Array>` **rand_seed** **(** :ref:`int<class_int>` seed **)**
|
|
|
|
|
|
Random from seed: pass a ``seed``, and an array with both number and new seed is returned. "Seed" here refers to the internal state of the pseudo random number generator. The internal state of the current implementation is 64 bits.
|
|
Random from seed: pass a ``seed``, and an array with both number and new seed is returned. "Seed" here refers to the internal state of the pseudo random number generator. The internal state of the current implementation is 64 bits.
|
|
|
|
|
|
|
|
+----
|
|
|
|
+
|
|
.. _class_@GDScript_method_randf:
|
|
.. _class_@GDScript_method_randf:
|
|
|
|
|
|
- :ref:`float<class_float>` **randf** **(** **)**
|
|
- :ref:`float<class_float>` **randf** **(** **)**
|
|
@@ -908,6 +1028,8 @@ Returns a random floating point value on the interval ``[0, 1]``.
|
|
|
|
|
|
randf() # returns e.g. 0.375671
|
|
randf() # returns e.g. 0.375671
|
|
|
|
|
|
|
|
+----
|
|
|
|
+
|
|
.. _class_@GDScript_method_randi:
|
|
.. _class_@GDScript_method_randi:
|
|
|
|
|
|
- :ref:`int<class_int>` **randi** **(** **)**
|
|
- :ref:`int<class_int>` **randi** **(** **)**
|
|
@@ -921,6 +1043,8 @@ Returns a random unsigned 32 bit integer. Use remainder to obtain a random value
|
|
randi() % 100 # returns random integer between 0 and 99
|
|
randi() % 100 # returns random integer between 0 and 99
|
|
randi() % 100 + 1 # returns random integer between 1 and 100
|
|
randi() % 100 + 1 # returns random integer between 1 and 100
|
|
|
|
|
|
|
|
+----
|
|
|
|
+
|
|
.. _class_@GDScript_method_randomize:
|
|
.. _class_@GDScript_method_randomize:
|
|
|
|
|
|
- void **randomize** **(** **)**
|
|
- void **randomize** **(** **)**
|
|
@@ -932,6 +1056,8 @@ Randomizes the seed (or the internal state) of the random number generator. Curr
|
|
func _ready():
|
|
func _ready():
|
|
randomize()
|
|
randomize()
|
|
|
|
|
|
|
|
+----
|
|
|
|
+
|
|
.. _class_@GDScript_method_range:
|
|
.. _class_@GDScript_method_range:
|
|
|
|
|
|
- :ref:`Array<class_Array>` **range** **(** ... **)** vararg
|
|
- :ref:`Array<class_Array>` **range** **(** ... **)** vararg
|
|
@@ -964,6 +1090,8 @@ Output:
|
|
2
|
|
2
|
|
4
|
|
4
|
|
|
|
|
|
|
|
+----
|
|
|
|
+
|
|
.. _class_@GDScript_method_range_lerp:
|
|
.. _class_@GDScript_method_range_lerp:
|
|
|
|
|
|
- :ref:`float<class_float>` **range_lerp** **(** :ref:`float<class_float>` value, :ref:`float<class_float>` istart, :ref:`float<class_float>` istop, :ref:`float<class_float>` ostart, :ref:`float<class_float>` ostop **)**
|
|
- :ref:`float<class_float>` **range_lerp** **(** :ref:`float<class_float>` value, :ref:`float<class_float>` istart, :ref:`float<class_float>` istop, :ref:`float<class_float>` ostart, :ref:`float<class_float>` ostop **)**
|
|
@@ -974,6 +1102,8 @@ Maps a ``value`` from range ``[istart, istop]`` to ``[ostart, ostop]``.
|
|
|
|
|
|
range_lerp(75, 0, 100, -1, 1) # returns 0.5
|
|
range_lerp(75, 0, 100, -1, 1) # returns 0.5
|
|
|
|
|
|
|
|
+----
|
|
|
|
+
|
|
.. _class_@GDScript_method_round:
|
|
.. _class_@GDScript_method_round:
|
|
|
|
|
|
- :ref:`float<class_float>` **round** **(** :ref:`float<class_float>` s **)**
|
|
- :ref:`float<class_float>` **round** **(** :ref:`float<class_float>` s **)**
|
|
@@ -984,6 +1114,8 @@ Returns the integral value that is nearest to ``s``, with halfway cases rounded
|
|
|
|
|
|
round(2.6) # returns 3
|
|
round(2.6) # returns 3
|
|
|
|
|
|
|
|
+----
|
|
|
|
+
|
|
.. _class_@GDScript_method_seed:
|
|
.. _class_@GDScript_method_seed:
|
|
|
|
|
|
- void **seed** **(** :ref:`int<class_int>` seed **)**
|
|
- void **seed** **(** :ref:`int<class_int>` seed **)**
|
|
@@ -995,6 +1127,8 @@ Sets seed for the random number generator.
|
|
my_seed = "Godot Rocks"
|
|
my_seed = "Godot Rocks"
|
|
seed(my_seed.hash())
|
|
seed(my_seed.hash())
|
|
|
|
|
|
|
|
+----
|
|
|
|
+
|
|
.. _class_@GDScript_method_sign:
|
|
.. _class_@GDScript_method_sign:
|
|
|
|
|
|
- :ref:`float<class_float>` **sign** **(** :ref:`float<class_float>` s **)**
|
|
- :ref:`float<class_float>` **sign** **(** :ref:`float<class_float>` s **)**
|
|
@@ -1007,6 +1141,8 @@ Returns the sign of ``s``: -1 or 1. Returns 0 if ``s`` is 0.
|
|
sign(0) # returns 0
|
|
sign(0) # returns 0
|
|
sign(6) # returns 1
|
|
sign(6) # returns 1
|
|
|
|
|
|
|
|
+----
|
|
|
|
+
|
|
.. _class_@GDScript_method_sin:
|
|
.. _class_@GDScript_method_sin:
|
|
|
|
|
|
- :ref:`float<class_float>` **sin** **(** :ref:`float<class_float>` s **)**
|
|
- :ref:`float<class_float>` **sin** **(** :ref:`float<class_float>` s **)**
|
|
@@ -1017,6 +1153,8 @@ Returns the sine of angle ``s`` in radians.
|
|
|
|
|
|
sin(0.523599) # returns 0.5
|
|
sin(0.523599) # returns 0.5
|
|
|
|
|
|
|
|
+----
|
|
|
|
+
|
|
.. _class_@GDScript_method_sinh:
|
|
.. _class_@GDScript_method_sinh:
|
|
|
|
|
|
- :ref:`float<class_float>` **sinh** **(** :ref:`float<class_float>` s **)**
|
|
- :ref:`float<class_float>` **sinh** **(** :ref:`float<class_float>` s **)**
|
|
@@ -1028,6 +1166,8 @@ Returns the hyperbolic sine of ``s``.
|
|
a = log(2.0) # returns 0.693147
|
|
a = log(2.0) # returns 0.693147
|
|
sinh(a) # returns 0.75
|
|
sinh(a) # returns 0.75
|
|
|
|
|
|
|
|
+----
|
|
|
|
+
|
|
.. _class_@GDScript_method_smoothstep:
|
|
.. _class_@GDScript_method_smoothstep:
|
|
|
|
|
|
- :ref:`float<class_float>` **smoothstep** **(** :ref:`float<class_float>` from, :ref:`float<class_float>` to, :ref:`float<class_float>` weight **)**
|
|
- :ref:`float<class_float>` **smoothstep** **(** :ref:`float<class_float>` from, :ref:`float<class_float>` to, :ref:`float<class_float>` weight **)**
|
|
@@ -1040,6 +1180,8 @@ Returns a number smoothly interpolated between the ``from`` and ``to``, based on
|
|
smoothstep(0, 2, 1.0) # returns 0.5
|
|
smoothstep(0, 2, 1.0) # returns 0.5
|
|
smoothstep(0, 2, 2.0) # returns 1.0
|
|
smoothstep(0, 2, 2.0) # returns 1.0
|
|
|
|
|
|
|
|
+----
|
|
|
|
+
|
|
.. _class_@GDScript_method_sqrt:
|
|
.. _class_@GDScript_method_sqrt:
|
|
|
|
|
|
- :ref:`float<class_float>` **sqrt** **(** :ref:`float<class_float>` s **)**
|
|
- :ref:`float<class_float>` **sqrt** **(** :ref:`float<class_float>` s **)**
|
|
@@ -1050,12 +1192,16 @@ Returns the square root of ``s``.
|
|
|
|
|
|
sqrt(9) # returns 3
|
|
sqrt(9) # returns 3
|
|
|
|
|
|
|
|
+----
|
|
|
|
+
|
|
.. _class_@GDScript_method_stepify:
|
|
.. _class_@GDScript_method_stepify:
|
|
|
|
|
|
- :ref:`float<class_float>` **stepify** **(** :ref:`float<class_float>` s, :ref:`float<class_float>` step **)**
|
|
- :ref:`float<class_float>` **stepify** **(** :ref:`float<class_float>` s, :ref:`float<class_float>` step **)**
|
|
|
|
|
|
Snaps float value ``s`` to a given ``step``.
|
|
Snaps float value ``s`` to a given ``step``.
|
|
|
|
|
|
|
|
+----
|
|
|
|
+
|
|
.. _class_@GDScript_method_str:
|
|
.. _class_@GDScript_method_str:
|
|
|
|
|
|
- :ref:`String<class_String>` **str** **(** ... **)** vararg
|
|
- :ref:`String<class_String>` **str** **(** ... **)** vararg
|
|
@@ -1069,6 +1215,8 @@ Converts one or more arguments to string in the best way possible.
|
|
len(a) # returns 3
|
|
len(a) # returns 3
|
|
len(b) # returns 12
|
|
len(b) # returns 12
|
|
|
|
|
|
|
|
+----
|
|
|
|
+
|
|
.. _class_@GDScript_method_str2var:
|
|
.. _class_@GDScript_method_str2var:
|
|
|
|
|
|
- :ref:`Variant<class_Variant>` **str2var** **(** :ref:`String<class_String>` string **)**
|
|
- :ref:`Variant<class_Variant>` **str2var** **(** :ref:`String<class_String>` string **)**
|
|
@@ -1081,6 +1229,8 @@ Converts a formatted string that was returned by :ref:`var2str<class_@GDScript_m
|
|
b = str2var(a)
|
|
b = str2var(a)
|
|
print(b['a']) # prints 1
|
|
print(b['a']) # prints 1
|
|
|
|
|
|
|
|
+----
|
|
|
|
+
|
|
.. _class_@GDScript_method_tan:
|
|
.. _class_@GDScript_method_tan:
|
|
|
|
|
|
- :ref:`float<class_float>` **tan** **(** :ref:`float<class_float>` s **)**
|
|
- :ref:`float<class_float>` **tan** **(** :ref:`float<class_float>` s **)**
|
|
@@ -1091,6 +1241,8 @@ Returns the tangent of angle ``s`` in radians.
|
|
|
|
|
|
tan(deg2rad(45)) # returns 1
|
|
tan(deg2rad(45)) # returns 1
|
|
|
|
|
|
|
|
+----
|
|
|
|
+
|
|
.. _class_@GDScript_method_tanh:
|
|
.. _class_@GDScript_method_tanh:
|
|
|
|
|
|
- :ref:`float<class_float>` **tanh** **(** :ref:`float<class_float>` s **)**
|
|
- :ref:`float<class_float>` **tanh** **(** :ref:`float<class_float>` s **)**
|
|
@@ -1102,6 +1254,8 @@ Returns the hyperbolic tangent of ``s``.
|
|
a = log(2.0) # returns 0.693147
|
|
a = log(2.0) # returns 0.693147
|
|
tanh(a) # returns 0.6
|
|
tanh(a) # returns 0.6
|
|
|
|
|
|
|
|
+----
|
|
|
|
+
|
|
.. _class_@GDScript_method_to_json:
|
|
.. _class_@GDScript_method_to_json:
|
|
|
|
|
|
- :ref:`String<class_String>` **to_json** **(** :ref:`Variant<class_Variant>` var **)**
|
|
- :ref:`String<class_String>` **to_json** **(** :ref:`Variant<class_Variant>` var **)**
|
|
@@ -1114,6 +1268,8 @@ Converts a Variant ``var`` to JSON text and return the result. Useful for serial
|
|
b = to_json(a)
|
|
b = to_json(a)
|
|
print(b) # {"a":1, "b":2}
|
|
print(b) # {"a":1, "b":2}
|
|
|
|
|
|
|
|
+----
|
|
|
|
+
|
|
.. _class_@GDScript_method_type_exists:
|
|
.. _class_@GDScript_method_type_exists:
|
|
|
|
|
|
- :ref:`bool<class_bool>` **type_exists** **(** :ref:`String<class_String>` type **)**
|
|
- :ref:`bool<class_bool>` **type_exists** **(** :ref:`String<class_String>` type **)**
|
|
@@ -1125,6 +1281,8 @@ Returns whether the given class exists in :ref:`ClassDB<class_ClassDB>`.
|
|
type_exists("Sprite") # returns true
|
|
type_exists("Sprite") # returns true
|
|
type_exists("Variant") # returns false
|
|
type_exists("Variant") # returns false
|
|
|
|
|
|
|
|
+----
|
|
|
|
+
|
|
.. _class_@GDScript_method_typeof:
|
|
.. _class_@GDScript_method_typeof:
|
|
|
|
|
|
- :ref:`int<class_int>` **typeof** **(** :ref:`Variant<class_Variant>` what **)**
|
|
- :ref:`int<class_int>` **typeof** **(** :ref:`Variant<class_Variant>` what **)**
|
|
@@ -1139,6 +1297,8 @@ Returns the internal type of the given Variant object, using the TYPE\_\* enum i
|
|
else:
|
|
else:
|
|
print("unexpected results")
|
|
print("unexpected results")
|
|
|
|
|
|
|
|
+----
|
|
|
|
+
|
|
.. _class_@GDScript_method_validate_json:
|
|
.. _class_@GDScript_method_validate_json:
|
|
|
|
|
|
- :ref:`String<class_String>` **validate_json** **(** :ref:`String<class_String>` json **)**
|
|
- :ref:`String<class_String>` **validate_json** **(** :ref:`String<class_String>` json **)**
|
|
@@ -1154,12 +1314,16 @@ Checks that ``json`` is valid JSON data. Returns empty string if valid. Returns
|
|
else:
|
|
else:
|
|
prints("invalid", v)
|
|
prints("invalid", v)
|
|
|
|
|
|
|
|
+----
|
|
|
|
+
|
|
.. _class_@GDScript_method_var2bytes:
|
|
.. _class_@GDScript_method_var2bytes:
|
|
|
|
|
|
- :ref:`PoolByteArray<class_PoolByteArray>` **var2bytes** **(** :ref:`Variant<class_Variant>` var, :ref:`bool<class_bool>` full_objects=false **)**
|
|
- :ref:`PoolByteArray<class_PoolByteArray>` **var2bytes** **(** :ref:`Variant<class_Variant>` var, :ref:`bool<class_bool>` full_objects=false **)**
|
|
|
|
|
|
Encodes a variable value to a byte array. When ``full_objects`` is ``true`` encoding objects is allowed (and can potentially include code).
|
|
Encodes a variable value to a byte array. When ``full_objects`` is ``true`` encoding objects is allowed (and can potentially include code).
|
|
|
|
|
|
|
|
+----
|
|
|
|
+
|
|
.. _class_@GDScript_method_var2str:
|
|
.. _class_@GDScript_method_var2str:
|
|
|
|
|
|
- :ref:`String<class_String>` **var2str** **(** :ref:`Variant<class_Variant>` var **)**
|
|
- :ref:`String<class_String>` **var2str** **(** :ref:`Variant<class_Variant>` var **)**
|
|
@@ -1180,6 +1344,8 @@ prints
|
|
"b": 2
|
|
"b": 2
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+----
|
|
|
|
+
|
|
.. _class_@GDScript_method_weakref:
|
|
.. _class_@GDScript_method_weakref:
|
|
|
|
|
|
- :ref:`WeakRef<class_WeakRef>` **weakref** **(** :ref:`Object<class_Object>` obj **)**
|
|
- :ref:`WeakRef<class_WeakRef>` **weakref** **(** :ref:`Object<class_Object>` obj **)**
|
|
@@ -1188,6 +1354,8 @@ Returns a weak reference to an object.
|
|
|
|
|
|
A weak reference to an object is not enough to keep the object alive: when the only remaining references to a referent are weak references, garbage collection is free to destroy the referent and reuse its memory for something else. However, until the object is actually destroyed the weak reference may return the object even if there are no strong references to it.
|
|
A weak reference to an object is not enough to keep the object alive: when the only remaining references to a referent are weak references, garbage collection is free to destroy the referent and reuse its memory for something else. However, until the object is actually destroyed the weak reference may return the object even if there are no strong references to it.
|
|
|
|
|
|
|
|
+----
|
|
|
|
+
|
|
.. _class_@GDScript_method_wrapf:
|
|
.. _class_@GDScript_method_wrapf:
|
|
|
|
|
|
- :ref:`float<class_float>` **wrapf** **(** :ref:`float<class_float>` value, :ref:`float<class_float>` min, :ref:`float<class_float>` max **)**
|
|
- :ref:`float<class_float>` **wrapf** **(** :ref:`float<class_float>` value, :ref:`float<class_float>` min, :ref:`float<class_float>` max **)**
|
|
@@ -1225,6 +1393,8 @@ The usage of ``wrapf`` is more flexible than using the :ref:`fmod<class_@GDScrip
|
|
# infinite rotation (in radians)
|
|
# infinite rotation (in radians)
|
|
angle = wrapf(angle + 0.1, -PI, PI)
|
|
angle = wrapf(angle + 0.1, -PI, PI)
|
|
|
|
|
|
|
|
+----
|
|
|
|
+
|
|
.. _class_@GDScript_method_wrapi:
|
|
.. _class_@GDScript_method_wrapi:
|
|
|
|
|
|
- :ref:`int<class_int>` **wrapi** **(** :ref:`int<class_int>` value, :ref:`int<class_int>` min, :ref:`int<class_int>` max **)**
|
|
- :ref:`int<class_int>` **wrapi** **(** :ref:`int<class_int>` value, :ref:`int<class_int>` min, :ref:`int<class_int>` max **)**
|
|
@@ -1257,6 +1427,8 @@ The usage of ``wrapi`` is more flexible than using the modulo approach by giving
|
|
# result is -2
|
|
# result is -2
|
|
var result = wrapi(-6, -5, -1)
|
|
var result = wrapi(-6, -5, -1)
|
|
|
|
|
|
|
|
+----
|
|
|
|
+
|
|
.. _class_@GDScript_method_yield:
|
|
.. _class_@GDScript_method_yield:
|
|
|
|
|
|
- :ref:`GDScriptFunctionState<class_GDScriptFunctionState>` **yield** **(** :ref:`Object<class_Object>` object=null, :ref:`String<class_String>` signal="" **)**
|
|
- :ref:`GDScriptFunctionState<class_GDScriptFunctionState>` **yield** **(** :ref:`Object<class_Object>` object=null, :ref:`String<class_String>` signal="" **)**
|