[Home] [Downloads] [Search] [Help/forum]


Register forum user name Search FAQ

Gammon Forum

[Folder]  Entire forum
-> [Folder]  MUDs
. -> [Folder]  MUD Design Concepts
. . -> [Subject]  best data storage way

best data storage way

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page


Posted by Serenity   (18 posts)  [Biography] bio
Date Tue 06 Oct 2009 12:52 PM (UTC)
Message
I'm currently storing my data in the following way on the filesystem:
areas/demo_area/demo_area.xml
areas/demo_area/script1.lua
..

Each area xml file contains: rooms, items, creatures
So everything for a single area is contained in one file.
This seemed handy, because builders dont have to switch between many small files.

However, these files tend to get large (1000+ lines), so one of my builders asked for a split into multiple files.

What i could do is split each area into subdirectories like items, creatures, rooms, etc
OR have multiple files per area like items.xml, rooms.xml etc

What would be the best option? Since i'm a coder and not a real builder, i dont know. Any input/ideas are welcome.

[Go to top] top

Posted by Wjmurdick   (13 posts)  [Biography] bio
Date Reply #1 on Tue 06 Oct 2009 01:17 PM (UTC)
Message
The great thing is that you are using Lua so you can have lots of flexibility for how to handle it..

My suggestion would be to do the following:

1. Split the XML up into parts (items, mobs, rooms, resets, progs, what-have-you).

2. Create a "master" lua script that handles the loading of each xml. loadfile(blah.xml) basically.

What this method does is gives your builders FAR more flexibility for what files to have. In fact, you could almost let them choose their own files if your system was flexible enough, since the lua script would handle the loading.

Thats how I do it on my own code... area_name.lua sets up the rooms and exits, then calls mobs.lua, items.lua, and so forth.
[Go to top] top

Posted by Serenity   (18 posts)  [Biography] bio
Date Reply #2 on Tue 06 Oct 2009 02:01 PM (UTC)
Message
I let my C++ core do the loading. Lua is used for all sort of builders' scripts.

My preference is to keep everything as simple as possible, but builders must of course feel comfortable with the engine. Is a file per item/creature too much? Or do builders prefer that?
[Go to top] top

Posted by David Haley   USA  (3,881 posts)  [Biography] bio
Date Reply #3 on Tue 06 Oct 2009 05:30 PM (UTC)
Message
I take it that you have an assumption that building is done on the file directly, as opposed to with a tool of some sort? (In-game building, separate building application, etc.) Having a tool would make the file size more or less irrelevant.

But, if you want everything to be in files, I think that having a file per entity can actually make a lot of sense. For example, it makes it very easy to share entity definitions across places. I have never liked how many MUDs tie objects/mobs to specific areas. I much prefer having some sort of general catalog of game entities, and you just refer to those identifiers when placing things in your locations.

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
[Go to top] top

Posted by Serenity   (18 posts)  [Biography] bio
Date Reply #4 on Wed 07 Oct 2009 07:23 AM (UTC)
Message
What i do with room/creature/item identifiers:
- areas are central in the design and are manager by a single builder/domain of builders.
- rooms/creatures/items all have an unique identifier within an area (= string) like goblin_soldier
- to address something, use the full path: area_id/object_id
eg. goblin_cave/goblin_soldier (=creature)
goblin_cave/goblin_sword (=item)
goblin_cave/main_room ( = room)
- all rooms/items/creatures can be private/public. This determines whether other area builders can use the object or in case of rooms, can use it as destination.

I also have special 'common' areas like 'effects', 'items' and 'creatures', so that some common stuff has id's like:
effects/drunk
items/longsword
creatures/human
...

This works really well. What i also use in that in area X, you dont have to say X/item_id, but can just use item_id.
[Go to top] top

Posted by David Haley   USA  (3,881 posts)  [Biography] bio
Date Reply #5 on Thu 08 Oct 2009 03:36 AM (UTC)
Message
That works too. It would work best (IMO) coupled with a policy that whenever possible, builders should push items to the general, shared areas, and if not possible, they should re-use existing items, and only after trying these two should they make their own copy of the item. It gets silly when every area has its own wooden table, iron longsword, etc.

Anyhow, since you have this breakdown, why not just explicitly represent it in the filesystem? That way, moving a file is just changing its directory (but you'd have to fix references, of course). You can easily distribute individual files without having to distribute the entire area alongside it.

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
[Go to top] top

Posted by Serenity   (18 posts)  [Biography] bio
Date Reply #6 on Thu 08 Oct 2009 05:28 AM (UTC)
Message
Matching the filesystem structure to the id structure seems like a nice thing to do indeed... I'll get on it.
[Go to top] top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


19,343 views.

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at HostDash]