Advertisement

DxInput defines into a AS compatible thing

Started by July 20, 2007 08:59 PM
1 comment, last by _Sigma 17 years, 4 months ago
I'm exposing a method to AS to check if a key is down. I ultimately need to be using the DxInput define to check if the key really is down, but I have no way of exposing this to AS. For example, I can't do IsKeyDown(DIK_1) from the script. So I was thinking: Use strings passed from AS to denote key codes. That is "T_1" would relate to DIK_1. I would have a large std::map, and use the CRC of the string as key, and the DirectInput define as the item. For example
m_keys.insert(std::pair<unsigned int, UCHAR>(CRC("T_Escape"), DIK_ESCAPE ));         
		m_keys.insert(std::pair<unsigned int, UCHAR>(CRC("T_1"), DIK_1 ));    
This sucks to do by hand, I'll be honest with you. Although speed is an issue, I think DWORD comparisons should be quick and it's only ~8 comparisons. So, is there a better way of doing this? If I am going with route, perhaps a priority tree of some flavour would be better?
Why do you think you can't use IsKeyDown(DIK_1)?

What you do is that you create a script section with the constant declarations, then add that to the same module as your user defined script and build them together. Alternatively you can use #include to allow the user defined scripts include other files and then expose the constant declarations as a script file. How to use the #include directive is explained in one of the samples that come with AngelScript.

Regards,
Andreas

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

Advertisement
Ah...I'm a tool! Ofcourse it should be done this way.

I actually have the #include directive working.

This topic is closed to new replies.

Advertisement