Class Core.Environment

The Environment class is used by the library to determine whether it's running in a specific World of Warcraft client or in a test suite.

Sometimes it's necessary to execute different code depending on the available API resources, like functions and tables that are available in Retail but not in Classic and vice versa.

Environment is alvo available to addons, but as long as they register multiple versions of a class for each supported client, everything should be transparent and no additional handling is required, not even asking this class for the current client version.

Note: Environment is registered before the library Factory, which means it can't be instantiated with library:new(). For any class that needs to know the current environment, use the library.environment instance.

Tables

core.environment.constants Constants for the available clients and test suite.

Methods

core.environment:getClientFlavor () Gets the current client flavor, determined by the current TOC version.
core.environment:getTocVersion () Gets the World of Warcraft TOC version.
core.environment:inGame () Determines whether the addon is running in a World of Warcraft client.

Metamethods

core.environment:__construct () Environment constructor.


Tables

core.environment.constants
Constants for the available clients and test suite.

Fields:

  • CLIENT_CLASSIC The current World of Warcraft Classic client, which includes TBC, WotLK, and Cataclysm, etc
  • CLIENT_CLASSIC_ERA Classic SoD, Hardcore, and any other clients that have no expansions
  • CLIENT_RETAIL The current World of Warcraft Retail client
  • TEST_SUITE The unit test suite, that executes locally without any World of Warcraft client

Methods

core.environment:getClientFlavor ()
Gets the current client flavor, determined by the current TOC version.

The client flavor is a string that represents the current World of Warcraft client and mapped to the constants.CLIENT_* values.

If the addon is running in a test suite, create the TEST_ENVIRONMENT global variable and set it to true before instantiating the library so this method can return the proper value.

Returns:

    string The current client flavor

See also:

core.environment:getTocVersion ()
Gets the World of Warcraft TOC version.

Returns:

    integer The client's TOC version
core.environment:inGame ()
Determines whether the addon is running in a World of Warcraft client.

Returns:

    boolean True if the addon is running in a World of Warcraft client, false otherwise, like in a test suite

Metamethods

core.environment:__construct ()
Environment constructor.
generated by LDoc 1.5.0 Last updated 2024-09-11 16:27:53