ID:179237
 
I'm looking for a way to check if an object is a direct branch from a specific type.

so obj/items would allow:
obj/items/cushion
obj/items/cow_bell
obj/items/monkey_fur
obj/items/todo

and obj/items/todo would allow:
obj/items/todo/alice
obj/items/todo/wonder
obj/items/todo/land
obj/items/todo/wrong
obj/items/todo/movie

Is there any way to do that?

Is there any way to do that?

istype() should do that.
In response to Theodis
Well, I want to see if it's immediately within that type, so anything in the / after the type I define would be acceptable. istype() only seems to check if it's exactly that type.
In response to Foomer
I'm fairly certain istype() checks for subclasses, too. Or at least, I believe it's supposed to. If not, you could always do:

if(whatever.type in typesof(/obj/item))

[Edit:] Out of curiousity, Foomer, why do you post questions in Newbie Central? You've definately been here long enough and know enough about BYOND to be considered well above Newbie status.

-AbyssDragon
In response to AbyssDragon
Newbie central questions get answered faster than code problems questions.

Besides, regardless of status, I'm still a newbie at some things :o)
In response to Foomer
Foomer wrote:
Well, I want to see if it's immediately within that type, so anything in the / after the type I define would be acceptable. istype() only seems to check if it's exactly that type.

I'd recommend reading the istype() doc again. You might notice the See Also for typesof()...
In response to Foomer
To add to that, all the less-thoughtfully-inclined people who don't have enough sense to realize that they are newbies, and newbies should post in NEWBIE Central are dwelling in Code Problems right now. I'd rather not have my posts flooded with pointless questions of that sort.

Be nice if Dantom made the code problems forum only show up for keys are have existed for a few months or something :oP