Handling player/area files - Easiest method?

Posted by Dralnu on Mon 15 Dec 2008 11:24 PM — 5 posts, 26,736 views.

USA #0
I'm in need of suggestions of ways (be it via markup language or something else) to handle the storing and usage of info in flat files for use in the MUD.

I have looked at XML and S-Lang (which looks like a Lua-style scripting language), but I am unaware of any other options.

I find XML to be far to verbose and to much of a pita to work with unless much of the work is automated, and S-Lang, being a scripting language, brings me to wonder whether I could write this info in Lua.

Databases, on the other hand, are something I'm not going to use right now.
USA #1
While I could argue that a database would save you a lot of trouble from the beginning, I understand reluctance to use it for something as simple as a mud.

I know there is a good table system in Lua that could probably simplify your storage and loading of data if you were willing to use Lua. David and Nick and probably elaborate more on that then I can.

There are libraries out there that can automate XML formatting for you so you don't have to bother with it, so you might consider that. However, if you are looking for portability, working with third party libraries can sometimes be a pain and potential roadblock.
Australia Forum Administrator #2
Take a look at this thread:

http://www.gammon.com.au/forum/bbshowpost.php?id=6400

That describes using Lua to read in stuff (eg. configuration) into a C (or C++) program.

Lua really has all you need to do that sort of thing - in fact it started its life as a simple system for reading configuration files.

The good thing about the Lua data structure is you can nest things (eg. a table of all rooms, and for each room it could be a table of all the attributes of the room, and the contents of the room could be a further table).

Probably your only stumbling block is to move data from the Lua script space to your program space - although one approach would be to not bother - whenever you want data (eg. about a room) you simply pull it in from the Lua space.
USA #3
Nick pretty much said what I was going to say. The only thing I might add is that it's not too bad to just use Lua as a parsing library. Basically, instead of the silly (read: error-prone and hard to use) parsing that SMAUG does, you can use Lua's tables as a natural file format. You could then move the data into C/C++/whatever, or as Nick said, leave it in Lua. (But that can make the interface a little annoying, depending on how you set things up.)

I agree that XML is rather excessive for these purposes.

The nice thing about using Lua is that you'll be building a framework for having a whole scripting language at your disposal. If you start thinking about how to tie it in from the beginning, you will save yourself all kinds of trouble when it comes to putting in a scripting language.
USA #4
I was planning on using Lua as a scripting language to avoid having to mess with anything similar to smaugspells or whatever it was called. Knowing I can use Lua to load everything is even better.

Thanks for the thread.