🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Registered enum values not recognized

Started by
1 comment, last by Juliean 10 years, 7 months ago

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!

Advertisement

I don't see anything wrong. It should work this way.

What is the compiler message you get?

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

Thanks for the quick reply, however it turned out I simply had the call for loading the script between the declaration of an interface, and those enums *facepalm*. I probably should know better than to work at 2am when I'm barely able to stay awake, but oh well. Sorry for having bothered you, but let me just take that opportunity again to say that I'm very happy with AngelScript, it fits my needs perfectly and gets the job done pretty quickly so far. Thanks!

This topic is closed to new replies.

Advertisement