How do I know if an object is a room?

Hello all,

I have a generic function that takes an object as input. And it does not do exactly the same thing if it's passed an item or a room.
I tried using the attribute isroom but it is removed upon compilation. I now use the attribute description since it is only filled for rooms but it seems very flimsy.

Is there another way? Am I missing something obvious?


The type editor_room sets the isroom attribute; but that type is removed when the game is published. If you tick and untick the "is a room" checkbox in the editor, it should persist in a published game.

In general, there isn't a simple option because Quest doesn't see a difference between items and rooms. The core functions distinguish between an item and a room based on whether the player is inside it – because the only room the core cares about is the one you're in (or the one you're entering/leaving).

So, if you want to distinguish between the two, you will probably end up creating an attribute or type of your own that you can check for.


Ok, thanks for your answer.

Follow-up question: how do I retrieve the current room? It could actually help me.


Every object has a parent attribute, pointing to the object it is inside of.
The game has a pov attribute, which means the object the player is currently controlling.

So game.pov.parent is the current room.

The functions that display the room description use either game.pov.parent or GetNonTransparentParent (game.pov.parent). This only makes a difference if the player is inside a transparent container which is also a room. For example, if they're inside a cage in a laboratory, then game.pov.parent will be the cage and GetNonTransparentParent (game.pov.parent) will give the lab. They can see objects outside the cage, but can't reach them.
In most games, you don't need to deal with this situation.


Ok, thank you. I think I will use GetNonTransparentParent (game.pov.parent).

But let's imagine a far-fetched scenario. What about if the player is hiding or held in a cupboard, for instance. Both game.pov.parent and GetNonTransparentParent (game.pov.parent) will return the cupboard, right? And the game won't be able to display the room description, too?


Both game.pov.parent and GetNonTransparentParent (game.pov.parent) will return the cupboard, right? And the game won't be able to display the room description, too?

Right.
The room description uses GetNonTransparentParent to find the outermost room the player can see. So it will find the cupboard unless the cupboard's transparent attribute is set.


That's a bit weird that the room description works like that...
Ok, thanks anyway.


Log in to post a reply.

Support

Forums