Adding custom variables

Custom variables may either be added through the entity and scene editors or through code.

Every custom data added to an entity must have a name, just like a regular variable. The methods ETHEntity::SetFloat, ::SetInt, ::SetUInt and ::SetString (among others, see the ETHEntity object reference for more information) may be used to add custom data or to update existing values:

Custom data sample:

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

// Add custom data to it
mainCharacter.SetString("class", "mage");
mainCharacter.SetFloat("speed", 100.0f);
mainCharacter.SetInt("hp", 60);
mainCharacter.SetUint("maxHp", 70);
mainCharacter.SetVector2("direction", vector2(20, 40));

// Now hp equals 70. Instead of adding new data,
// it will just update it because "hp" already exists.
mainCharacter.SetInt("hp", 70);

// Add 10 damage to character

// Will overwrite 'float speed' since it already exists and is not an int
mainCharacter.SetInt("speed", 150);

In order to retrieve data, use ETHEntity::GetFloat, ::GetUInt, etc.