class_gdscript.rst 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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|
  37. Returns a new instance of the script.
  38. For example:
  39. ::
  40. var MyClass = load("myclass.gd")
  41. var instance = MyClass.new()
  42. assert(instance.get_script() == MyClass)
  43. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  44. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  45. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  46. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  47. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  48. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`
  49. .. |bitfield| replace:: :abbr:`BitField (This value is an integer composed as a bitmask of the following flags.)`