FOnline Development > Questions and Answers
AngelScript questions (not related to FOnline API)
Bartosz:
--- Quote from: Mike Wall on May 21, 2013, 09:46:19 am ---How do I make my new .cpp file get used by the engine. Is this even possible or I have to use fonline_tla.cpp and/or fonline_test.cpp files?
--- End quote ---
Check the Makefile which is used to build the dll, you need to configure it to build your additional cpps as well (it's in scripts directory).
wladimiiir:
--- Quote from: scypior on June 06, 2013, 11:12:56 am ---Check the Makefile which is used to build the dll, you need to configure it to build your additional cpps as well (it's in scripts directory).
--- End quote ---
I already have dll compiled. My question is, how does the server load these dlls? Is it hardcoded in the server, what dlls should be used? This is not really clear to me.
Bartosz:
pragma bindfunc with dll as module causes the library to be loaded:
--- Code: ---// Test function
# ifdef __SERVER
# pragma bindfunc "void TestFunc(string&) -> fonline_test.dll TestFunc"
# endif
# ifdef __CLIENT
# pragma bindfunc "void TestFunc(string&) -> fonline_test_client.dll TestFunc"
# endif
--- End code ---
wladimiiir:
Cool, thanks. :)
wladimiiir:
I have an interface defined in C++:
--- Code: ---class IFoo
{
public:
virtual void FooMethod();
};
--- End code ---
I have registered the interface in AngelScript engine:
--- Code: ---ASEngine->RegisterInterface("IFoo");
ASEngine->RegisterInterfaceMethod("IFoo", "void FooMethod()");
--- End code ---
I have a script (foo.fos) with implementation of this interface:
--- Code: ---class FooImpl : IFoo
{
void FooMethod() {/*doing something totally useful*/}
}
--- End code ---
I have also registered Global function which I am calling from my script with new instance of my FooImpl class as parameter:
--- Code: ---ASEngine->RegisterGlobalFunction("void RetrieveFoo(IFoo& foo)", asFUNCTION(RetrieveFoo), asCALL_CDECL);
--- End code ---
And I have my RetrieveFoo function in C++ code:
--- Code: ---void RetrieveFoo(asIScriptObject* obj)
{
if(obj == NULL)
{
Log("No object has been passed");
return;
}
//I want to do something with passed FooImpl
}
--- End code ---
My question is:
Is it possible to cast asIScriptObject* obj to IFoo interface and directly call FooMethod() or I have to do it the "ugly" way, which makes the interface useless (creating context, getting function to call, setting parameters, and executing it)?
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version