I can run a script that just calls LoadScript("Test2.script") correctly, and call a function from that newly loaded script with the following code:
// The function:class LoadScript : public EScriptFunction{public: LoadScript() : EScriptFunction(L"LoadScript") {} virtual void Call(EScriptContext& context) { EScriptMgr::Get().LoadScript(context.GetArgAsString(0)); }};// Register the functionEScriptMgr::Get().Register(new LoadScript);// Load and run Test.script (Which will cause LoadScript to be called)EScriptMgr::Get().LoadScript(L"Test.script");// Get an object allowing us to make a call to the "main" function in LuaEScriptCall::SP pCall = EScriptMgr::Get().Call(L"main");// Add some argspCall->AddArg(L"LOL");pCall->AddArg(42);// Call the script functionif(!pCall->Call()){ /* Error */ }// Get the first return value as a stringstd::wstring strRetval = pCall->GetRetvalAsString(0);
Nice and simple. I might make some wrapper functions to easily call script functions with 0 or 1 parameters that return void.
So anyway, scripting is now "Complete", and is ready to be moved into TEH ENGINE. I told you there was a reason to be doing this side project [smile]
So I've now got 3 modules ready to bung into the main engine; File system, network and scripting.
I'll probably start getting the guts of the server going today, and it should be ready for a test tomorrow if all goes well. I'll post in the lounge if that's the case.
Anyway, work time...