W3cubDocs

/Godot 2.1

Globals

Inherits: Object

Category: Core

Brief Description

Contains global variables accessible from everywhere.

Member Functions

void add_property_info ( Dictionary hint )
void clear ( String name )
int get_order ( String name ) const
Object get_singleton ( String name ) const
String globalize_path ( String path ) const
bool has ( String name ) const
bool has_singleton ( String name ) const
bool is_persisting ( String name ) const
bool load_resource_pack ( String pack )
String localize_path ( String path ) const
int save ( )
int save_custom ( String file )
void set_order ( String name, int pos )
void set_persisting ( String name, bool enable )

Description

Contains global variables accessible from everywhere. Use the normal 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.

Member Function Description

void add_property_info ( Dictionary hint )

Add a custom property info to a property. The dictionary must contain: name:String), and optionally hint:int), hint_string:String.

Example:

Globals.set("category/property_name", 0)

var property_info = {
    "name": "category/property_name",
    "type": TYPE_INT,
    "hint": PROPERTY_HINT_ENUM,
    "hint_string": "one,two,three"
}

Globals.add_property_info(property_info)

void clear ( String name )

Clear the whole configuration (not recommended, may break things).

int get_order ( String name ) const

Return the order of a configuration value (influences when saved to the config file).

Object get_singleton ( String name ) const

String globalize_path ( String path ) const

Convert a localized path (res://) to a full native OS path.

bool has ( String name ) const

Return true if a configuration value is present.

bool has_singleton ( String name ) const

bool is_persisting ( String name ) const

If returns true, this value can be saved to the configuration file. This is useful for editors.

bool load_resource_pack ( String pack )

String localize_path ( String path ) const

Convert a path to a localized path (res:// path).

int save ( )

int save_custom ( String file )

void set_order ( String name, int pos )

Set the order of a configuration value (influences when saved to the config file).

void set_persisting ( String name, bool enable )

If set to true, this value can be saved to the configuration file. This is useful for editors.

© 2014–2017 Juan Linietsky, Ariel Manzur, Godot Engine contributors
Licensed under the MIT License.
http://docs.godotengine.org/en/2.1/classes/class_globals.html