ID:169863
 
Hello all, I'm wondering, what exactly are Datums used for. When do you use them and why?
I suggest reading Lummox's article that tenkuu linked you to, but just to clarify:

In DM, the datum is the ancestor of every object. It's the object that is the closest to the top of the object tree. Everything inherits from the /datum object!

By definition, an atom is a mappable object. Therefore, if you want to make an object, but the object will never have to appear on the map, that object should be a datum!

When you define something with no indnetation before it, the "datum/" is implied. Therefore, instead of defining a datum like so:

datum/admin


We're perfectly free to define it like this:

admin


"Admin?", you may ask, why would that be a datum?

Well, you see, datums are often used as containers. For example, let's say that I want administrative verbs for my game. I need to store the verbs under an object, of course. Now, many beginning developers would, at this point, start defining verbs under a /mob/admin object. This method may work, but if the /mob/admin object will never appear on the map, why should it be a mob? For that matter, why should it be an atom at all?! Let's make it a datum!

var/list/admins = list("Wizkidd0123","DragonMasterGod")

admin/proc
Fly()
usr << "You [src.density ? "soar up into the air!":"gracefully land on the ground."]"
usr.density = !usr.density

mob/player/Login()
..()
if(src.key in admins)
src.verbs += typesof(/admin/proc)


That, of course, is only one of the hundreds of great uses for datums! You'll learn more by reading Lummox's article, and from there, try to find your own ways to use them!
In response to tenkuu
Whoa, I never knew about what datums were or how they are used, but I've heard of them. I just never had the patience to look them up. Thank for the replies to this guy's thread, it helped me out as well.
In response to Wizkidd0123
Dude Wizkid, you and Lummox are great. Thank you guys for all of your help. I can always count on Lummox and Wizkid for the good advice.
In response to Wizkidd0123
is the ..() like a return thing?
You can also use them for skills and thing in generic RPGS:

Skill
proc/Use(var/mob/a,var/mob/d)
return
Leetness
Use(var/mob/a,var/mob/d)
d << "[a] is so leet that he pwns you good"
del d
a << "Your leetness pwns [d]"


Then you just add the datum to a list for mobs, and call their Use() procedure when they're used.