Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 04 Sep 2005
Offline Last Active Jul 31 2012 06:50 PM

#4957995 Overrid C++ methods from angelscript, possible? alternatives?

Posted by on 11 July 2012 - 06:11 AM


I asked the very same question to Andreas not long ago. And he told me of a work-around for this, (as well as why it doesn't work Posted Image ).

Here is his reply:

Unfortunately, it is not possible to inherit directly from application registered objects as they are not instances of asCScriptObject.

It is possible to implement a script proxy class that gives a light wrapper on top of the application registered object, and then have the script classes inherit from the proxy instead. For example:

shared class FSMProxy
FSMProxy() { @inner = FSM(); }
bool ChangeState(string v) { return inner.ChangeState(v); }
string CurrState {
get const { return inner.CurrState; }
set { inner.CurrState = value; }

private FSM @inner;

The script code for the proxy class can be generated by the application and added as a secondary script section to the script modules that will use the FSM class.


In this case "FSM" is my SuperClass and FSMProxy is the derived class