🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Untitled

posted in DruinkJournal
Published April 19, 2007
Advertisement
And now scripting is in. I'm amazed how nice and simple it was, once I got my OOPy stuff working with C closures.
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...
Previous Entry Untitled
Next Entry Untitled
0 likes 0 comments

Comments

Nobody has left a comment. You can be the first!
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Advertisement
Advertisement