Programming Tutorial VII - Private Doors Part 2
We are now in a position to give a more advanced version of the private doors program that was covered in tutorial IV. This time we are going to add extra messages to our guest, depending on whether they're in your clan or not. If you're following these tutorials in order, then you may wish to refresh your memory by quickly reading that tutorial here.
Let room A be your room that's open to the general public, and room B be the first room of your clan's private space. You will need to build and decorate two pages as well, one for the special message to your clan “The door through to the clan's private rooms is guarded by two kittymorphs. They recognise you as a member and stand to attention.”, and one for the general public. “The door through to the clan's private rooms is guarded by two kittymorphs. They eye you warily and make threatening noises when you get too close to the door.” In Master Settings, set these pages' 'Show nav link to this page' to 'No'. You can label these rooms however you like since your guests are never going to see the labels, so pick something convenient and easy to remember. Say “Clannie welcome.” and “Non-clannie welcome.” Make sure that the door to the clan's private rooms is locked.
Now take a Clan Contrivance with the parameter set to your clan, an Unlock Door Contraption with the parameter set to the door between the two rooms, and two Show Page Contraptions, one pointing to each of your pages. Use these to build a program in room A as shown in the following diagram. Put the Clan Contrivance on the first row, as this is the question that you're asking. On the second row, put the Unlock Door Contrivance and the Show Page Contraption that points to your “Clannies welcome” Page. Finally, put the “Non-clannies welcome” Show Page in the square in the far right of the first row, the Escape Hatch. Your program should look like the following:
Once you've done this, make a program in room B with a single Unlock Door Contraption with the parameter pointing to the connecting door.
Note for budding programmers
That space on the right hand side that we've just used is called the Escape Hatch. Any Contraption placed there will get activated whenever the corresponding row fails. If the row passes however, then the program passes onto the next row, as normal. We'll show the diagram from the previous tutorial again to help.
Follow the logic of the program through. It starts off at the first row and finds a Clan Contrivance, so it checks the guest's clan. If this matches the Contrivance's parameter clan, then it passes and proceeds to the next row. Here it finds an Unlock Door Contraption, so the door is now unlocked, and a Show Page Contraption pointing to the 'Clannie welcome' page, which duly gets shown.
If however, the guest is not from the clan, then the Clan contrivance fails, the whole row fails, and the Show Page Contraption in the Escape Hatch gets fired instead, showing the 'Non-clannie welcome' page.
Very good. We're getting close to understanding all about the programming grid and what it can do now, but there's one thing left. That knob separating the main grid from the Escape Hatch. The knob that we've been carefully avoiding mentioning so far. That's the flow control knob, and we will cover what this does in the next two tutorials.
Go to next tutorial.
Return to previous tutorial.
Tutorial Contents Page
Return to Introduction to Programming.
Return to Places Overview