.. _class_@GDScript: @GDScript ========= **Category:** Core Brief Description ----------------- Built-in GDScript functions. Member Functions ---------------- +--------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`float` | :ref:`sin` **(** :ref:`float` s **)** | +--------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`float` | :ref:`cos` **(** :ref:`float` s **)** | +--------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`float` | :ref:`tan` **(** :ref:`float` s **)** | +--------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`float` | :ref:`sinh` **(** :ref:`float` s **)** | +--------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`float` | :ref:`cosh` **(** :ref:`float` s **)** | +--------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`float` | :ref:`tanh` **(** :ref:`float` s **)** | +--------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`float` | :ref:`asin` **(** :ref:`float` s **)** | +--------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`float` | :ref:`acos` **(** :ref:`float` s **)** | +--------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`float` | :ref:`atan` **(** :ref:`float` s **)** | +--------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`float` | :ref:`atan2` **(** :ref:`float` x, :ref:`float` y **)** | +--------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`float` | :ref:`sqrt` **(** :ref:`float` s **)** | +--------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`float` | :ref:`fmod` **(** :ref:`float` x, :ref:`float` y **)** | +--------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`float` | :ref:`fposmod` **(** :ref:`float` x, :ref:`float` y **)** | +--------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`float` | :ref:`floor` **(** :ref:`float` s **)** | +--------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`float` | :ref:`ceil` **(** :ref:`float` s **)** | +--------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`float` | :ref:`round` **(** :ref:`float` s **)** | +--------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`float` | :ref:`abs` **(** :ref:`float` s **)** | +--------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`float` | :ref:`sign` **(** :ref:`float` s **)** | +--------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`float` | :ref:`pow` **(** :ref:`float` x, :ref:`float` y **)** | +--------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`float` | :ref:`log` **(** :ref:`float` s **)** | +--------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`float` | :ref:`exp` **(** :ref:`float` s **)** | +--------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`float` | :ref:`isnan` **(** :ref:`float` s **)** | +--------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`float` | :ref:`isinf` **(** :ref:`float` s **)** | +--------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`float` | :ref:`ease` **(** :ref:`float` s, :ref:`float` curve **)** | +--------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`float` | :ref:`decimals` **(** :ref:`float` step **)** | +--------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`float` | :ref:`stepify` **(** :ref:`float` s, :ref:`float` step **)** | +--------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`float` | :ref:`lerp` **(** :ref:`float` from, :ref:`float` to, :ref:`float` weight **)** | +--------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`float` | :ref:`dectime` **(** :ref:`float` value, :ref:`float` amount, :ref:`float` step **)** | +--------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Nil` | :ref:`randomize` **(** **)** | +--------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`int` | :ref:`randi` **(** **)** | +--------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`float` | :ref:`randf` **(** **)** | +--------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`float` | :ref:`rand_range` **(** :ref:`float` from, :ref:`float` to **)** | +--------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Nil` | :ref:`seed` **(** :ref:`float` seed **)** | +--------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Array` | :ref:`rand_seed` **(** :ref:`float` seed **)** | +--------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`float` | :ref:`deg2rad` **(** :ref:`float` deg **)** | +--------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`float` | :ref:`rad2deg` **(** :ref:`float` rad **)** | +--------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`float` | :ref:`linear2db` **(** :ref:`float` nrg **)** | +--------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`float` | :ref:`db2linear` **(** :ref:`float` db **)** | +--------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`float` | :ref:`max` **(** :ref:`float` a, :ref:`float` b **)** | +--------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`float` | :ref:`min` **(** :ref:`float` a, :ref:`float` b **)** | +--------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`float` | :ref:`clamp` **(** :ref:`float` val, :ref:`float` min, :ref:`float` max **)** | +--------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`int` | :ref:`nearest_po2` **(** :ref:`int` val **)** | +--------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`WeakRef` | :ref:`weakref` **(** :ref:`Object` obj **)** | +--------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`FuncRef` | :ref:`funcref` **(** :ref:`Object` instance, :ref:`String` funcname **)** | +--------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Object` | :ref:`convert` **(** Variant what, :ref:`int` type **)** | +--------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`int` | :ref:`typeof` **(** Variant what **)** | +--------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`String` | :ref:`str` **(** Variant what, Variant ... **)** | +--------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Nil` | :ref:`print` **(** Variant what, Variant ... **)** | +--------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Nil` | :ref:`printt` **(** Variant what, Variant ... **)** | +--------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Nil` | :ref:`prints` **(** Variant what, Variant ... **)** | +--------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Nil` | :ref:`printerr` **(** Variant what, Variant ... **)** | +--------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Nil` | :ref:`printraw` **(** Variant what, Variant ... **)** | +--------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`String` | :ref:`var2str` **(** Variant var **)** | +--------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Variant | :ref:`str2var` **(** :ref:`String` string **)** | +--------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`RawArray` | :ref:`var2bytes` **(** Variant var **)** | +--------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Variant | :ref:`bytes2var` **(** :ref:`RawArray` bytes **)** | +--------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Array` | :ref:`range` **(** Variant ... **)** | +--------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Resource` | :ref:`load` **(** :ref:`String` path **)** | +--------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Dictionary` | :ref:`inst2dict` **(** :ref:`Object` inst **)** | +--------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Object` | :ref:`dict2inst` **(** :ref:`Dictionary` dict **)** | +--------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`int` | :ref:`hash` **(** Variant var:Variant **)** | +--------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Color` | :ref:`Color8` **(** :ref:`int` r8, :ref:`int` g8, :ref:`int` b8, :ref:`int` a8 **)** | +--------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Nil` | :ref:`print_stack` **(** **)** | +--------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Object` | :ref:`instance_from_id` **(** :ref:`int` instance_id **)** | +--------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+ Numeric Constants ----------------- - **PI** = **3.141593** --- Constant that represents how many times the diameter of a circumference fits around it's perimeter. Description ----------- This contains the list of built-in gdscript functions. Mostly math functions and other utilities. Everything else is expanded by objects. Member Function Description --------------------------- .. _class_@GDScript_sin: - :ref:`float` **sin** **(** :ref:`float` s **)** Standard sine function. .. _class_@GDScript_cos: - :ref:`float` **cos** **(** :ref:`float` s **)** Standard cosine function. .. _class_@GDScript_tan: - :ref:`float` **tan** **(** :ref:`float` s **)** Standard tangent function. .. _class_@GDScript_sinh: - :ref:`float` **sinh** **(** :ref:`float` s **)** Hyperbolic sine. .. _class_@GDScript_cosh: - :ref:`float` **cosh** **(** :ref:`float` s **)** Hyperbolic cosine. .. _class_@GDScript_tanh: - :ref:`float` **tanh** **(** :ref:`float` s **)** Hyperbolic tangent. .. _class_@GDScript_asin: - :ref:`float` **asin** **(** :ref:`float` s **)** Arc-sine. .. _class_@GDScript_acos: - :ref:`float` **acos** **(** :ref:`float` s **)** Arc-cosine. .. _class_@GDScript_atan: - :ref:`float` **atan** **(** :ref:`float` s **)** Arc-tangent. .. _class_@GDScript_atan2: - :ref:`float` **atan2** **(** :ref:`float` x, :ref:`float` y **)** Arc-tangent that takes a 2D vector as argument, retuns the full -pi to +pi range. .. _class_@GDScript_sqrt: - :ref:`float` **sqrt** **(** :ref:`float` s **)** Square root. .. _class_@GDScript_fmod: - :ref:`float` **fmod** **(** :ref:`float` x, :ref:`float` y **)** Module (remainder of x/y). .. _class_@GDScript_fposmod: - :ref:`float` **fposmod** **(** :ref:`float` x, :ref:`float` y **)** Module (remainder of x/y) that wraps equally in positive and negative. .. _class_@GDScript_floor: - :ref:`float` **floor** **(** :ref:`float` s **)** Floor (rounds down to nearest integer). .. _class_@GDScript_ceil: - :ref:`float` **ceil** **(** :ref:`float` s **)** Ceiling (rounds up to nearest integer). .. _class_@GDScript_round: - :ref:`float` **round** **(** :ref:`float` s **)** Round to nearest integer. .. _class_@GDScript_abs: - :ref:`float` **abs** **(** :ref:`float` s **)** Remove sign (works for integer and float). .. _class_@GDScript_sign: - :ref:`float` **sign** **(** :ref:`float` s **)** Return sign (-1 or +1). .. _class_@GDScript_pow: - :ref:`float` **pow** **(** :ref:`float` x, :ref:`float` y **)** Power function, x elevate to y. .. _class_@GDScript_log: - :ref:`float` **log** **(** :ref:`float` s **)** Natural logarithm. .. _class_@GDScript_exp: - :ref:`float` **exp** **(** :ref:`float` s **)** Exponential logarithm. .. _class_@GDScript_isnan: - :ref:`float` **isnan** **(** :ref:`float` s **)** Return true if the float is not a number. .. _class_@GDScript_isinf: - :ref:`float` **isinf** **(** :ref:`float` s **)** Return true if the float is infinite. .. _class_@GDScript_ease: - :ref:`float` **ease** **(** :ref:`float` s, :ref:`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. .. _class_@GDScript_decimals: - :ref:`float` **decimals** **(** :ref:`float` step **)** Return the amount of decimals in the floating point value. .. _class_@GDScript_stepify: - :ref:`float` **stepify** **(** :ref:`float` s, :ref:`float` step **)** Snap float value to a given step. .. _class_@GDScript_lerp: - :ref:`float` **lerp** **(** :ref:`float` from, :ref:`float` to, :ref:`float` weight **)** Linear interpolates between two values by a normalized value. .. _class_@GDScript_dectime: - :ref:`float` **dectime** **(** :ref:`float` value, :ref:`float` amount, :ref:`float` step **)** Decreases time by a specified amount. .. _class_@GDScript_randomize: - :ref:`Nil` **randomize** **(** **)** Reset the seed of the random number generator with a new, different one. .. _class_@GDScript_randi: - :ref:`int` **randi** **(** **)** Random 32 bits value (integer). To obtain a value from 0 to N, you can use remainder, like (for random from 0 to 19): randi() % 20. .. _class_@GDScript_randf: - :ref:`float` **randf** **(** **)** Random value (0 to 1 float). .. _class_@GDScript_rand_range: - :ref:`float` **rand_range** **(** :ref:`float` from, :ref:`float` to **)** Random range, any floating point value between 'from' and 'to' .. _class_@GDScript_seed: - :ref:`Nil` **seed** **(** :ref:`float` seed **)** .. _class_@GDScript_rand_seed: - :ref:`Array` **rand_seed** **(** :ref:`float` seed **)** Random from seed, pass a seed and an array with both number and new seed is returned. .. _class_@GDScript_deg2rad: - :ref:`float` **deg2rad** **(** :ref:`float` deg **)** Convert from degrees to radians. .. _class_@GDScript_rad2deg: - :ref:`float` **rad2deg** **(** :ref:`float` rad **)** Convert from radias to degrees. .. _class_@GDScript_linear2db: - :ref:`float` **linear2db** **(** :ref:`float` nrg **)** Convert from linear energy to decibels (audio). .. _class_@GDScript_db2linear: - :ref:`float` **db2linear** **(** :ref:`float` db **)** Convert from decibels to linear energy (audio). .. _class_@GDScript_max: - :ref:`float` **max** **(** :ref:`float` a, :ref:`float` b **)** Return the maximum of two values. .. _class_@GDScript_min: - :ref:`float` **min** **(** :ref:`float` a, :ref:`float` b **)** Return the minimum of two values. .. _class_@GDScript_clamp: - :ref:`float` **clamp** **(** :ref:`float` val, :ref:`float` min, :ref:`float` max **)** Clamp both values to a range. .. _class_@GDScript_nearest_po2: - :ref:`int` **nearest_po2** **(** :ref:`int` val **)** Return the nearest larger power of 2 for an integer. .. _class_@GDScript_weakref: - :ref:`WeakRef` **weakref** **(** :ref:`Object` obj **)** Return a weak reference to an object. .. _class_@GDScript_funcref: - :ref:`FuncRef` **funcref** **(** :ref:`Object` instance, :ref:`String` funcname **)** Returns a reference to the specified function .. _class_@GDScript_convert: - :ref:`Object` **convert** **(** Variant what, :ref:`int` type **)** Convert from a type to another in the best way possible. The "type" parameter uses the enum TYPE\_\* in :ref:`@Global Scope`. .. _class_@GDScript_typeof: - :ref:`int` **typeof** **(** Variant what **)** Returns the internal type of the given Variant object, using the TYPE\_\* enum in :ref:`@Global Scope`. .. _class_@GDScript_str: - :ref:`String` **str** **(** Variant what, Variant ... **)** Convert one or more arguments to strings in the best way possible. .. _class_@GDScript_print: - :ref:`Nil` **print** **(** Variant what, Variant ... **)** Print one or more arguments to strings in the best way possible to a console line. .. _class_@GDScript_printt: - :ref:`Nil` **printt** **(** Variant what, Variant ... **)** Print one or more arguments to the console with a tab between each argument. .. _class_@GDScript_prints: - :ref:`Nil` **prints** **(** Variant what, Variant ... **)** .. _class_@GDScript_printerr: - :ref:`Nil` **printerr** **(** Variant what, Variant ... **)** Print one or more arguments to strings in the best way possible to standard error line. .. _class_@GDScript_printraw: - :ref:`Nil` **printraw** **(** Variant what, Variant ... **)** Print one or more arguments to strings in the best way possible to console. No newline is added at the end. .. _class_@GDScript_var2str: - :ref:`String` **var2str** **(** Variant var **)** Converts the value of a variable to a String. .. _class_@GDScript_str2var: - Variant **str2var** **(** :ref:`String` string **)** .. _class_@GDScript_var2bytes: - :ref:`RawArray` **var2bytes** **(** Variant var **)** .. _class_@GDScript_bytes2var: - Variant **bytes2var** **(** :ref:`RawArray` bytes **)** .. _class_@GDScript_range: - :ref:`Array` **range** **(** Variant ... **)** Return an array with the given range. Range can be 1 argument N (0 to N-1), two arguments (initial, final-1) or three arguments (initial,final-1,increment). .. _class_@GDScript_load: - :ref:`Resource` **load** **(** :ref:`String` path **)** Load a resource from the filesystem, pass a valid path as argument. .. _class_@GDScript_inst2dict: - :ref:`Dictionary` **inst2dict** **(** :ref:`Object` inst **)** Convert a script class instance to a dictionary (useful for serializing). .. _class_@GDScript_dict2inst: - :ref:`Object` **dict2inst** **(** :ref:`Dictionary` dict **)** Convert a previously converted instances to dictionary back into an instance. Useful for deserializing. .. _class_@GDScript_hash: - :ref:`int` **hash** **(** Variant var:Variant **)** Hashes the variable passed and returns an integer. .. _class_@GDScript_Color8: - :ref:`Color` **Color8** **(** :ref:`int` r8, :ref:`int` g8, :ref:`int` b8, :ref:`int` a8 **)** .. _class_@GDScript_print_stack: - :ref:`Nil` **print_stack** **(** **)** Print a stack track at code location, only works when running with debugger turned on. .. _class_@GDScript_instance_from_id: - :ref:`Object` **instance_from_id** **(** :ref:`int` instance_id **)**