ID:1948274
 
(See the best response by LordAndrew.)
Hello.

What I am trying to accomplish is to generate a list that contains one instance of all objects of a given type upon character creation.

In this case, the type is /item, which has /datum as its parent. So it is essentially a datum. Now, within my character creation routine, there is a list variable which I want to contain one of every object that falls within the /item type.

How would I go about to generate this list code-wise? It's been a while since I DM'd, so I'm just getting back in the bath, so to speak. Tried a lot of ideas, but couldn't come up with anything that worked. If anyone could provide an example on how to accomplish this, so I can understand how to handle these sort of lists, it would be great. :)


Thanks in advance!
Best response
You'd want to make use of typesof(), which will return a list of all the child paths the base path supplied has:

item
parent_type = /obj

longsword_of_frost
name = "Longsword of Frost"

nanosuit
name = "Nanosuit"

depthshine
name = "Depthshine"

mob/Login()
..()

// Subtract the /item path from the results of typesof().
for (var/it in typesof(/item) - /item)
new it(src)