class_gdscript.rst 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. :github_url: hide
  2. .. DO NOT EDIT THIS FILE!!!
  3. .. Generated automatically from Godot engine sources.
  4. .. Generator: https://github.com/godotengine/godot/tree/master/doc/tools/make_rst.py.
  5. .. XML source: https://github.com/godotengine/godot/tree/master/modules/gdscript/doc_classes/GDScript.xml.
  6. .. _class_GDScript:
  7. GDScript
  8. ========
  9. **Inherits:** :ref:`Script<class_Script>` **<** :ref:`Resource<class_Resource>` **<** :ref:`RefCounted<class_RefCounted>` **<** :ref:`Object<class_Object>`
  10. A script implemented in the GDScript programming language.
  11. .. rst-class:: classref-introduction-group
  12. Description
  13. -----------
  14. A script implemented in the GDScript programming language, saved with the ``.gd`` extension. The script extends the functionality of all objects that instantiate it.
  15. Calling :ref:`new<class_GDScript_method_new>` creates a new instance of the script. :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.
  16. If you are looking for GDScript's built-in functions, see :ref:`@GDScript<class_@GDScript>` instead.
  17. .. rst-class:: classref-introduction-group
  18. Tutorials
  19. ---------
  20. - :doc:`GDScript documentation index <../tutorials/scripting/gdscript/index>`
  21. .. rst-class:: classref-reftable-group
  22. Methods
  23. -------
  24. .. table::
  25. :widths: auto
  26. +-------------------------------+-----------------------------------------------------------+
  27. | :ref:`Variant<class_Variant>` | :ref:`new<class_GDScript_method_new>`\ (\ ...\ ) |vararg| |
  28. +-------------------------------+-----------------------------------------------------------+
  29. .. rst-class:: classref-section-separator
  30. ----
  31. .. rst-class:: classref-descriptions-group
  32. Method Descriptions
  33. -------------------
  34. .. _class_GDScript_method_new:
  35. .. rst-class:: classref-method
  36. :ref:`Variant<class_Variant>` **new**\ (\ ...\ ) |vararg| :ref:`🔗<class_GDScript_method_new>`
  37. Returns a new instance of the script.
  38. ::
  39. var MyClass = load("myclass.gd")
  40. var instance = MyClass.new()
  41. print(instance.get_script() == MyClass) # Prints true
  42. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  43. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  44. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  45. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  46. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  47. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`
  48. .. |bitfield| replace:: :abbr:`BitField (This value is an integer composed as a bitmask of the following flags.)`
  49. .. |void| replace:: :abbr:`void (No return value.)`