0.2.0-dev Download ZIP
148 lines ·6.0 KB Raw
| 1 | <?xml version="1.0" encoding="UTF-8" ?> |
| 2 | <class name="Script" inherits="Resource" api_type="core" 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 | |
| 40 | [GlobalClass] |
| 41 | public partial class MyNode : Node |
| 42 | { |
| 43 | } |
| 44 | [/csharp] |
| 45 | [/codeblocks] |
| 46 | </description> |
| 47 | </method> |
| 48 | <method name="get_instance_base_type" qualifiers="const"> |
| 49 | <return type="StringName" /> |
| 50 | <description> |
| 51 | Returns the script's base type. |
| 52 | </description> |
| 53 | </method> |
| 54 | <method name="get_property_default_value"> |
| 55 | <return type="Variant" /> |
| 56 | <param index="0" name="property" type="StringName" /> |
| 57 | <description> |
| 58 | Returns the default value of the specified property. |
| 59 | [b]Note:[/b] In GDScript and C#, this method returns [code]null[/code] outside of editor builds. |
| 60 | </description> |
| 61 | </method> |
| 62 | <method name="get_rpc_config" qualifiers="const"> |
| 63 | <return type="Variant" /> |
| 64 | <description> |
| 65 | Returns a [Dictionary] mapping method names to their RPC configuration defined by this script. |
| 66 | </description> |
| 67 | </method> |
| 68 | <method name="get_script_constant_map"> |
| 69 | <return type="Dictionary" /> |
| 70 | <description> |
| 71 | Returns a dictionary containing constant names and their values. |
| 72 | </description> |
| 73 | </method> |
| 74 | <method name="get_script_method_list"> |
| 75 | <return type="Dictionary[]" /> |
| 76 | <description> |
| 77 | Returns the list of methods in this [Script]. |
| 78 | [b]Note:[/b] The dictionaries returned by this method are formatted identically to those returned by [method Object.get_method_list]. |
| 79 | </description> |
| 80 | </method> |
| 81 | <method name="get_script_property_list"> |
| 82 | <return type="Dictionary[]" /> |
| 83 | <description> |
| 84 | Returns the list of properties in this [Script]. |
| 85 | [b]Note:[/b] The dictionaries returned by this method are formatted identically to those returned by [method Object.get_property_list]. |
| 86 | </description> |
| 87 | </method> |
| 88 | <method name="get_script_signal_list"> |
| 89 | <return type="Dictionary[]" /> |
| 90 | <description> |
| 91 | Returns the list of signals defined in this [Script]. |
| 92 | [b]Note:[/b] The dictionaries returned by this method are formatted identically to those returned by [method Object.get_signal_list]. |
| 93 | </description> |
| 94 | </method> |
| 95 | <method name="has_script_method" qualifiers="const"> |
| 96 | <return type="bool" /> |
| 97 | <param index="0" name="method_name" type="StringName" /> |
| 98 | <description> |
| 99 | Returns [code]true[/code] if the script, or a base class, defines a method with the given name. |
| 100 | </description> |
| 101 | </method> |
| 102 | <method name="has_script_signal" qualifiers="const"> |
| 103 | <return type="bool" /> |
| 104 | <param index="0" name="signal_name" type="StringName" /> |
| 105 | <description> |
| 106 | Returns [code]true[/code] if the script, or a base class, defines a signal with the given name. |
| 107 | </description> |
| 108 | </method> |
| 109 | <method name="has_source_code" qualifiers="const"> |
| 110 | <return type="bool" /> |
| 111 | <description> |
| 112 | Returns [code]true[/code] if the script contains non-empty source code. |
| 113 | [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]. |
| 114 | </description> |
| 115 | </method> |
| 116 | <method name="instance_has" qualifiers="const" deprecated="Compare this script with [method Object.get_script] instead."> |
| 117 | <return type="bool" /> |
| 118 | <param index="0" name="base_object" type="Object" /> |
| 119 | <description> |
| 120 | Returns [code]true[/code] if [param base_object] is an instance of this script. |
| 121 | </description> |
| 122 | </method> |
| 123 | <method name="is_abstract" qualifiers="const"> |
| 124 | <return type="bool" /> |
| 125 | <description> |
| 126 | Returns [code]true[/code] if the script is an abstract script. An abstract script does not have a constructor and cannot be instantiated. |
| 127 | </description> |
| 128 | </method> |
| 129 | <method name="is_tool" qualifiers="const"> |
| 130 | <return type="bool" /> |
| 131 | <description> |
| 132 | Returns [code]true[/code] if the script is a tool script. A tool script can run in the editor. |
| 133 | </description> |
| 134 | </method> |
| 135 | <method name="reload"> |
| 136 | <return type="int" enum="Error" /> |
| 137 | <param index="0" name="keep_state" type="bool" default="false" /> |
| 138 | <description> |
| 139 | Reloads the script's class implementation. Returns an error code. |
| 140 | </description> |
| 141 | </method> |
| 142 | </methods> |
| 143 | <members> |
| 144 | <member name="source_code" type="String" setter="set_source_code" getter="get_source_code"> |
| 145 | The script source code or an empty string if source code is not available. When set, does not reload the class implementation automatically. |
| 146 | </member> |
| 147 | </members> |
| 148 | </class> |