ID:1732872
 
(See the best response by Reformist.)
if(src.type == typeof(/obj/objectONE))
DO THIS
else
DO THAT


So what I want it to do is: DO THIS when obj/objectONE/CUBE or obj/objectOne/Pyriamid is being tested as the src but not when something like: /obj/objectTwo is the src, I want that one to do: DO THAT.

I tried the typeof command but it keeps coming up with errors and nothing else seems to work. Thoughts?
Best response
Lemme clarify this for you.

When checking an object's type, use istype().
// DM type-path style
object1
object2
object3

// traditional object inherited style
obj1
parent_type = /datum
obj2
parent_type = /obj1
obj3
parent_type = /obj2

// (test proc)
proc/CheckObject()

var/object1/object2/object3/o = new()

if (istype(o,/object1))
world << "1" // o is derived from /object1
if (istype(o,/object1/object2))
world << "2" // o is derived from /object1/object2
if (istype(o,/object1/object2/object3))
world << "3" // o is derived/is type /object1/object2/object3

var/obj3/u = new()
if (istype(u,/obj1))
world << "A" // u is derived from /obj1
if (istype(u,/obj2))
world << "B" // u is derived from /obj2
if (istype(u,/obj3))
world << "C" // u is derived/is type /obj3
In response to Mr_Goober
Isn't obj's parent type /datum/atom/movable/ ?
In response to NNAAAAHH
Yes.
I got it! Thanks for your help ^_^
In response to NNAAAAHH
Yeah. But /obj1, /obj2, /obj3 are arbitrary datums so they aren't linked to /obj in any way. I was mostly using them as a means of an example.
In response to Mr_Goober
I saw that, just thought to ask. Too tired to bother going to the computer, too lazy to go through the hassle on my phone to look it up.