Site Tools
User Tools

Programming Tutorial IX - The Gentle Pitter Patter of Rain on Leaves - Weather, Part 2

You've got a garden area in your Place, and you'd like to take into account the weather there. In particular, you'd like to use the Rain Contraptions to give a raindrops background, when it's raining of course. This was covered in programming tutorial VI - raindrops keep falling on my bonce. But you'd like to go further. When it's not raining, then you'd like to use the Tree Shadows Contraption to give you a nice background woodland effect. How do you mix the two?

You could try starting with the 'rain' program of tutorial IV. This shows a rain background whenever the weather status number is five, six, or seven, (the three 'rainy states). Now note that you want to have your trees whenever this fails, put it in the Escape Hatch. But there's a problem. You want to use the Page Lighter Contraption as well as the Tree Shadows Contraption, but there's only room for one gadget in the Escape Hatch. Think again.

You might try doing things the other way round. Put four Weather Contrivances for the other, 'fair weather' weather states, one through four. If any one of these pass, you can use a tree shadows Contraption and a Page Lighter Contraption on the second row to achieve the trees, and then if none of them pass, if they all fail, then a Rain Contraption in the escape hatch completes the program.

You could do this and it would work, although, it does require an extra column in your program. There is another way.

Start with three weather contrivances, one for each of the 'rainy' weather states, five, six and seven. Notice that you want Tree Shadows and Page Brighter whenever it's not five AND it's not six AND it's not seven, that is, when All of them fail. If Any of them pass, you want Rain. So put these three Contrivances in the first row, then click on the flow control knob three times, until it says 'All' and 'Fail', both on red backgrounds. Now put your tree shadow and page lighter Contraptions on the second row, and a rain Contraption in the escape hatch of the first row. Your program should look like this:

 Come rain or come shine...
And there you have it, rain when it's, well, raining, and a lighter treed effect when it's not raining. You clever thing!

Note for budding programmers

Here we have used the All Fail setting on the flow control knob, which does exactly what it says on the tin. The line passes whenever all the gadgets on it fail. The Any Fail setting works similarly, and we won't have a separate tutorial for that.

(Another) Note: In some sense the Fail settings swap round when a line passes and the program progresses to the next line, and when a line fails and the program progresses to the escape hatch. Indeed, if a line consists of a single Contrivance, then 'Any' and 'All' amount to the same thing and that's exactly what the 'Fail' settings do. However if more than one contrivance is used, then it is a little bit more subtle. If the flow control knob is set to Any Fail, then the escape hatch will be fired only if All the Contrivances pass. If the flow control knob is set to All Fail, then the escape hatch is fired whenever Any of the Contrivances pass. So a Fail setting not only swaps over when the program proceeds to the next row and when it proceeds to the escape hatch, but also swaps over All and Any. The situation can be summed up in the following table.

Proceed to
next line of
program
(flow control
knob setting)
Proceed to
Escape Hatch
Any Pass All Fail
All Pass Any Fail
Any Fail All Pass
All Fail Any Pass

The intricacies of the Flow Control Knob can be very hard to wrap your head around, especially if you are new to programming and formal logic.1) A different way of thinking about it may be to simply remember that Any Fail is the opposite of All Pass. Or this table may help: if your gadgets will do this, when the FCK is set to that, then the program will go to there as its next action:

If: All gadgets pass Some and some All gadgets fail
Any Pass Next row Next row Escape hatch
All Pass Next row Escape hatch Escape hatch
Any Fail Escape hatch Next row Next row
All Fail Escape hatch Escape hatch Next row

We have now covered all the different parts of the programming grid. There're still a few more things to cover. The next tutorial will be rather short and easy. It will cover the Add Page Access (Show Page Link) and Hide Page Link Contraptions.


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

1)
It can become not so much a FCK as a WTFCK.
gameplay/guides/places/progtutix.txt · Last modified: 2023/11/21 23:20 by kuhsodas