class_gdscript.rst 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. :github_url: hide
  2. .. Generated automatically by doc/tools/makerst.py in Godot's source tree.
  3. .. DO NOT EDIT THIS FILE, but the GDScript.xml source instead.
  4. .. The source is found in doc/classes or modules/<name>/doc_classes.
  5. .. _class_GDScript:
  6. GDScript
  7. ========
  8. **Inherits:** :ref:`Script<class_Script>` **<** :ref:`Resource<class_Resource>` **<** :ref:`Reference<class_Reference>` **<** :ref:`Object<class_Object>`
  9. **Category:** Core
  10. Brief Description
  11. -----------------
  12. A script implemented in the GDScript programming language.
  13. Methods
  14. -------
  15. +-------------------------------------------+-----------------------------------------------------------------------------------+
  16. | :ref:`PoolByteArray<class_PoolByteArray>` | :ref:`get_as_byte_code<class_GDScript_method_get_as_byte_code>` **(** **)** const |
  17. +-------------------------------------------+-----------------------------------------------------------------------------------+
  18. | :ref:`Variant<class_Variant>` | :ref:`new<class_GDScript_method_new>` **(** ... **)** vararg |
  19. +-------------------------------------------+-----------------------------------------------------------------------------------+
  20. Description
  21. -----------
  22. A script implemented in the GDScript programming language. The script exends the functionality of all objects that instance it.
  23. :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.
  24. Tutorials
  25. ---------
  26. - :doc:`../getting_started/scripting/gdscript/index`
  27. Method Descriptions
  28. -------------------
  29. .. _class_GDScript_method_get_as_byte_code:
  30. - :ref:`PoolByteArray<class_PoolByteArray>` **get_as_byte_code** **(** **)** const
  31. Returns byte code for the script source code.
  32. .. _class_GDScript_method_new:
  33. - :ref:`Variant<class_Variant>` **new** **(** ... **)** vararg
  34. Returns a new instance of the script.
  35. For example:
  36. ::
  37. var MyClass = load("myclass.gd")
  38. var instance = MyClass.new()
  39. assert(instance.get_script() == MyClass)