ID:2124798
 
Something really neat I discovered a few months ago that's somewhat documented, but poorly understood is the "/" path operator.

I really like it for grouping related objects together despite hierarchy changes.

Let's take an example here:

obj/item

recipe
var
list/ingredients
list/results
proc
Craft(mob/user,free=0)
if(!free)
var/count = 0, obj/item/i
var/list/conts = user.contents.Copy(), take = list()
while(++count<=ingredients.len)
if(ispath(ingredients[count]))
i = locate(ingredients[count]) in conts
if(i)
take += i
conts -= i
else
return 0
user.contents -= take

var/count = 0, /obj/item/i, t
while(++count<=results.len)
t = results[count]
i = new t(user)
return 1


Normally, we'd define all /obj/item subtypes under the /obj/item path and all the recipes under the /recipe path. This means if we want to modify an item and its recipe, we need to jump around in DM to find both the recipe definition and the item definition.

The "/" operator allows you to specify path nodes. But if a path begins with the "/" operator, that means that the node is a root. What does this mean?

Well, it means that we can arbitrarily swap to other paths when we're tabbed inside of another path.

obj/item
mushroom
water
potion
/recipe/potion
ingredients = list(/obj/item/mushroom,/obj/item/water)
results = list(/obj/item/potion)


Even though /recipe/potion is tabbed inside of /obj/item/potion, because we prefaced "recipe" with "/", the tabbed-in prototype is ignored and we go back to root. That means even though /recipe/potion is tabbed inside of /obj/item/potion, we're actually defining the properties of /recipe/potion without affecting /obj/item/potion hierarchy.

This is really useful for defining interface elements that work as part of a datum, and subelements of multi-part systems.

While this is documented, I found the example in the reference really quite terrible.
I actually wrote up an article years back about this. There's also the look-up and look-down operators.

mob
enemy
var/alignment

dragon
alignment = .dragon

asshole_dragon
alignment = .asshole_dragon

snake
alignment = .snake // /mob/enemy/snake

asshole_snake
alignment = .dragon/asshole_dragon // /mob/enemy/dragon/asshole_dragon

dragon_snake
alignment = .dragon


And :

obj/corpse
icon = 'deadstuff.dmi'


mob/dragon
:corpse
var/dragon_testicles = 0


Now /obj/corpse has a variable called dragon_testicles, without having to define it, this is effectively the same as the / operator you mentioned above except it starts at the absolute root and not the parent root. You could do ":/mob/path/tome" as well.

The Blue Book is actually where these are documented best.