• entries
557
1237
• views
422158

# Untitled

67 views

Back in Edinburgh tonight for a piss-up on Saturday night, and since I have no TV in my room (It's in Glasgow), and this PC (my server) is useless for most things, I may as well post here.

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...

-------------------------------------------------------------------------------- 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):
• Handle telnet negotiation - Easy, I have code for this somewhere I did for another MUD
• Handle idle timeouts for various user states - Will be done by the script, users at the login prompt will time out after 30 seconds or so with no valid input
• Handle flooding - Also done by the script
So on my mental code list, I have:
• Handle telnet and TA2 protocols (If you don't know, don't ask). Scripts should read / write in the most advanced format, the code should then filter the text to the correct protocol
• Telnet negotiation (see above)
• Room classes - Containers for items and users, can have 1 or more exits, a description, and so on
• User profiles - I think this is already done, sort of. User profiles will just be a series of key-value pairs of strings, and scripts will parse this out into numbers, tables, etc
• Items - Again, mostly a series of key-value pairs. Need an item manager to load the config file containing items, and commands to reload it
• NPCs. Not much more to say
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.

• ## 1 Comment

Don't cry, Steve.

MUDs are just boring.

I need some nicer scripting support but I'm too sleepy to read up on your system.