Register method for all script classes

Started by
0 comments, last by WitchLord 12 years ago
I'm looking for a way to register a class method for all script classes. I would like to be able to have a toString() method for every object. Have you given any thought to allowing this?

I did figure out how to register the method inside asCObectType, but it crashes when calling it (and I don't really want to modify angelscript).

Thanks,
Jeremy
Advertisement
I haven't thought of this before.

To make this work nicely it would have to be a special kind of registration, possibly something like 'RegisterDefaultScriptClassMethod'. Once registered with the engine, the builder to include the method as one of the members for all script classes that are built. Or, the compiler could be modified to understand this method directly and call it even though it wasn't explicitly declared in the class.

Do you really have to make this a class method? It would be much easier to use a global function that takes the object as argument instead. You can then use the variable argument type to accept any type you want (like the any add-on). A global function would also be able to function for primitive types.

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