-
Notifications
You must be signed in to change notification settings - Fork 52
Retrieving custom variables
Roberto de Deus Barbosa Murta edited this page Nov 7, 2019
·
1 revision
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
{
print(mainCharacter.GetString("class"));
}
If the ETHEntity::Get*
methods try to retrieve an inexistent variable or if its type does not match the retrieving type, it will return `` 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.