Retrieving custom variables

In order to check if a custom variable exists or even to find out its type, use the ETHEntity::CheckCustomData method. The methods ETHEntity::GetFloat, ::GetUInt, ::GetInt, ::GetString, ::GetVector2 and ::GetVector3 can be used to retrieve custom data from entities:

Checking data:

// Retrieves a handle to our character
ETHEntity @mainCharacter = SeekEntity("my_character.ent");

// Checks if "class" exists
DATA_TYPE dt = mainCharacter.CheckCustomData("class");

// if class doesn't exist
if (dt == DT_NODATA)
    print("No data here\n");
else if (dt == DT_STRING) // if it exists and it is a string, print it

If the ETHEntity::Get* methods try to retrieve an inexistent variable or if its type does not match the retrieving type, it will return 0 or an empty string.

If you are not sure if a certain variable exists or not, test it with ETHEntity::CheckCustomData before retrieving its value.