what would be the best way to implement a room inside another one? For example imagine we have a room called “Main place” and other one called “House”. The house is in the place, and I can “enter” to visit it. So “The House is inside from Main Place” would work, but how can I refer to the house, if I’m still in the main place?
Generally I create a “fake” object with the same name (“understand “house” as fakehouse”), and I intercept the player’s command to the fake house so the player can get the illusion to see the real house. Then to enter the house, I use something like this:
Instead of entering fakehouse when housedoor is unlocked, move player to house.
Now with the new default response, it doesn’t look good (“The house is not something you can enter.”, instead of “You can’t enter the house”).
How could I do better?
So the problem is that when the housedoor isn’t unlocked, you get the standard entering message, which isn’t good? One thing you could do is change the message in this case, but it seems like the better solution would be to redirect entering the fakehouse to going inside. Then the game will take care of checking the door for you (and opening it, etc.) And if you have any other code that deals with moving, this will hook onto it to.
Instead of entering fakehouse, try going inside.
I figure that the player wouldn’t mean “go inside” and “enter house” to have different effects, so it’s probably cleaner to have them taken care of by the same action.
yes it should work, but what if there are several houses to enter? (sometimes I put the different houses at different cardinal directions so at least I have a few places available)
But is there a better code in the general case (by avoiding to create a fake object), for example a way to label the room so it could also be an object?
Well, if there are several houses in one place you could just do “Instead of entering fakebrickhouse, try going west. Instead of entering fakewoodenhouse, try going east.” and so on.
As for making rooms into objects, I don’t think this will be feasible. Rooms are their own kind of object in the kind hierarchy, and things are different; you can’t make a room into a thing.
There’s nothing wrong with scenery objects. I make a lot of them.
I’d recommend making them both rooms, with the house object being a door inside from the main place and outside from the house. “Enter [door]” is already handled by the Inform library, and the door will be implicitly opened if necessary.
thank you for the tips, using the door as the fake name for the house is probably the best option.
I made a bunch of hotel rooms with bathrooms inside making each bathroom a “lit, enterable, openable container”. Inside each of those was a shower stall which was a “transparent, openable, enterable container”.
That means that when you’re in the bathroom and the bathroom is open you can see everything in the hotel room too, right? That might or might not be desirable depending on what you’re going for.