Skip to content

Commit

Permalink
[MIRROR] Document managed globals (#2441)
Browse files Browse the repository at this point in the history
Co-authored-by: SierraKomodo <[email protected]>
  • Loading branch information
SierraHelper and SierraKomodo authored Sep 3, 2024
1 parent 297c720 commit b3dc027
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions code/__datastructures/globals.dm
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
/* *
* Managed Globals
*/

/**
* Managed Globals datum. Any defined global vars can be accessed via `GLOB.varname`.
*
* New globals can be defined on the global scope (Outside of any class definitions) via the various `GLOBAL_*()`
* defines listed at the end of `code\__datastructures\globals.dm`.
*/
var/global/datum/globals/GLOB


Expand Down Expand Up @@ -62,20 +64,28 @@ var/global/datum/globals/GLOB
##X = V; \
}

/// Initializes the global constant `GLOB.[X]` with the value `[V]` as a managed global.
#define GLOBAL_VAR_CONST(X, V) /datum/globals/var/const/##X = V;

/// Initializes the global variable `GLOB.[X]` with no value (`null`) as a managed global.
#define GLOBAL_VAR(X) /datum/globals/var/static/##X;

/// Initializes the global variable `GLOB.[X]` with the value `[V]` as a managed global.
#define GLOBAL_VAR_INIT(X, V) GLOBAL_VAR(X) GLOBAL_INIT(X, V)

/// Initializes the global variable `GLOB.[X]` as an instance of `/static[P]` with no value (`null`) as a managed global.
#define GLOBAL_DATUM(X, P) /datum/globals/var/static##P/##X;

/// Initializes the global variable `GLOB.[X]` as an instance of `/static[P]` with the value `[V]` as a managed global.
#define GLOBAL_DATUM_INIT(X, P, V) GLOBAL_DATUM(X, P) GLOBAL_INIT(X, V)

/// Initializes the global variable `GLOB[X]` as a list with no value (`null`) as a managed global.
#define GLOBAL_LIST(X) /datum/globals/var/static/list/##X;

/// Initializes the global variable `GLOB[X]` as a list with value `[V]` as a managed global.
#define GLOBAL_LIST_INIT(X, V) GLOBAL_LIST(X) GLOBAL_INIT(X, V)

/// Initializes the global variable `GLOB[X]` as an empty list (`list()`) as a managed global.
#define GLOBAL_LIST_EMPTY(X) GLOBAL_LIST_INIT(X, list())

/// Prevents the GLOB member from being shown in View Variables.
Expand Down

0 comments on commit b3dc027

Please sign in to comment.