_std/types.dm
ENSURE_TYPE | nulls a var if its value doesn't match the var's type |
---|---|
/proc/concrete_typesof | [/proc/typesof()] but only for concrete (not abstract) types, it caches the result so you don't need to worry about doing that manually so subsequent calls on the same type will be very fast. |
/proc/filtered_concrete_typesof | The same thing but now you can filter the types using a proc. Also cached. The filter proc takes a type and should return 1 if we want to include it and 0 otherwise. That proc should also be pure (always return the same thing for the same arguments) because of the caching. If you want to use non-pure proc do the filtering manually yourself and don't use this. Note that the first call to filtered_concrete_typesof with a given type and filter will be (possibly a lot) slower than doing it manually. The benefit of this proc only shows itself for future calls which are very fast due to caching. |
/proc/get_singleton | Gets the instance of a singleton type (or a non-singleton type if you decide to use it on one). |
/proc/predecessor_path_in_list | Find predecessor of a type |
/proc/maximal_subtype | Returns the maximal subtype (i.e. the most subby) in a list of given types |
/var/by_type | contains lists of objects indexed by their type based on [START_TRACKING] / [STOP_TRACKING] |
for_by_tcl | Loops over all instances of a type that's tracked via the [START_TRACKING] and [STOP_TRACKING] macros. Example: for_by_tcl(gnome, /obj/item/gnomechompski) qdel(gnome) |
/var/by_cat | contains lists of objects indexed by a category string based on START_TRACKING_CAT / STOP_TRACKING_CAT |
/typeinfo | type-level information type |
TYPEINFO | Declares typeinfo for some type. |
/proc/get_type_typeinfo | Retrieves the typeinfo datum for a given type. |
/proc/type2parent | Returns the parent type of a given type. Assumes that parent_type was not overriden. |
/proc/find_first_by_type | Finds some instance of a type in the world. Returns null if none found. |
/proc/find_all_by_type | Finds all instance of a type in the world.
Returns a list of the instances if no procedure is given.
Otherwise, calls the procedure for each instance and returns an assoc list of the form list(instance = procedure(instance, arguments...), ...)
procedure_src is the src for the proc call. If it is null, a global proc is called.
If it is the string "instance" the output list will be instead list(instance = instance.procedure(arguments...), ...) |
/proc/istypes | istype but for checking a list of types |
/proc/get_random_subtype | Returns a random subtype when an atom has TYPEINFO with a random_subtypes list |
/proc/string_type_of_anything | thing.type but it also returns "num" for numbers etc. |
Define Details
ENSURE_TYPE
nulls a var if its value doesn't match the var's type
TYPEINFO
Declares typeinfo for some type.
Example:
TYPEINFO(/atom)
var/monkeys_hate = FALSE
TYPEINFO(/obj/item/clothing/glasses/blindfold)
monkeys_hate = TRUE
Treat this as if you were defining a type. You can add vars and procs, override vars and procs etc.
There might be minor issues if you define TYPEINFO of one type multiple times. Consider using /typeinfo/THE_TYPE
for subsequent additions
to the object's typeinfo if you know it has already been declared once using TYPEINFO.
for_by_tcl
Loops over all instances of a type that's tracked via the [START_TRACKING] and [STOP_TRACKING] macros. Example: for_by_tcl(gnome, /obj/item/gnomechompski) qdel(gnome)