Jump to content
  • Advertisement
Sign in to follow this  
Juliean

Registered enum values not recognized

This topic is 2160 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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!

Share this post


Link to post
Share on other sites
Advertisement

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!

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!