GetFamilyVariable

From Intrigues Wiki
Revision as of 08:52, 5 August 2024 by Tayfunwiki (talk | contribs) (Created page with "= <code>GetVariable</code> Method Documentation = == Description == The <code>GetVariable</code> methods allow for retrieving a private variable from the family based on its name or ID. These methods come in two variants: a non-generic version that retrieves the variable and a generic version that retrieves the variable and casts it to a specified type. == Method Signatures == === GetVariable (Non-Generic) === <syntaxhighlight lang="c#"> public NVar GetVariable(string...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

GetVariable Method Documentation

Description

The GetVariable methods allow for retrieving a private variable from the family based on its name or ID. These methods come in two variants: a non-generic version that retrieves the variable and a generic version that retrieves the variable and casts it to a specified type.

Method Signatures

GetVariable (Non-Generic)

public NVar GetVariable(string variableNameOrId)

This method retrieves the variable with the specified name or ID from the family.

GetVariable (Generic)

public T GetVariable<T>(string variableNameOrId) where T : NVar

This method retrieves the variable with the specified name or ID from the family and casts it to the specified type T.

Example Usage

Non-Generic Usage

NVar variable = IM.Player.Family.GetVariable("someVariable");
Debug.Log(variable.value);

Retrieves the someVariable from the family and logs its value.

Generic Usage

NBool booleanVar = IM.Player.Family.GetVariable<NBool>("booleanVariable");
Debug.Log(booleanVar.Value);

Retrieves the booleanVariable from the family, casts it to an NBool type, and logs its boolean value.

Note: booleanVar.Value will return the value as a boolean type (bool).