class_script.rst 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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:`VisualScript<class_visualscript>`, :ref:`GDScript<class_gdscript>`, :ref:`CSharpScript<class_csharpscript>`, :ref:`NativeScript<class_nativescript>`
  9. **Category:** Core
  10. Brief Description
  11. -----------------
  12. A class stored as a resource.
  13. Member Functions
  14. ----------------
  15. +------------------------------+----------------------------------------------------------------------------------------------------------------------+
  16. | :ref:`bool<class_bool>` | :ref:`can_instance<class_Script_can_instance>` **(** **)** const |
  17. +------------------------------+----------------------------------------------------------------------------------------------------------------------+
  18. | :ref:`String<class_string>` | :ref:`get_node_type<class_Script_get_node_type>` **(** **)** const |
  19. +------------------------------+----------------------------------------------------------------------------------------------------------------------+
  20. | :ref:`String<class_string>` | :ref:`get_source_code<class_Script_get_source_code>` **(** **)** const |
  21. +------------------------------+----------------------------------------------------------------------------------------------------------------------+
  22. | :ref:`bool<class_bool>` | :ref:`has_script_signal<class_Script_has_script_signal>` **(** :ref:`String<class_string>` signal_name **)** const |
  23. +------------------------------+----------------------------------------------------------------------------------------------------------------------+
  24. | :ref:`bool<class_bool>` | :ref:`has_source_code<class_Script_has_source_code>` **(** **)** const |
  25. +------------------------------+----------------------------------------------------------------------------------------------------------------------+
  26. | :ref:`bool<class_bool>` | :ref:`instance_has<class_Script_instance_has>` **(** :ref:`Object<class_object>` base_object **)** const |
  27. +------------------------------+----------------------------------------------------------------------------------------------------------------------+
  28. | :ref:`bool<class_bool>` | :ref:`is_tool<class_Script_is_tool>` **(** **)** const |
  29. +------------------------------+----------------------------------------------------------------------------------------------------------------------+
  30. | :ref:`int<class_int>` | :ref:`reload<class_Script_reload>` **(** :ref:`bool<class_bool>` keep_state=false **)** |
  31. +------------------------------+----------------------------------------------------------------------------------------------------------------------+
  32. | void | :ref:`set_source_code<class_Script_set_source_code>` **(** :ref:`String<class_string>` source **)** |
  33. +------------------------------+----------------------------------------------------------------------------------------------------------------------+
  34. Description
  35. -----------
  36. A class stored as a resource. The script exends the functionality of all objects that instance it.
  37. The 'new' method of a script subclass creates a new instance. :ref:`Object.set_script<class_Object_set_script>` extends an existing object, if that object's class matches one of the script's base classes.
  38. Member Function Description
  39. ---------------------------
  40. .. _class_Script_can_instance:
  41. - :ref:`bool<class_bool>` **can_instance** **(** **)** const
  42. Returns true if the script can be instanced.
  43. .. _class_Script_get_node_type:
  44. - :ref:`String<class_string>` **get_node_type** **(** **)** const
  45. .. _class_Script_get_source_code:
  46. - :ref:`String<class_string>` **get_source_code** **(** **)** const
  47. Returns the script source code, or an empty string if source code is not available.
  48. .. _class_Script_has_script_signal:
  49. - :ref:`bool<class_bool>` **has_script_signal** **(** :ref:`String<class_string>` signal_name **)** const
  50. Returns true if the script, or a base class, defines a signal with the given name.
  51. .. _class_Script_has_source_code:
  52. - :ref:`bool<class_bool>` **has_source_code** **(** **)** const
  53. Returns true if the script contains non-empty source code.
  54. .. _class_Script_instance_has:
  55. - :ref:`bool<class_bool>` **instance_has** **(** :ref:`Object<class_object>` base_object **)** const
  56. Returns true if 'base_object' is an instance of this script.
  57. .. _class_Script_is_tool:
  58. - :ref:`bool<class_bool>` **is_tool** **(** **)** const
  59. Returns true if the script is a tool script. A tool script can run in the editor.
  60. .. _class_Script_reload:
  61. - :ref:`int<class_int>` **reload** **(** :ref:`bool<class_bool>` keep_state=false **)**
  62. Reloads the script's class implementation. Returns an error code.
  63. .. _class_Script_set_source_code:
  64. - void **set_source_code** **(** :ref:`String<class_string>` source **)**
  65. Sets the script source code. Does not reload the class implementation.