Script.xml 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <class name="Script" inherits="Resource" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
  3. <brief_description>
  4. A class stored as a resource.
  5. </brief_description>
  6. <description>
  7. A class stored as a resource. A script extends the functionality of all objects that instantiate it.
  8. This is the base class for all scripts and should not be used directly. Trying to create a new script with this class will result in an error.
  9. The [code]new[/code] method of a script subclass creates a new instance. [method Object.set_script] extends an existing object, if that object's class matches one of the script's base classes.
  10. </description>
  11. <tutorials>
  12. <link title="Scripting documentation index">$DOCS_URL/tutorials/scripting/index.html</link>
  13. </tutorials>
  14. <methods>
  15. <method name="can_instantiate" qualifiers="const">
  16. <return type="bool" />
  17. <description>
  18. Returns [code]true[/code] if the script can be instantiated.
  19. </description>
  20. </method>
  21. <method name="get_base_script" qualifiers="const">
  22. <return type="Script" />
  23. <description>
  24. Returns the script directly inherited by this script.
  25. </description>
  26. </method>
  27. <method name="get_global_name" qualifiers="const">
  28. <return type="StringName" />
  29. <description>
  30. Returns the class name associated with the script, if there is one. Returns an empty string otherwise.
  31. To give the script a global name, you can use the [code]class_name[/code] keyword in GDScript and the [code][GlobalClass][/code] attribute in C#.
  32. [codeblocks]
  33. [gdscript]
  34. class_name MyNode
  35. extends Node
  36. [/gdscript]
  37. [csharp]
  38. using Godot;
  39. [GlobalClass]
  40. public partial class MyNode : Node
  41. {
  42. }
  43. [/csharp]
  44. [/codeblocks]
  45. </description>
  46. </method>
  47. <method name="get_instance_base_type" qualifiers="const">
  48. <return type="StringName" />
  49. <description>
  50. Returns the script's base type.
  51. </description>
  52. </method>
  53. <method name="get_property_default_value">
  54. <return type="Variant" />
  55. <param index="0" name="property" type="StringName" />
  56. <description>
  57. Returns the default value of the specified property.
  58. </description>
  59. </method>
  60. <method name="get_rpc_config" qualifiers="const">
  61. <return type="Variant" />
  62. <description>
  63. Returns a [Dictionary] mapping method names to their RPC configuration defined by this script.
  64. </description>
  65. </method>
  66. <method name="get_script_constant_map">
  67. <return type="Dictionary" />
  68. <description>
  69. Returns a dictionary containing constant names and their values.
  70. </description>
  71. </method>
  72. <method name="get_script_method_list">
  73. <return type="Dictionary[]" />
  74. <description>
  75. Returns the list of methods in this [Script].
  76. </description>
  77. </method>
  78. <method name="get_script_property_list">
  79. <return type="Dictionary[]" />
  80. <description>
  81. Returns the list of properties in this [Script].
  82. </description>
  83. </method>
  84. <method name="get_script_signal_list">
  85. <return type="Dictionary[]" />
  86. <description>
  87. Returns the list of user signals defined in this [Script].
  88. </description>
  89. </method>
  90. <method name="has_script_signal" qualifiers="const">
  91. <return type="bool" />
  92. <param index="0" name="signal_name" type="StringName" />
  93. <description>
  94. Returns [code]true[/code] if the script, or a base class, defines a signal with the given name.
  95. </description>
  96. </method>
  97. <method name="has_source_code" qualifiers="const">
  98. <return type="bool" />
  99. <description>
  100. Returns [code]true[/code] if the script contains non-empty source code.
  101. [b]Note:[/b] If a script does not have source code, this does not mean that it is invalid or unusable. For example, a [GDScript] that was exported with binary tokenization has no source code, but still behaves as expected and could be instantiated. This can be checked with [method can_instantiate].
  102. </description>
  103. </method>
  104. <method name="instance_has" qualifiers="const">
  105. <return type="bool" />
  106. <param index="0" name="base_object" type="Object" />
  107. <description>
  108. Returns [code]true[/code] if [param base_object] is an instance of this script.
  109. </description>
  110. </method>
  111. <method name="is_abstract" qualifiers="const">
  112. <return type="bool" />
  113. <description>
  114. Returns [code]true[/code] if the script is an abstract script. An abstract script does not have a constructor and cannot be instantiated.
  115. </description>
  116. </method>
  117. <method name="is_tool" qualifiers="const">
  118. <return type="bool" />
  119. <description>
  120. Returns [code]true[/code] if the script is a tool script. A tool script can run in the editor.
  121. </description>
  122. </method>
  123. <method name="reload">
  124. <return type="int" enum="Error" />
  125. <param index="0" name="keep_state" type="bool" default="false" />
  126. <description>
  127. Reloads the script's class implementation. Returns an error code.
  128. </description>
  129. </method>
  130. </methods>
  131. <members>
  132. <member name="source_code" type="String" setter="set_source_code" getter="get_source_code">
  133. The script source code or an empty string if source code is not available. When set, does not reload the class implementation automatically.
  134. </member>
  135. </members>
  136. </class>