2
0

class_visualscriptcustomnode.rst 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  1. :github_url: hide
  2. .. Generated automatically by doc/tools/makerst.py in Godot's source tree.
  3. .. DO NOT EDIT THIS FILE, but the VisualScriptCustomNode.xml source instead.
  4. .. The source is found in doc/classes or modules/<name>/doc_classes.
  5. .. _class_VisualScriptCustomNode:
  6. VisualScriptCustomNode
  7. ======================
  8. **Inherits:** :ref:`VisualScriptNode<class_VisualScriptNode>` **<** :ref:`Resource<class_Resource>` **<** :ref:`Reference<class_Reference>` **<** :ref:`Object<class_Object>`
  9. A scripted Visual Script node.
  10. Description
  11. -----------
  12. A custom Visual Script node which can be scripted in powerful ways.
  13. Methods
  14. -------
  15. +-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  16. | :ref:`String<class_String>` | :ref:`_get_caption<class_VisualScriptCustomNode_method__get_caption>` **(** **)** |virtual| |
  17. +-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  18. | :ref:`String<class_String>` | :ref:`_get_category<class_VisualScriptCustomNode_method__get_category>` **(** **)** |virtual| |
  19. +-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  20. | :ref:`int<class_int>` | :ref:`_get_input_value_port_count<class_VisualScriptCustomNode_method__get_input_value_port_count>` **(** **)** |virtual| |
  21. +-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  22. | :ref:`String<class_String>` | :ref:`_get_input_value_port_name<class_VisualScriptCustomNode_method__get_input_value_port_name>` **(** :ref:`int<class_int>` idx **)** |virtual| |
  23. +-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  24. | :ref:`int<class_int>` | :ref:`_get_input_value_port_type<class_VisualScriptCustomNode_method__get_input_value_port_type>` **(** :ref:`int<class_int>` idx **)** |virtual| |
  25. +-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  26. | :ref:`int<class_int>` | :ref:`_get_output_sequence_port_count<class_VisualScriptCustomNode_method__get_output_sequence_port_count>` **(** **)** |virtual| |
  27. +-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  28. | :ref:`String<class_String>` | :ref:`_get_output_sequence_port_text<class_VisualScriptCustomNode_method__get_output_sequence_port_text>` **(** :ref:`int<class_int>` idx **)** |virtual| |
  29. +-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  30. | :ref:`int<class_int>` | :ref:`_get_output_value_port_count<class_VisualScriptCustomNode_method__get_output_value_port_count>` **(** **)** |virtual| |
  31. +-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  32. | :ref:`String<class_String>` | :ref:`_get_output_value_port_name<class_VisualScriptCustomNode_method__get_output_value_port_name>` **(** :ref:`int<class_int>` idx **)** |virtual| |
  33. +-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  34. | :ref:`int<class_int>` | :ref:`_get_output_value_port_type<class_VisualScriptCustomNode_method__get_output_value_port_type>` **(** :ref:`int<class_int>` idx **)** |virtual| |
  35. +-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  36. | :ref:`String<class_String>` | :ref:`_get_text<class_VisualScriptCustomNode_method__get_text>` **(** **)** |virtual| |
  37. +-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  38. | :ref:`int<class_int>` | :ref:`_get_working_memory_size<class_VisualScriptCustomNode_method__get_working_memory_size>` **(** **)** |virtual| |
  39. +-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  40. | :ref:`bool<class_bool>` | :ref:`_has_input_sequence_port<class_VisualScriptCustomNode_method__has_input_sequence_port>` **(** **)** |virtual| |
  41. +-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  42. | :ref:`Variant<class_Variant>` | :ref:`_step<class_VisualScriptCustomNode_method__step>` **(** :ref:`Array<class_Array>` inputs, :ref:`Array<class_Array>` outputs, :ref:`int<class_int>` start_mode, :ref:`Array<class_Array>` working_mem **)** |virtual| |
  43. +-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  44. Enumerations
  45. ------------
  46. .. _enum_VisualScriptCustomNode_StartMode:
  47. .. _class_VisualScriptCustomNode_constant_START_MODE_BEGIN_SEQUENCE:
  48. .. _class_VisualScriptCustomNode_constant_START_MODE_CONTINUE_SEQUENCE:
  49. .. _class_VisualScriptCustomNode_constant_START_MODE_RESUME_YIELD:
  50. enum **StartMode**:
  51. - **START_MODE_BEGIN_SEQUENCE** = **0** --- The start mode used the first time when :ref:`_step<class_VisualScriptCustomNode_method__step>` is called.
  52. - **START_MODE_CONTINUE_SEQUENCE** = **1** --- The start mode used when :ref:`_step<class_VisualScriptCustomNode_method__step>` is called after coming back from a :ref:`STEP_PUSH_STACK_BIT<class_VisualScriptCustomNode_constant_STEP_PUSH_STACK_BIT>`.
  53. - **START_MODE_RESUME_YIELD** = **2** --- The start mode used when :ref:`_step<class_VisualScriptCustomNode_method__step>` is called after resuming from :ref:`STEP_YIELD_BIT<class_VisualScriptCustomNode_constant_STEP_YIELD_BIT>`.
  54. Constants
  55. ---------
  56. .. _class_VisualScriptCustomNode_constant_STEP_PUSH_STACK_BIT:
  57. .. _class_VisualScriptCustomNode_constant_STEP_GO_BACK_BIT:
  58. .. _class_VisualScriptCustomNode_constant_STEP_NO_ADVANCE_BIT:
  59. .. _class_VisualScriptCustomNode_constant_STEP_EXIT_FUNCTION_BIT:
  60. .. _class_VisualScriptCustomNode_constant_STEP_YIELD_BIT:
  61. - **STEP_PUSH_STACK_BIT** = **16777216** --- Hint used by :ref:`_step<class_VisualScriptCustomNode_method__step>` to tell that control should return to it when there is no other node left to execute.
  62. This is used by :ref:`VisualScriptCondition<class_VisualScriptCondition>` to redirect the sequence to the "Done" port after the ``true``/``false`` branch has finished execution.
  63. - **STEP_GO_BACK_BIT** = **33554432** --- Hint used by :ref:`_step<class_VisualScriptCustomNode_method__step>` to tell that control should return back, either hitting a previous :ref:`STEP_PUSH_STACK_BIT<class_VisualScriptCustomNode_constant_STEP_PUSH_STACK_BIT>` or exiting the function.
  64. - **STEP_NO_ADVANCE_BIT** = **67108864**
  65. - **STEP_EXIT_FUNCTION_BIT** = **134217728** --- Hint used by :ref:`_step<class_VisualScriptCustomNode_method__step>` to tell that control should stop and exit the function.
  66. - **STEP_YIELD_BIT** = **268435456** --- Hint used by :ref:`_step<class_VisualScriptCustomNode_method__step>` to tell that the function should be yielded.
  67. Using this requires you to have at least one working memory slot, which is used for the :ref:`VisualScriptFunctionState<class_VisualScriptFunctionState>`.
  68. Method Descriptions
  69. -------------------
  70. .. _class_VisualScriptCustomNode_method__get_caption:
  71. - :ref:`String<class_String>` **_get_caption** **(** **)** |virtual|
  72. Return the node's title.
  73. ----
  74. .. _class_VisualScriptCustomNode_method__get_category:
  75. - :ref:`String<class_String>` **_get_category** **(** **)** |virtual|
  76. Return the node's category.
  77. ----
  78. .. _class_VisualScriptCustomNode_method__get_input_value_port_count:
  79. - :ref:`int<class_int>` **_get_input_value_port_count** **(** **)** |virtual|
  80. Return the count of input value ports.
  81. ----
  82. .. _class_VisualScriptCustomNode_method__get_input_value_port_name:
  83. - :ref:`String<class_String>` **_get_input_value_port_name** **(** :ref:`int<class_int>` idx **)** |virtual|
  84. Return the specified input port's name.
  85. ----
  86. .. _class_VisualScriptCustomNode_method__get_input_value_port_type:
  87. - :ref:`int<class_int>` **_get_input_value_port_type** **(** :ref:`int<class_int>` idx **)** |virtual|
  88. Return the specified input port's type. See the :ref:`Variant.Type<enum_@GlobalScope_Variant.Type>` values.
  89. ----
  90. .. _class_VisualScriptCustomNode_method__get_output_sequence_port_count:
  91. - :ref:`int<class_int>` **_get_output_sequence_port_count** **(** **)** |virtual|
  92. Return the amount of output **sequence** ports.
  93. ----
  94. .. _class_VisualScriptCustomNode_method__get_output_sequence_port_text:
  95. - :ref:`String<class_String>` **_get_output_sequence_port_text** **(** :ref:`int<class_int>` idx **)** |virtual|
  96. Return the specified **sequence** output's name.
  97. ----
  98. .. _class_VisualScriptCustomNode_method__get_output_value_port_count:
  99. - :ref:`int<class_int>` **_get_output_value_port_count** **(** **)** |virtual|
  100. Return the amount of output value ports.
  101. ----
  102. .. _class_VisualScriptCustomNode_method__get_output_value_port_name:
  103. - :ref:`String<class_String>` **_get_output_value_port_name** **(** :ref:`int<class_int>` idx **)** |virtual|
  104. Return the specified output's name.
  105. ----
  106. .. _class_VisualScriptCustomNode_method__get_output_value_port_type:
  107. - :ref:`int<class_int>` **_get_output_value_port_type** **(** :ref:`int<class_int>` idx **)** |virtual|
  108. Return the specified output's type. See the :ref:`Variant.Type<enum_@GlobalScope_Variant.Type>` values.
  109. ----
  110. .. _class_VisualScriptCustomNode_method__get_text:
  111. - :ref:`String<class_String>` **_get_text** **(** **)** |virtual|
  112. Return the custom node's text, which is shown right next to the input **sequence** port (if there is none, on the place that is usually taken by it).
  113. ----
  114. .. _class_VisualScriptCustomNode_method__get_working_memory_size:
  115. - :ref:`int<class_int>` **_get_working_memory_size** **(** **)** |virtual|
  116. Return the size of the custom node's working memory. See :ref:`_step<class_VisualScriptCustomNode_method__step>` for more details.
  117. ----
  118. .. _class_VisualScriptCustomNode_method__has_input_sequence_port:
  119. - :ref:`bool<class_bool>` **_has_input_sequence_port** **(** **)** |virtual|
  120. Return whether the custom node has an input **sequence** port.
  121. ----
  122. .. _class_VisualScriptCustomNode_method__step:
  123. - :ref:`Variant<class_Variant>` **_step** **(** :ref:`Array<class_Array>` inputs, :ref:`Array<class_Array>` outputs, :ref:`int<class_int>` start_mode, :ref:`Array<class_Array>` working_mem **)** |virtual|
  124. Execute the custom node's logic, returning the index of the output sequence port to use or a :ref:`String<class_String>` when there is an error.
  125. The ``inputs`` array contains the values of the input ports.
  126. ``outputs`` is an array whose indices should be set to the respective outputs.
  127. The ``start_mode`` is usually :ref:`START_MODE_BEGIN_SEQUENCE<class_VisualScriptCustomNode_constant_START_MODE_BEGIN_SEQUENCE>`, unless you have used the ``STEP_*`` constants.
  128. ``working_mem`` is an array which can be used to persist information between runs of the custom node.
  129. When returning, you can mask the returned value with one of the ``STEP_*`` constants.
  130. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  131. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  132. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`