class_gdscript.rst 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. :github_url: hide
  2. .. Generated automatically by doc/tools/make_rst.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. A script implemented in the GDScript programming language.
  10. Description
  11. -----------
  12. A script implemented in the GDScript programming language. The script extends the functionality of all objects that instance it.
  13. :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.
  14. Tutorials
  15. ---------
  16. - :doc:`../tutorials/scripting/gdscript/index`
  17. Methods
  18. -------
  19. +-------------------------------------------+-------------------------------------------------------------------------------------+
  20. | :ref:`PoolByteArray<class_PoolByteArray>` | :ref:`get_as_byte_code<class_GDScript_method_get_as_byte_code>` **(** **)** |const| |
  21. +-------------------------------------------+-------------------------------------------------------------------------------------+
  22. | :ref:`Variant<class_Variant>` | :ref:`new<class_GDScript_method_new>` **(** ... **)** |vararg| |
  23. +-------------------------------------------+-------------------------------------------------------------------------------------+
  24. Method Descriptions
  25. -------------------
  26. .. _class_GDScript_method_get_as_byte_code:
  27. - :ref:`PoolByteArray<class_PoolByteArray>` **get_as_byte_code** **(** **)** |const|
  28. Returns byte code for the script source code.
  29. ----
  30. .. _class_GDScript_method_new:
  31. - :ref:`Variant<class_Variant>` **new** **(** ... **)** |vararg|
  32. Returns a new instance of the script.
  33. For example:
  34. ::
  35. var MyClass = load("myclass.gd")
  36. var instance = MyClass.new()
  37. assert(instance.get_script() == MyClass)
  38. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  39. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  40. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`