Gyrbo:
Thanks Gyrbo for helping out.
ontheheap:
I guess you're reading the overview article. That is only meant to show a bit of what can be done with AngelScript, not to serve as a tutorial. The sample code in that article lacks error checking (to make it easier to understand), which if you had used probably would have told you what was wrong.
Especially when calling Build() it is a good idea to pass a pointer to an output stream, example:
class COutStream : public asIOutputStream{public: void Write(const char *text) { printf(text); }};
Build the scripts, passing a pointer to the output stream:
COutStream out;int r = engine->Build("module name", &out);if( r < 0 ){ // The build failed, verify the messages passed to the output stream}
Also when registering application functions, types, or properties, always verify that the return code is not negative, which would mean the registration failded. I usually put an assert, after each register function call. That way it is possible to pinpoint in debug mode which register function that failed. In release mode it is not necessary to verify them (the assert call will be removed by the compiler), the Build() method would fail anyway.
r = engine->RegisterGlobalFunction(...); assert( r >= 0 );r = engine->RegisterGlobalProperty(...); assert( r >= 0 );
Regards,
Andreas