Jump to content
  • Advertisement
Sign in to follow this  
WackyWormer

Programming a Lua MUD server, trying to accept keyboard input

This topic is 2129 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm trying to program a MUD server in Lua, as I've had a good bit of experience in writing scripts for the Mudlet client and Lua is the language I'm currently most comfortable with. I've run into a bit of a brick wall though. I'd like for the server, a console application, to accept keyboard input, so when I'm running the games i can interact as an admin from the server itself. The problem is, all the functions for accepting input in Lua are blocking functions. Should I just program a backdoor into the server, so I can connect as an admin from any telnet client? Or is there a simple way to accept keyboard input to the console app without blocking the rest of the script from running?

Share this post


Link to post
Share on other sites
Advertisement
What environment are you using to host your Lua scripts? If it doesn't already provide a non-blocking console API, it should be possible to add one, depending on the hosting program and OS.

Share this post


Link to post
Share on other sites
Bah, stupid phone.

Its the Lua for Windows package, if that's what you're asking.(Sorry, I'm new at this thing... all my Lua experience has been scripting in Mudlet, which auto compiles/runs the scripts for you. Over there, you just type the code out and save it.) Edited by WackyWormer

Share this post


Link to post
Share on other sites
Gotcha. So LFW has support for some useful libraries that you might check out, including CUI (console-mode UI package) and LuaInterface (which lets you interact with .Net software). You could try using CUI to do the console stuff, or just write a full-blown UI in C# or something and rig it up with LuaInterface.

Share this post


Link to post
Share on other sites
It's a bit unclear what exactly are you asking for. Have you got a MUD server already? If what you mean scripts for it, then you'r probably be writing the script, uploading it to the server (or writing it on the server directly) and then reloading it in the Lua VM. There isn't a problem of blocking user input here, so perhaps I'm misunderstanding you.

For a Lua MUD server, check out MudCore, which is build on pretty good stuff. I can't vouch for how well it would perform, I've only fiddled with it a bit, but the tech behind it is pretty solid.

It's cross-platform as well so you wouldn't be getting tied down to finding a Windows server for your hosting. Edited by Vadi

Share this post


Link to post
Share on other sites
If I understand the question correctly: "Is there some way to read console input on Windows with LUA without blocking the running thread?"
It does look like the CUI library has a "nodelay" option to allow polled input.
However, if I were to do this personally, I would add an attribute to users for whether they are allowed admin options or not, and just do it using regular logins.
If this scales up to a bigger system, you'd want to replace "is_admin" with a list of specific granted privileges, and test different privileges for different management functions. This would allow certain users to be "wizards" without being "admins."

Share this post


Link to post
Share on other sites
I've decided to go with the "client with admin privileges" idea. Now the only thing that concerns me is closing the server without shutting down the client connections. Is there any way to call a function when the console window is destroyed, like the WM_DESTROY event I remember using in my c++ apps?

Share this post


Link to post
Share on other sites
Not sure I'm understanding your question. What exactly is it you want to avoid? Do you mean you want the server to keep running even if you close the console?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!