Table of Contents

Programming Tutorial V - Making a Grand Entrance


So there are two doors into my Room. Problem?

So you've got a grand hall in your place. It's got big double doors at one end, a large staircase leading up from the other, and various smaller doors leading off from both sides. I can see the description now -

“The great doors swing open before you revealing a glittering ballroom. A staircase of the sort that glamourous Hollywood stars should be walking gracefully down rises majestically from the other end. Through the glittering throng you can make out many side-doors leading off to who knows where? etc.etc.”

Very nice. Then your visitor goes through the first side door and has a look round there, before returning to the grand hall. “The great doors swing open before you…”. Hang on a moment, was that door great? I thought that we were coming back in through a smaller side-door. Then they climb the stairs and look at the delights that you have in store for them up there. Sweeping back down the staircase and - “The great doors swing open before you…” again. Now that's just plain wrong!

The point is that many rooms (not just great halls) should look different depending on which way you enter them. Did you drop down into the swimming pool while climbing on a structurally unsound roof, or did you come in through the door in the vain hope that people might mistake you for a normal person? Did you come into the train station via the door, or did you come in on a train? The point is even sharper if there's another way round, so your visitor could have seen the great hall for the first time coming down the stairs, having previously gone up the servant's stairs.

OK, problem. Solution?

What is needed is a way of having the same room show different descriptions depending on where you've come in from. We can use Pages for this. In this tutorial we shall deal with the simple case of only two different ways into a room. For a more sophisticated version which can deal with multiple entries, see here.

So, you have room A (the grand hall) with entries from room B (through the great doors) and room C (down the stairs). First of all, write your two descriptions. Yes, two; they're both describing room A, differing in what you see according to where you enter from. Now build a Page. Decorate the actual room A with one description (what you see as you enter from room B, through the great doors say), and decorate the Page with the other description (entering from room C, down the stairs).

To set up the program, you will need a 'Previous Room' Contrivance, a 'Show Page' Contraption, and a 'Hide Room Description' Contraption.

Set the 'Previous Room' parameter to whatever is at the top of the stairs, set the 'Show Page' parameter to your newly decorated Page, and arrange them like this:

 Two views of a room.

Job done!


Note for budding programmers

Look, it's too big to put in a box. Just read it.

Most of this you might have guessed by now. The one surprising aspect is that 'Hide Room Description Contraption'. You may be asking yourself why we need that. Surely we can just use the master settings, switching 'Show Room Description Underneath' to 'No'? Well you can if you want, but it won't do you any good. That only has an effect if the page is reached by clicking on a link to get there. If the page is shown by a program, then that setting is ignored, and the room description is shown underneath. To counteract that, you have to use that 'Hide Room Description' Contraption.

Why is programming set up like this? Why this extra complication? Well there're very good reasons. You may have noticed in the above, that when I said “build a Page”, I didn't actually specify where you had to build it. This was deliberate. The Show Page Contraption doesn't care where the Page is, it could be anywhere at all in the Place. All it does is to go and get the decoration for the specified Page, and display it. For organisational purposes, it's probably better to build the Page off the room that you're displaying it from. You're less likely to get confused about what you're doing and make mistakes. But it's really not necessary.

What this means is that you can use the same Page from many different rooms in your Place. Suppose that you're trying to build some sort of text adventure game, complete with 'Look' and commands, using the 'Partial Commentary Match' Contrivance. (We shall cover the mechanics of doing this in a future tutorial. For the moment just bear with it as an example of why the 'Show Page' Contraption is designed the way it is.) You can expect people to try looking at things that you haven't built a response for. Instead of having the generic 'Command Not Recognised' message, you can have the program sideline to your own, single, Page: “What are you trying to look at?” Instead of having to build one for every room in your entire Place, you only need to build one, and have your programs all pointing there. Less work for you. Win!

Maybe that's a little beyond you at the moment, but when you get there, you'll be very glad of the extra flexibility that the 'Show Page' Contraption gives you by working this way. The minor downside is the use of one extra Contraption when you use it and don't want the Page showing underneath, and that's a small price to pay.

There are a lot of details involved in the advanced use of Pages, but you don't have to know about them all. The more you get to know, the more effectively you'll be able to use Pages, but you can learn it slowly.

In the next tutorial, we will be going back to the basics of programming grids again. We will be looking at how to go about having more than one condition at a time. I'll see you there.


Go to next tutorial.
Return to previous tutorial.
Tutorial Contents Page
Return to Introduction to Programming.
Return to Places Overview.