Hello,
I've recently started to use AngelScript for my game engine, and I must admit, I personally really like the syntax a lot, especially compared to lua, whichI tried before. That out of the way, I seem to have some trouble with registering enums through the application and using them in scripts. For example, I have the following part of a script:
void OnProcessInput(const MappedInput@ input)
{
if(input.HasState(MOVE_BACKWARD))
moveX = 1;
else if(input.HasState(MOVE_FORWARD))
moveX = -1;
if(input.HasState(MOVE_RIGHT))
moveY = 1;
else if(input.HasState(MOVE_LEFT))
moveY = -1;
}
now if I add the enum declaration in the same script, everything works fine:
enum State
{
MOVE_LEFT,
MOVE_RIGHT,
MOVE_FORWARD,
MOVE_BACKWARD
};
However, once I manually register those enum and values via the application, the script throws compilation errors saying all those values are unkown. This is how I register them:
m_pEngine->RegisterEnum("State");
m_pEngine->RegisterEnumValue("State", "MOVE_LEFT", 1);
m_pEngine->RegisterEnumValue("State", "MOVE_RIGHT", 2);
m_pEngine->RegisterEnumValue("State", "MOVE_FORWARD", 3);
m_pEngine->RegisterEnumValue("State", "MOVE_BACKWARD", 4);
While not appeareant in the code, I've checked the return values, everything is giving success so far. Now, is there anything else I have to take care of when using application registered enums, or do you have any other idea what I could be doing wrong? Thanks in advance!