class_script.rst 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. .. Generated automatically by doc/tools/makerst.py in Godot's source tree.
  2. .. DO NOT EDIT THIS FILE, but the Script.xml source instead.
  3. .. The source is found in doc/classes or modules/<name>/doc_classes.
  4. .. _class_Script:
  5. Script
  6. ======
  7. **Inherits:** :ref:`Resource<class_Resource>` **<** :ref:`Reference<class_Reference>` **<** :ref:`Object<class_Object>`
  8. **Inherited By:** :ref:`CSharpScript<class_CSharpScript>`, :ref:`GDScript<class_GDScript>`, :ref:`NativeScript<class_NativeScript>`, :ref:`PluginScript<class_PluginScript>`, :ref:`VisualScript<class_VisualScript>`
  9. **Category:** Core
  10. Brief Description
  11. -----------------
  12. A class stored as a resource.
  13. Properties
  14. ----------
  15. +-----------------------------+-------------------------------------------------------+
  16. | :ref:`String<class_String>` | :ref:`source_code<class_Script_property_source_code>` |
  17. +-----------------------------+-------------------------------------------------------+
  18. Methods
  19. -------
  20. +---------------------------------------+---------------------------------------------------------------------------------------------------------------------------+
  21. | :ref:`bool<class_bool>` | :ref:`can_instance<class_Script_method_can_instance>` **(** **)** const |
  22. +---------------------------------------+---------------------------------------------------------------------------------------------------------------------------+
  23. | :ref:`Script<class_Script>` | :ref:`get_base_script<class_Script_method_get_base_script>` **(** **)** const |
  24. +---------------------------------------+---------------------------------------------------------------------------------------------------------------------------+
  25. | :ref:`String<class_String>` | :ref:`get_instance_base_type<class_Script_method_get_instance_base_type>` **(** **)** const |
  26. +---------------------------------------+---------------------------------------------------------------------------------------------------------------------------+
  27. | :ref:`bool<class_bool>` | :ref:`has_script_signal<class_Script_method_has_script_signal>` **(** :ref:`String<class_String>` signal_name **)** const |
  28. +---------------------------------------+---------------------------------------------------------------------------------------------------------------------------+
  29. | :ref:`bool<class_bool>` | :ref:`has_source_code<class_Script_method_has_source_code>` **(** **)** const |
  30. +---------------------------------------+---------------------------------------------------------------------------------------------------------------------------+
  31. | :ref:`bool<class_bool>` | :ref:`instance_has<class_Script_method_instance_has>` **(** :ref:`Object<class_Object>` base_object **)** const |
  32. +---------------------------------------+---------------------------------------------------------------------------------------------------------------------------+
  33. | :ref:`bool<class_bool>` | :ref:`is_tool<class_Script_method_is_tool>` **(** **)** const |
  34. +---------------------------------------+---------------------------------------------------------------------------------------------------------------------------+
  35. | :ref:`Error<enum_@GlobalScope_Error>` | :ref:`reload<class_Script_method_reload>` **(** :ref:`bool<class_bool>` keep_state=false **)** |
  36. +---------------------------------------+---------------------------------------------------------------------------------------------------------------------------+
  37. Description
  38. -----------
  39. A class stored as a resource. A script exends the functionality of all objects that instance it.
  40. The ``new`` method of a script subclass creates a new instance. :ref:`Object.set_script<class_Object_method_set_script>` extends an existing object, if that object's class matches one of the script's base classes.
  41. Tutorials
  42. ---------
  43. - :doc:`../getting_started/step_by_step/scripting`
  44. Property Descriptions
  45. ---------------------
  46. .. _class_Script_property_source_code:
  47. - :ref:`String<class_String>` **source_code**
  48. +----------+------------------------+
  49. | *Setter* | set_source_code(value) |
  50. +----------+------------------------+
  51. | *Getter* | get_source_code() |
  52. +----------+------------------------+
  53. The script source code or an empty string if source code is not available. When set, does not reload the class implementation automatically.
  54. Method Descriptions
  55. -------------------
  56. .. _class_Script_method_can_instance:
  57. - :ref:`bool<class_bool>` **can_instance** **(** **)** const
  58. Returns ``true`` if the script can be instanced.
  59. .. _class_Script_method_get_base_script:
  60. - :ref:`Script<class_Script>` **get_base_script** **(** **)** const
  61. Returns the script directly inherited by this script.
  62. .. _class_Script_method_get_instance_base_type:
  63. - :ref:`String<class_String>` **get_instance_base_type** **(** **)** const
  64. Returns the script's base type.
  65. .. _class_Script_method_has_script_signal:
  66. - :ref:`bool<class_bool>` **has_script_signal** **(** :ref:`String<class_String>` signal_name **)** const
  67. Returns ``true`` if the script, or a base class, defines a signal with the given name.
  68. .. _class_Script_method_has_source_code:
  69. - :ref:`bool<class_bool>` **has_source_code** **(** **)** const
  70. Returns ``true`` if the script contains non-empty source code.
  71. .. _class_Script_method_instance_has:
  72. - :ref:`bool<class_bool>` **instance_has** **(** :ref:`Object<class_Object>` base_object **)** const
  73. Returns ``true`` if ``base_object`` is an instance of this script.
  74. .. _class_Script_method_is_tool:
  75. - :ref:`bool<class_bool>` **is_tool** **(** **)** const
  76. Returns ``true`` if the script is a tool script. A tool script can run in the editor.
  77. .. _class_Script_method_reload:
  78. - :ref:`Error<enum_@GlobalScope_Error>` **reload** **(** :ref:`bool<class_bool>` keep_state=false **)**
  79. Reloads the script's class implementation. Returns an error code.