I'm currently trying to learn how to use a datum, what situations they would be useful in, and why to use them instead of /atom, /mob, /obj, etc.
I've read the Dream Makers Article and the Reference, but was wondering if anyone knew of any other sources I could look at, or if they could be so kind as to answer my questions for me here?
|
||||||||||||||||||||||
Whenever you want to create an OBJECT (not /obj) and it DOESN'T need to be an atom of some kind (you don't intend on it being on the map or in an atom's contents, for example), then you'd use a datum.
Here's an example... say you want a system of guilds. Each guild has a bunch of information associated with it. A name, a description of its purpose (if you want something like that), a list of members (and their rank), a list of ranks, a list of leaders, and the like.
In this case, you'd create some kind of datum prototype:
Now that this is done, you want a place to store all of them so you can easily access them. A global variable called guilds, for example. And then you can add a method of creating NEW guilds, assigning it the basic information, then a method for adding people to the guild and such. Then you'd save the list when the world closes and reload the list when the world opens.
That's just one example (I figured I'd use something that people would in general find a use for...). People use datums for all sorts of things. Even if they just want an object to hold two values, they would make a datum (which is much better than creating an atom with all sorts of useless information).
Here's something I made:
It's a calendar with all of the necessary information to generate a date and time using world.time and some other information. In datum format, it is easily modifiable and creating multiple instances (say I want different calendars in different parts of the world?) is as easy as creating a new calendar object and changing some fields.