Hello,
I'm trying to figure out the best way for flexible communication between script side and C++ side. What are you using when you need to call some specific C++ object method from AS script without registering it through script engine?
I have event system, but it rather works in other direction (C++ sending events to Angelscript) and I'd like to keep it that way (one sided).
Lets consider situation where I have LoginState C++ class that handles logging logic and owns GUI overlay thats scripted in AS. In that script, I gather inputs, validate them and should call C++ method to send username/password through network interface. I don't want to expose network interface to scripting, but I'd like to have Auth(login, password) method available on script side.
Is registering LoginState as a OBJ_REF | OBJ_NOHANDLE type with a method Auth(login, password), then setting global property "LoginState state" the only way? Its a bit problematic with how script interface has to be registered, I'd need to register all possible methods prior to launching the state.
Or I should invent some event system that works both sides? Where script can do "eventSystem.fire("auth", dict())" where dict has login/password and some method on C++ side listens for such event? I don't like event systems much, I use libRocket events for UI side, so I can launch some events from C++, but I'd rather keep it that way, because it fires events in UI widgets, and I want to keep them script-only so I don't even query them on C++ side. This means I'd need another event system for AS->C++ communication.
Maybe someone uses different methods to call some function with parameters on C++ side from AS?
PS. In case someone wants to discuss it live, I'm on #angelscript irc channel (@freenode) 24/7, my session hangs there but when I'm not afk I look there from time to time.