:github_url: hide .. Generated automatically by doc/tools/makerst.py in Godot's source tree. .. DO NOT EDIT THIS FILE, but the Script.xml source instead. .. The source is found in doc/classes or modules//doc_classes. .. _class_Script: Script ====== **Inherits:** :ref:`Resource` **<** :ref:`Reference` **<** :ref:`Object` **Inherited By:** :ref:`CSharpScript`, :ref:`GDScript`, :ref:`NativeScript`, :ref:`PluginScript`, :ref:`VisualScript` **Category:** Core Brief Description ----------------- A class stored as a resource. Properties ---------- +-----------------------------+-------------------------------------------------------+ | :ref:`String` | :ref:`source_code` | +-----------------------------+-------------------------------------------------------+ Methods ------- +---------------------------------------+---------------------------------------------------------------------------------------------------------------------------+ | :ref:`bool` | :ref:`can_instance` **(** **)** const | +---------------------------------------+---------------------------------------------------------------------------------------------------------------------------+ | :ref:`Script` | :ref:`get_base_script` **(** **)** const | +---------------------------------------+---------------------------------------------------------------------------------------------------------------------------+ | :ref:`String` | :ref:`get_instance_base_type` **(** **)** const | +---------------------------------------+---------------------------------------------------------------------------------------------------------------------------+ | :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 **)** | +---------------------------------------+---------------------------------------------------------------------------------------------------------------------------+ Description ----------- A class stored as a resource. A script exends 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. Tutorials --------- - :doc:`../getting_started/step_by_step/scripting` Property Descriptions --------------------- .. _class_Script_property_source_code: - :ref:`String` **source_code** +----------+------------------------+ | *Setter* | set_source_code(value) | +----------+------------------------+ | *Getter* | 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. Method Descriptions ------------------- .. _class_Script_method_can_instance: - :ref:`bool` **can_instance** **(** **)** const Returns ``true`` if the script can be instanced. ---- .. _class_Script_method_get_base_script: - :ref:`Script` **get_base_script** **(** **)** const Returns the script directly inherited by this script. ---- .. _class_Script_method_get_instance_base_type: - :ref:`String` **get_instance_base_type** **(** **)** const Returns the script's base type. ---- .. _class_Script_method_has_script_signal: - :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. ---- .. _class_Script_method_has_source_code: - :ref:`bool` **has_source_code** **(** **)** const Returns ``true`` if the script contains non-empty source code. ---- .. _class_Script_method_instance_has: - :ref:`bool` **instance_has** **(** :ref:`Object` base_object **)** const Returns ``true`` if ``base_object`` is an instance of this script. ---- .. _class_Script_method_is_tool: - :ref:`bool` **is_tool** **(** **)** const Returns ``true`` if the script is a tool script. A tool script can run in the editor. ---- .. _class_Script_method_reload: - :ref:`Error` **reload** **(** :ref:`bool` keep_state=false **)** Reloads the script's class implementation. Returns an error code.