Not much to report really, I spent an hour today (my lunch break) adjusting the code for TEH MUD slightly. I added code to parse user input, which is now nice and simple thanks to my abstraction from the platform specific mess. I'm not going to post more huge chunks of code, but I'll post this bit, which shows a practical use of the scripting:
bool GConnection::Tick(){ // See if the client is connected if(!m_pClient->IsConnected()) return false; // Do main tick switch(m_eState) { case STATE_New: { // New user, send login prompt EScriptCall::SP pCall = EScriptMgr::Get().Call(L"SendLoginPrompt"); pCall->AddArg(this); if(!pCall->Call()) { OnInternalError(); return false; } m_eState = STATE_ReadUsername; } break;// Snip...
And the contend of login.script:
-------------------------------------------------------------------------------- Login.script - Functions to handle user login------------------------------------------------------------------------------function SendLoginPrompt(user) -- TODO: Handle IP bans HostSendString(user, TELNET_BOLD .. TELNET_RED .. "Welcome to TEH MUD!" .. TELNET_RESET.. NEWLINE .. "Please enter your username: ");end
Everything in caps is a global set by the code. I could stick it in a [Lua] script, but since these aren't going to change, and since they'll be referenced from all sorts of scripts, I'm just as well to register them code-side.
If anyone is wondering why I use .script as an extension instead of .lua, it's because the scripting code is abstracted away by the engine. All the game code knows (and should know) is that it's dealing with "A script". The only script that the game code actually loads directly is actoexec.script (Which will bew renamed to boot.script soon), and that sctript loads all the others. I could have all the othre scripts named .lua, but I'm just as easy to call them all .script for constancy.
I have 3 TODO's currently in my code (Although there's still loads to do):
So on my mental code list, I have:
There's a fair bit more, but I'm too lazy to think or type any more, so I'm going to bed.
Someone leave some comments or I'll cry.
MUDs are just boring.
I need some nicer scripting support but I'm too sleepy to read up on your system.