:github_url: hide .. DO NOT EDIT THIS FILE!!! .. Generated automatically from Godot engine sources. .. Generator: https://github.com/godotengine/godot/tree/3.6/doc/tools/make_rst.py. .. XML source: https://github.com/godotengine/godot/tree/3.6/doc/classes/Script.xml. .. _class_Script: Script ====== **Inherits:** :ref:`Resource` **<** :ref:`Reference` **<** :ref:`Object` **Inherited By:** :ref:`CSharpScript`, :ref:`GDScript`, :ref:`NativeScript`, :ref:`PluginScript`, :ref:`VisualScript` A class stored as a resource. .. rst-class:: classref-introduction-group Description ----------- A class stored as a resource. A script extends the functionality of all objects that instance it. The ``new`` method of a script subclass creates a new instance. :ref:`Object.set_script` extends an existing object, if that object's class matches one of the script's base classes. .. rst-class:: classref-introduction-group Tutorials --------- - :doc:`../tutorials/scripting/index` .. rst-class:: classref-reftable-group Properties ---------- .. table:: :widths: auto +-----------------------------+-------------------------------------------------------+ | :ref:`String` | :ref:`source_code` | +-----------------------------+-------------------------------------------------------+ .. rst-class:: classref-reftable-group Methods ------- .. table:: :widths: auto +---------------------------------------+------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`bool` | :ref:`can_instance` **(** **)** |const| | +---------------------------------------+------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Script` | :ref:`get_base_script` **(** **)** |const| | +---------------------------------------+------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`String` | :ref:`get_instance_base_type` **(** **)** |const| | +---------------------------------------+------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Variant` | :ref:`get_property_default_value` **(** :ref:`String` property **)** | +---------------------------------------+------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Dictionary` | :ref:`get_script_constant_map` **(** **)** | +---------------------------------------+------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Array` | :ref:`get_script_method_list` **(** **)** | +---------------------------------------+------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Array` | :ref:`get_script_property_list` **(** **)** | +---------------------------------------+------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Array` | :ref:`get_script_signal_list` **(** **)** | +---------------------------------------+------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`bool` | :ref:`has_script_signal` **(** :ref:`String` signal_name **)** |const| | +---------------------------------------+------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`bool` | :ref:`has_source_code` **(** **)** |const| | +---------------------------------------+------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`bool` | :ref:`instance_has` **(** :ref:`Object` base_object **)** |const| | +---------------------------------------+------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`bool` | :ref:`is_tool` **(** **)** |const| | +---------------------------------------+------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Error` | :ref:`reload` **(** :ref:`bool` keep_state=false **)** | +---------------------------------------+------------------------------------------------------------------------------------------------------------------------------------+ .. rst-class:: classref-section-separator ---- .. rst-class:: classref-descriptions-group Property Descriptions --------------------- .. _class_Script_property_source_code: .. rst-class:: classref-property :ref:`String` **source_code** .. rst-class:: classref-property-setget - void **set_source_code** **(** :ref:`String` value **)** - :ref:`String` **get_source_code** **(** **)** The script source code or an empty string if source code is not available. When set, does not reload the class implementation automatically. .. rst-class:: classref-section-separator ---- .. rst-class:: classref-descriptions-group Method Descriptions ------------------- .. _class_Script_method_can_instance: .. rst-class:: classref-method :ref:`bool` **can_instance** **(** **)** |const| Returns ``true`` if the script can be instanced. .. rst-class:: classref-item-separator ---- .. _class_Script_method_get_base_script: .. rst-class:: classref-method :ref:`Script` **get_base_script** **(** **)** |const| Returns the script directly inherited by this script. .. rst-class:: classref-item-separator ---- .. _class_Script_method_get_instance_base_type: .. rst-class:: classref-method :ref:`String` **get_instance_base_type** **(** **)** |const| Returns the script's base type. .. rst-class:: classref-item-separator ---- .. _class_Script_method_get_property_default_value: .. rst-class:: classref-method :ref:`Variant` **get_property_default_value** **(** :ref:`String` property **)** Returns the default value of the specified property. .. rst-class:: classref-item-separator ---- .. _class_Script_method_get_script_constant_map: .. rst-class:: classref-method :ref:`Dictionary` **get_script_constant_map** **(** **)** Returns a dictionary containing constant names and their values. .. rst-class:: classref-item-separator ---- .. _class_Script_method_get_script_method_list: .. rst-class:: classref-method :ref:`Array` **get_script_method_list** **(** **)** Returns the list of methods in this **Script**. .. rst-class:: classref-item-separator ---- .. _class_Script_method_get_script_property_list: .. rst-class:: classref-method :ref:`Array` **get_script_property_list** **(** **)** Returns the list of properties in this **Script**. .. rst-class:: classref-item-separator ---- .. _class_Script_method_get_script_signal_list: .. rst-class:: classref-method :ref:`Array` **get_script_signal_list** **(** **)** Returns the list of user signals defined in this **Script**. .. rst-class:: classref-item-separator ---- .. _class_Script_method_has_script_signal: .. rst-class:: classref-method :ref:`bool` **has_script_signal** **(** :ref:`String` signal_name **)** |const| Returns ``true`` if the script, or a base class, defines a signal with the given name. .. rst-class:: classref-item-separator ---- .. _class_Script_method_has_source_code: .. rst-class:: classref-method :ref:`bool` **has_source_code** **(** **)** |const| Returns ``true`` if the script contains non-empty source code. .. rst-class:: classref-item-separator ---- .. _class_Script_method_instance_has: .. rst-class:: classref-method :ref:`bool` **instance_has** **(** :ref:`Object` base_object **)** |const| Returns ``true`` if ``base_object`` is an instance of this script. .. rst-class:: classref-item-separator ---- .. _class_Script_method_is_tool: .. rst-class:: classref-method :ref:`bool` **is_tool** **(** **)** |const| Returns ``true`` if the script is a tool script. A tool script can run in the editor. .. rst-class:: classref-item-separator ---- .. _class_Script_method_reload: .. rst-class:: classref-method :ref:`Error` **reload** **(** :ref:`bool` keep_state=false **)** Reloads the script's class implementation. Returns an error code. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)` .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)` .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)` .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`