ID:1736292
 
(See the best response by Multiverse7.)
I've got a bit of a thought happening here but have no idea how to tackle it. Lets say I have a var to begin with:

mob/var/equipped = null


then I make that variable to something

src.equipped == /obj/sword


What I want to do in a verb is get the name of that variable. I have called something like:
src << src.equipped


but I get the icon as well. Is there a way I can go like this:

src << src.equipped.name


could I make it like presume something is a type of something or something else?

Well, you've allocated a type to equipped, not an actual object. As types are not concrete objects in their own right, you cannot access variables on them, no.

To do that, you'd need to actually allocate an object to equipped. For example:

mob/var/equipped = null

mob/verb/Equip_A_Sword()
src.equipped = new/obj/sword()

mob/verb/Display_Equipped_Name()
if (src.equipped == null)
src << "You have nothing equipped!"
else
src << "You currently have [src.equipped.name] equipped."
In response to Stephen001
Best response
Stephen001 wrote:
As types are not concrete objects in their own right, you cannot access variables on them, no.

That's not entirely true. Technically all type paths are objects, but they cannot be modified at runtime, and their only purpose is to hold the compile-time data used to instantiate actual objects, so they are not true prototypes.

What this means is that in a very specific case, we are able to read the compile-time values of an actual type's variables, without needing to create any instances. Unfortunately, reading the variables of a type is not as easy as reading the variables of an instance, since the vars list isn't available for use.

You have the initial() proc to thank for this unusual functionality. Here is an example:
proc
getinit_name(object)
if(istype(object, /atom) || ispath(object, /atom))
. = initial(object:name)

The proc works on both instances and paths!
// Outputs the compile-time value of /obj/sword.name
world << getinit_name(/obj/sword)

This is only reliable because we know for sure that an atom will always have a name var.
While definitely interesting and informative (thank you, genuinely, I voted accordingly), one might suspect this isn't quite what OP is going for though, in practice?