class_visualscriptbuiltinfunc.rst 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340
  1. :github_url: hide
  2. .. Generated automatically by doc/tools/make_rst.py in Godot's source tree.
  3. .. DO NOT EDIT THIS FILE, but the VisualScriptBuiltinFunc.xml source instead.
  4. .. The source is found in doc/classes or modules/<name>/doc_classes.
  5. .. _class_VisualScriptBuiltinFunc:
  6. VisualScriptBuiltinFunc
  7. =======================
  8. **Inherits:** :ref:`VisualScriptNode<class_VisualScriptNode>` **<** :ref:`Resource<class_Resource>` **<** :ref:`Reference<class_Reference>` **<** :ref:`Object<class_Object>`
  9. A Visual Script node used to call built-in functions.
  10. Description
  11. -----------
  12. A built-in function used inside a :ref:`VisualScript<class_VisualScript>`. It is usually a math function or an utility function.
  13. See also :ref:`@GDScript<class_@GDScript>`, for the same functions in the GDScript language.
  14. Properties
  15. ----------
  16. +--------------------------------------------------------------+------------------------------------------------------------------+-------+
  17. | :ref:`BuiltinFunc<enum_VisualScriptBuiltinFunc_BuiltinFunc>` | :ref:`function<class_VisualScriptBuiltinFunc_property_function>` | ``0`` |
  18. +--------------------------------------------------------------+------------------------------------------------------------------+-------+
  19. Enumerations
  20. ------------
  21. .. _enum_VisualScriptBuiltinFunc_BuiltinFunc:
  22. .. _class_VisualScriptBuiltinFunc_constant_MATH_SIN:
  23. .. _class_VisualScriptBuiltinFunc_constant_MATH_COS:
  24. .. _class_VisualScriptBuiltinFunc_constant_MATH_TAN:
  25. .. _class_VisualScriptBuiltinFunc_constant_MATH_SINH:
  26. .. _class_VisualScriptBuiltinFunc_constant_MATH_COSH:
  27. .. _class_VisualScriptBuiltinFunc_constant_MATH_TANH:
  28. .. _class_VisualScriptBuiltinFunc_constant_MATH_ASIN:
  29. .. _class_VisualScriptBuiltinFunc_constant_MATH_ACOS:
  30. .. _class_VisualScriptBuiltinFunc_constant_MATH_ATAN:
  31. .. _class_VisualScriptBuiltinFunc_constant_MATH_ATAN2:
  32. .. _class_VisualScriptBuiltinFunc_constant_MATH_SQRT:
  33. .. _class_VisualScriptBuiltinFunc_constant_MATH_FMOD:
  34. .. _class_VisualScriptBuiltinFunc_constant_MATH_FPOSMOD:
  35. .. _class_VisualScriptBuiltinFunc_constant_MATH_FLOOR:
  36. .. _class_VisualScriptBuiltinFunc_constant_MATH_CEIL:
  37. .. _class_VisualScriptBuiltinFunc_constant_MATH_ROUND:
  38. .. _class_VisualScriptBuiltinFunc_constant_MATH_ABS:
  39. .. _class_VisualScriptBuiltinFunc_constant_MATH_SIGN:
  40. .. _class_VisualScriptBuiltinFunc_constant_MATH_POW:
  41. .. _class_VisualScriptBuiltinFunc_constant_MATH_LOG:
  42. .. _class_VisualScriptBuiltinFunc_constant_MATH_EXP:
  43. .. _class_VisualScriptBuiltinFunc_constant_MATH_ISNAN:
  44. .. _class_VisualScriptBuiltinFunc_constant_MATH_ISINF:
  45. .. _class_VisualScriptBuiltinFunc_constant_MATH_EASE:
  46. .. _class_VisualScriptBuiltinFunc_constant_MATH_DECIMALS:
  47. .. _class_VisualScriptBuiltinFunc_constant_MATH_STEPIFY:
  48. .. _class_VisualScriptBuiltinFunc_constant_MATH_LERP:
  49. .. _class_VisualScriptBuiltinFunc_constant_MATH_INVERSE_LERP:
  50. .. _class_VisualScriptBuiltinFunc_constant_MATH_RANGE_LERP:
  51. .. _class_VisualScriptBuiltinFunc_constant_MATH_MOVE_TOWARD:
  52. .. _class_VisualScriptBuiltinFunc_constant_MATH_DECTIME:
  53. .. _class_VisualScriptBuiltinFunc_constant_MATH_RANDOMIZE:
  54. .. _class_VisualScriptBuiltinFunc_constant_MATH_RAND:
  55. .. _class_VisualScriptBuiltinFunc_constant_MATH_RANDF:
  56. .. _class_VisualScriptBuiltinFunc_constant_MATH_RANDOM:
  57. .. _class_VisualScriptBuiltinFunc_constant_MATH_SEED:
  58. .. _class_VisualScriptBuiltinFunc_constant_MATH_RANDSEED:
  59. .. _class_VisualScriptBuiltinFunc_constant_MATH_DEG2RAD:
  60. .. _class_VisualScriptBuiltinFunc_constant_MATH_RAD2DEG:
  61. .. _class_VisualScriptBuiltinFunc_constant_MATH_LINEAR2DB:
  62. .. _class_VisualScriptBuiltinFunc_constant_MATH_DB2LINEAR:
  63. .. _class_VisualScriptBuiltinFunc_constant_MATH_POLAR2CARTESIAN:
  64. .. _class_VisualScriptBuiltinFunc_constant_MATH_CARTESIAN2POLAR:
  65. .. _class_VisualScriptBuiltinFunc_constant_MATH_WRAP:
  66. .. _class_VisualScriptBuiltinFunc_constant_MATH_WRAPF:
  67. .. _class_VisualScriptBuiltinFunc_constant_LOGIC_MAX:
  68. .. _class_VisualScriptBuiltinFunc_constant_LOGIC_MIN:
  69. .. _class_VisualScriptBuiltinFunc_constant_LOGIC_CLAMP:
  70. .. _class_VisualScriptBuiltinFunc_constant_LOGIC_NEAREST_PO2:
  71. .. _class_VisualScriptBuiltinFunc_constant_OBJ_WEAKREF:
  72. .. _class_VisualScriptBuiltinFunc_constant_FUNC_FUNCREF:
  73. .. _class_VisualScriptBuiltinFunc_constant_TYPE_CONVERT:
  74. .. _class_VisualScriptBuiltinFunc_constant_TYPE_OF:
  75. .. _class_VisualScriptBuiltinFunc_constant_TYPE_EXISTS:
  76. .. _class_VisualScriptBuiltinFunc_constant_TEXT_CHAR:
  77. .. _class_VisualScriptBuiltinFunc_constant_TEXT_STR:
  78. .. _class_VisualScriptBuiltinFunc_constant_TEXT_PRINT:
  79. .. _class_VisualScriptBuiltinFunc_constant_TEXT_PRINTERR:
  80. .. _class_VisualScriptBuiltinFunc_constant_TEXT_PRINTRAW:
  81. .. _class_VisualScriptBuiltinFunc_constant_VAR_TO_STR:
  82. .. _class_VisualScriptBuiltinFunc_constant_STR_TO_VAR:
  83. .. _class_VisualScriptBuiltinFunc_constant_VAR_TO_BYTES:
  84. .. _class_VisualScriptBuiltinFunc_constant_BYTES_TO_VAR:
  85. .. _class_VisualScriptBuiltinFunc_constant_COLORN:
  86. .. _class_VisualScriptBuiltinFunc_constant_MATH_SMOOTHSTEP:
  87. .. _class_VisualScriptBuiltinFunc_constant_MATH_POSMOD:
  88. .. _class_VisualScriptBuiltinFunc_constant_MATH_LERP_ANGLE:
  89. .. _class_VisualScriptBuiltinFunc_constant_TEXT_ORD:
  90. .. _class_VisualScriptBuiltinFunc_constant_FUNC_MAX:
  91. enum **BuiltinFunc**:
  92. - **MATH_SIN** = **0** --- Return the sine of the input.
  93. - **MATH_COS** = **1** --- Return the cosine of the input.
  94. - **MATH_TAN** = **2** --- Return the tangent of the input.
  95. - **MATH_SINH** = **3** --- Return the hyperbolic sine of the input.
  96. - **MATH_COSH** = **4** --- Return the hyperbolic cosine of the input.
  97. - **MATH_TANH** = **5** --- Return the hyperbolic tangent of the input.
  98. - **MATH_ASIN** = **6** --- Return the arc sine of the input.
  99. - **MATH_ACOS** = **7** --- Return the arc cosine of the input.
  100. - **MATH_ATAN** = **8** --- Return the arc tangent of the input.
  101. - **MATH_ATAN2** = **9** --- Return the arc tangent of the input, using the signs of both parameters to determine the exact angle.
  102. - **MATH_SQRT** = **10** --- Return the square root of the input.
  103. - **MATH_FMOD** = **11** --- Return the remainder of one input divided by the other, using floating-point numbers.
  104. - **MATH_FPOSMOD** = **12** --- Return the positive remainder of one input divided by the other, using floating-point numbers.
  105. - **MATH_FLOOR** = **13** --- Return the input rounded down.
  106. - **MATH_CEIL** = **14** --- Return the input rounded up.
  107. - **MATH_ROUND** = **15** --- Return the input rounded to the nearest integer.
  108. - **MATH_ABS** = **16** --- Return the absolute value of the input.
  109. - **MATH_SIGN** = **17** --- Return the sign of the input, turning it into 1, -1, or 0. Useful to determine if the input is positive or negative.
  110. - **MATH_POW** = **18** --- Return the input raised to a given power.
  111. - **MATH_LOG** = **19** --- Return the natural logarithm of the input. Note that this is not the typical base-10 logarithm function calculators use.
  112. - **MATH_EXP** = **20** --- Return the mathematical constant **e** raised to the specified power of the input. **e** has an approximate value of 2.71828.
  113. - **MATH_ISNAN** = **21** --- Return whether the input is NaN (Not a Number) or not. NaN is usually produced by dividing 0 by 0, though other ways exist.
  114. - **MATH_ISINF** = **22** --- Return whether the input is an infinite floating-point number or not. Infinity is usually produced by dividing a number by 0, though other ways exist.
  115. - **MATH_EASE** = **23** --- 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.
  116. - **MATH_DECIMALS** = **24** --- Return the number of digit places after the decimal that the first non-zero digit occurs.
  117. - **MATH_STEPIFY** = **25** --- Return the input snapped to a given step.
  118. - **MATH_LERP** = **26** --- Return a number linearly interpolated between the first two inputs, based on the third input. Uses the formula ``a + (a - b) * t``.
  119. - **MATH_INVERSE_LERP** = **27**
  120. - **MATH_RANGE_LERP** = **28**
  121. - **MATH_MOVE_TOWARD** = **29** --- Moves the number toward a value, based on the third input.
  122. - **MATH_DECTIME** = **30** --- Return the result of ``value`` decreased by ``step`` \* ``amount``.
  123. - **MATH_RANDOMIZE** = **31** --- Randomize the seed (or the internal state) of the random number generator. Current implementation reseeds using a number based on time.
  124. - **MATH_RAND** = **32** --- Return a random 32 bits integer value. To obtain a random value between 0 to N (where N is smaller than 2^32 - 1), you can use it with the remainder function.
  125. - **MATH_RANDF** = **33** --- Return a random floating-point value between 0 and 1. To obtain a random value between 0 to N, you can use it with multiplication.
  126. - **MATH_RANDOM** = **34** --- Return a random floating-point value between the two inputs.
  127. - **MATH_SEED** = **35** --- Set the seed for the random number generator.
  128. - **MATH_RANDSEED** = **36** --- Return a random value from the given seed, along with the new seed.
  129. - **MATH_DEG2RAD** = **37** --- Convert the input from degrees to radians.
  130. - **MATH_RAD2DEG** = **38** --- Convert the input from radians to degrees.
  131. - **MATH_LINEAR2DB** = **39** --- Convert the input from linear volume to decibel volume.
  132. - **MATH_DB2LINEAR** = **40** --- Convert the input from decibel volume to linear volume.
  133. - **MATH_POLAR2CARTESIAN** = **41** --- 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).
  134. - **MATH_CARTESIAN2POLAR** = **42** --- 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).
  135. - **MATH_WRAP** = **43**
  136. - **MATH_WRAPF** = **44**
  137. - **LOGIC_MAX** = **45** --- Return the greater of the two numbers, also known as their maximum.
  138. - **LOGIC_MIN** = **46** --- Return the lesser of the two numbers, also known as their minimum.
  139. - **LOGIC_CLAMP** = **47** --- Return the input clamped inside the given range, ensuring the result is never outside it. Equivalent to ``min(max(input, range_low), range_high)``.
  140. - **LOGIC_NEAREST_PO2** = **48** --- Return the nearest power of 2 to the input.
  141. - **OBJ_WEAKREF** = **49** --- Create a :ref:`WeakRef<class_WeakRef>` from the input.
  142. - **FUNC_FUNCREF** = **50** --- Create a :ref:`FuncRef<class_FuncRef>` from the input.
  143. - **TYPE_CONVERT** = **51** --- Convert between types.
  144. - **TYPE_OF** = **52** --- Return the type of the input as an integer. Check :ref:`Variant.Type<enum_@GlobalScope_Variant.Type>` for the integers that might be returned.
  145. - **TYPE_EXISTS** = **53** --- Checks if a type is registered in the :ref:`ClassDB<class_ClassDB>`.
  146. - **TEXT_CHAR** = **54** --- Return a character with the given ascii value.
  147. - **TEXT_STR** = **55** --- Convert the input to a string.
  148. - **TEXT_PRINT** = **56** --- Print the given string to the output window.
  149. - **TEXT_PRINTERR** = **57** --- Print the given string to the standard error output.
  150. - **TEXT_PRINTRAW** = **58** --- Print the given string to the standard output, without adding a newline.
  151. - **VAR_TO_STR** = **59** --- Serialize a :ref:`Variant<class_Variant>` to a string.
  152. - **STR_TO_VAR** = **60** --- Deserialize a :ref:`Variant<class_Variant>` from a string serialized using :ref:`VAR_TO_STR<class_VisualScriptBuiltinFunc_constant_VAR_TO_STR>`.
  153. - **VAR_TO_BYTES** = **61** --- Serialize a :ref:`Variant<class_Variant>` to a :ref:`PoolByteArray<class_PoolByteArray>`.
  154. - **BYTES_TO_VAR** = **62** --- Deserialize a :ref:`Variant<class_Variant>` from a :ref:`PoolByteArray<class_PoolByteArray>` serialized using :ref:`VAR_TO_BYTES<class_VisualScriptBuiltinFunc_constant_VAR_TO_BYTES>`.
  155. - **COLORN** = **63** --- Return the :ref:`Color<class_Color>` with the given name and alpha ranging from 0 to 1.
  156. **Note:** Names are defined in ``color_names.inc``.
  157. - **MATH_SMOOTHSTEP** = **64** --- Return a number smoothly interpolated between the first two inputs, based on the third input. Similar to :ref:`MATH_LERP<class_VisualScriptBuiltinFunc_constant_MATH_LERP>`, but interpolates faster at the beginning and slower at the end. Using Hermite interpolation formula:
  158. ::
  159. var t = clamp((weight - from) / (to - from), 0.0, 1.0)
  160. return t * t * (3.0 - 2.0 * t)
  161. - **MATH_POSMOD** = **65**
  162. - **MATH_LERP_ANGLE** = **66**
  163. - **TEXT_ORD** = **67**
  164. - **FUNC_MAX** = **68** --- Represents the size of the :ref:`BuiltinFunc<enum_VisualScriptBuiltinFunc_BuiltinFunc>` enum.
  165. Property Descriptions
  166. ---------------------
  167. .. _class_VisualScriptBuiltinFunc_property_function:
  168. - :ref:`BuiltinFunc<enum_VisualScriptBuiltinFunc_BuiltinFunc>` **function**
  169. +-----------+-----------------+
  170. | *Default* | ``0`` |
  171. +-----------+-----------------+
  172. | *Setter* | set_func(value) |
  173. +-----------+-----------------+
  174. | *Getter* | get_func() |
  175. +-----------+-----------------+
  176. The function to be executed.
  177. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  178. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  179. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`