class_globals.rst 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. .. Generated automatically by doc/tools/makerst.py in Godot's source tree.
  2. .. DO NOT EDIT THIS FILE, but the doc/base/classes.xml source instead.
  3. .. _class_Globals:
  4. Globals
  5. =======
  6. **Inherits:** :ref:`Object<class_object>`
  7. **Category:** Core
  8. Brief Description
  9. -----------------
  10. Contains global variables accessible from everywhere.
  11. Member Functions
  12. ----------------
  13. +------------------------------+------------------------------------------------------------------------------------------------------------------------------------+
  14. | void | :ref:`add_property_info<class_Globals_add_property_info>` **(** :ref:`Dictionary<class_dictionary>` hint **)** |
  15. +------------------------------+------------------------------------------------------------------------------------------------------------------------------------+
  16. | void | :ref:`clear<class_Globals_clear>` **(** :ref:`String<class_string>` name **)** |
  17. +------------------------------+------------------------------------------------------------------------------------------------------------------------------------+
  18. | :ref:`int<class_int>` | :ref:`get_order<class_Globals_get_order>` **(** :ref:`String<class_string>` name **)** const |
  19. +------------------------------+------------------------------------------------------------------------------------------------------------------------------------+
  20. | :ref:`Object<class_object>` | :ref:`get_singleton<class_Globals_get_singleton>` **(** :ref:`String<class_string>` name **)** const |
  21. +------------------------------+------------------------------------------------------------------------------------------------------------------------------------+
  22. | :ref:`String<class_string>` | :ref:`globalize_path<class_Globals_globalize_path>` **(** :ref:`String<class_string>` path **)** const |
  23. +------------------------------+------------------------------------------------------------------------------------------------------------------------------------+
  24. | :ref:`bool<class_bool>` | :ref:`has<class_Globals_has>` **(** :ref:`String<class_string>` name **)** const |
  25. +------------------------------+------------------------------------------------------------------------------------------------------------------------------------+
  26. | :ref:`bool<class_bool>` | :ref:`has_singleton<class_Globals_has_singleton>` **(** :ref:`String<class_string>` name **)** const |
  27. +------------------------------+------------------------------------------------------------------------------------------------------------------------------------+
  28. | :ref:`bool<class_bool>` | :ref:`is_persisting<class_Globals_is_persisting>` **(** :ref:`String<class_string>` name **)** const |
  29. +------------------------------+------------------------------------------------------------------------------------------------------------------------------------+
  30. | :ref:`bool<class_bool>` | :ref:`load_resource_pack<class_Globals_load_resource_pack>` **(** :ref:`String<class_string>` pack **)** |
  31. +------------------------------+------------------------------------------------------------------------------------------------------------------------------------+
  32. | :ref:`String<class_string>` | :ref:`localize_path<class_Globals_localize_path>` **(** :ref:`String<class_string>` path **)** const |
  33. +------------------------------+------------------------------------------------------------------------------------------------------------------------------------+
  34. | :ref:`int<class_int>` | :ref:`save<class_Globals_save>` **(** **)** |
  35. +------------------------------+------------------------------------------------------------------------------------------------------------------------------------+
  36. | :ref:`int<class_int>` | :ref:`save_custom<class_Globals_save_custom>` **(** :ref:`String<class_string>` file **)** |
  37. +------------------------------+------------------------------------------------------------------------------------------------------------------------------------+
  38. | void | :ref:`set_order<class_Globals_set_order>` **(** :ref:`String<class_string>` name, :ref:`int<class_int>` pos **)** |
  39. +------------------------------+------------------------------------------------------------------------------------------------------------------------------------+
  40. | void | :ref:`set_persisting<class_Globals_set_persisting>` **(** :ref:`String<class_string>` name, :ref:`bool<class_bool>` enable **)** |
  41. +------------------------------+------------------------------------------------------------------------------------------------------------------------------------+
  42. Description
  43. -----------
  44. Contains global variables accessible from everywhere. Use the normal :ref:`Object<class_object>` API, such as "Globals.get(variable)", "Globals.set(variable,value)" or "Globals.has(variable)" to access them. Variables stored in engine.cfg are also loaded into globals, making this object very useful for reading custom game configuration options.
  45. Member Function Description
  46. ---------------------------
  47. .. _class_Globals_add_property_info:
  48. - void **add_property_info** **(** :ref:`Dictionary<class_dictionary>` hint **)**
  49. Add a custom property info to a property. The dictionary must contain: name::ref:`String<class_string>`(the name of the property) and type::ref:`int<class_int>`(see TYPE\_\* in :ref:`@Global Scope<class_@global scope>`), and optionally hint::ref:`int<class_int>`(see PROPERTY_HINT\_\* in :ref:`@Global Scope<class_@global scope>`), hint_string::ref:`String<class_string>`.
  50. Example:
  51. ::
  52. Globals.set("category/property_name", 0)
  53. var property_info = {
  54. "name": "category/property_name",
  55. "type": TYPE_INT,
  56. "hint": PROPERTY_HINT_ENUM,
  57. "hint_string": "one,two,three"
  58. }
  59. Globals.add_property_info(property_info)
  60. .. _class_Globals_clear:
  61. - void **clear** **(** :ref:`String<class_string>` name **)**
  62. Clear the whole configuration (not recommended, may break things).
  63. .. _class_Globals_get_order:
  64. - :ref:`int<class_int>` **get_order** **(** :ref:`String<class_string>` name **)** const
  65. Return the order of a configuration value (influences when saved to the config file).
  66. .. _class_Globals_get_singleton:
  67. - :ref:`Object<class_object>` **get_singleton** **(** :ref:`String<class_string>` name **)** const
  68. .. _class_Globals_globalize_path:
  69. - :ref:`String<class_string>` **globalize_path** **(** :ref:`String<class_string>` path **)** const
  70. Convert a localized path (res://) to a full native OS path.
  71. .. _class_Globals_has:
  72. - :ref:`bool<class_bool>` **has** **(** :ref:`String<class_string>` name **)** const
  73. Return true if a configuration value is present.
  74. .. _class_Globals_has_singleton:
  75. - :ref:`bool<class_bool>` **has_singleton** **(** :ref:`String<class_string>` name **)** const
  76. .. _class_Globals_is_persisting:
  77. - :ref:`bool<class_bool>` **is_persisting** **(** :ref:`String<class_string>` name **)** const
  78. If returns true, this value can be saved to the configuration file. This is useful for editors.
  79. .. _class_Globals_load_resource_pack:
  80. - :ref:`bool<class_bool>` **load_resource_pack** **(** :ref:`String<class_string>` pack **)**
  81. .. _class_Globals_localize_path:
  82. - :ref:`String<class_string>` **localize_path** **(** :ref:`String<class_string>` path **)** const
  83. Convert a path to a localized path (res:// path).
  84. .. _class_Globals_save:
  85. - :ref:`int<class_int>` **save** **(** **)**
  86. .. _class_Globals_save_custom:
  87. - :ref:`int<class_int>` **save_custom** **(** :ref:`String<class_string>` file **)**
  88. .. _class_Globals_set_order:
  89. - void **set_order** **(** :ref:`String<class_string>` name, :ref:`int<class_int>` pos **)**
  90. Set the order of a configuration value (influences when saved to the config file).
  91. .. _class_Globals_set_persisting:
  92. - void **set_persisting** **(** :ref:`String<class_string>` name, :ref:`bool<class_bool>` enable **)**
  93. If set to true, this value can be saved to the configuration file. This is useful for editors.