m_pASEngine->RegisterGlobalFunction("bool LoadScene(const string ∈)", asFUNCTIONPR(LoadScene, (string), bool), asCALL_CDECL);
It won't work because the object triggers the cast instead. One more question, what's the best way to register constants to the script? Can I do like engine->RegisterGlobalProperty("const unsigned long SPACE_KEY", &number); Thanks in advance.
Overloaded functions with objet parameters
I'm new to AngelScript so I have some dumb questions. How can I register an overloaded function with objects as parameters?
...
What do you mean that 'the object triggers the cast'?
The function signature in your code doesn't match what you tell AngelScript, so this would cause errors when the function is called from the script. It should be:
or
You need to check what the real signature is for the LoadScene function.
If you want the script compiler to treat the constants as real constants, instead of just read-only variables, then the best way is either to register them as enums (only for integer constants) or declare them in the script. The application can add an extra script section to all modules that are compiled that holds the constants.
alternative:
The function signature in your code doesn't match what you tell AngelScript, so this would cause errors when the function is called from the script. It should be:
m_pASEngine->RegisterGlobalFunction("bool LoadScene(const string ∈)", asFUNCTIONPR(LoadScene, (const string&), bool), asCALL_CDECL);
or
m_pASEngine->RegisterGlobalFunction("bool LoadScene(string)", asFUNCTIONPR(LoadScene, (string), bool), asCALL_CDECL);
You need to check what the real signature is for the LoadScene function.
If you want the script compiler to treat the constants as real constants, instead of just read-only variables, then the best way is either to register them as enums (only for integer constants) or declare them in the script. The application can add an extra script section to all modules that are compiled that holds the constants.
engine->RegisterEnum("EKEY");engine->RegisterEnumValue("EKEY", "SPACE_KEY", SPACE_KEY);
alternative:
// Add the constants as a hidden script sectionconst char *constDecl = "const uint32 SPACE_KEY = 32;";mod->AddScriptSection("Constants", constDecl);// Then add the other sections normally and build the script
AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement