When it comes to MUD clients I’ve always been a MUSHclient user but I thought it was about time I tried out Mudlet, particularly as they added a fancy mapper in the latest release.
I found Mudlet pretty easy to get into and was able to do almost everything I wanted, but one thing missing that I was used to in MUSHclient was an equivalent of the getCommand() function. I’ve always used a keypad based system that allows me to issue commands by typing an alias and then pressing a key on the keypad to execute it and I use getCommand() to capture the contents of the command line.
I had a look through the Mudlet Lua API and while there were clearCmdLine() and appendCmdLine() functions strangely enough there was no getCmdLine().
Fortunately Mudlet is Open Source and it was easy enough to add it myself.
You just need to add this function to TLuaInterpreter.cpp.
int TLuaInterpreter::getCmdLine( lua_State * L )
{
Host * pHost = TLuaInterpreter::luaInterpreterMap[L];
QString curText = pHost->mpConsole->mpCommandLine->toPlainText();
lua_pushstring( L, curText.toLatin1().data() );
return 1;
}
You also need to add it to the initLuaGlobals function in the same file.
lua_register( pGlobalLua, "getCmdLine", TLuaInterpreter::getCmdLine );
And don’t forget to declare it in TLuaInterpreter.h.
static int getCmdLine( lua_State * L );
That’s it. You should now be able to use getCmdLine() in scripts, so for 1 on the keypad I have this.
cmd = getCmdLine()
if cmd then
expandAlias(cmd .. " southwest")
else
send("southwest")
end
You can then use this with aliases like “sw *” for “swim matches[2]” and then all you have to do is type sw and press a key on the keypad to have your character swim in that direction.

That is a quite smart idea.
LikeLike
Thanks! And feel free to include it (or similar) in the next mudlet release 🙂
LikeLike
Yeah, will look into it!
LikeLike
https://github.com/keneanung/Mudlet-1/commit/9ea37e2389cc75a8e2ff0966bd44fd491b932bc4
LikeLike
And it only took 2 years! 🙂
LikeLike