1
0
Fork 0
mirror of https://github.com/ganelson/inform.git synced 2024-07-05 16:44:21 +03:00
inform7/resources/Documentation/Examples/Blocks.txt
2019-03-16 13:12:11 +00:00

47 lines
3.2 KiB
Plaintext

*** Duplicates
(Duplicated blue, red and green building blocks--Paint that colours blocks; Early Childhood)
A child's set of building blocks, which come in three different colours - red, green and blue - but which can be repainted during play.
This would be a one-star example if it were not for the repainting:
{*}"Early Childhood 1"
A building block is a kind of thing. A red block, a blue block and a green block are kinds of building block.
The Nursery is a room. In the Nursery are six red blocks, four blue blocks and a green block.
Test me with "look / get red block".
But a kind cannot change during play, so this will not do. Instead, the colour will have to be a property of the block. So we might first try this:
{*}"Early Childhood 2"
Colour is a kind of value. The colours are red, blue and green. A block is a kind of thing. A block has a colour. A block is usually blue.
The Nursery is a room. In the Nursery are six red blocks, four blue blocks and a green block.
Test me with "look / get red block".
Which is fine, so far as it goes, but the colour property is not at all visible to the player, who simply sees "eleven blocks". We thought of colour as being something outwardly apparent, but Inform does not know this. To achieve a better effect, we will need features from distant chapters. The first is an activity called "printing the name of":
{*}"Early Childhood 3"
Colour is a kind of value. The colours are red, blue and green. A block is a kind of thing. A block has a colour. A block is usually blue. Before printing the name of a block: say "[colour] ". Before printing the plural name of a block: say "[colour] ".
The Nursery is a room. In the Nursery are six red blocks, four blue blocks and a green block.
Test me with "look / get red block".
This too, however, is unsatisfactory. The individual blocks are correctly described, but we are unable to distinguish them during play: we cannot type "take a green block", for instance. And because the blocks are indistinguishable in play, they are still massed together as "eleven blocks" in room descriptions. We need to go one step further:
{*}"Early Childhood 4"
Colour is a kind of value. The colours are red, blue and green. A block is a kind of thing. A block has a colour. A block is usually blue. Before printing the name of a block: say "[colour] ". Before printing the plural name of a block: say "[colour] ". Understand the colour property as describing a block.
The Nursery is a room. In the Nursery are six red blocks, four blue blocks and a green block.
And now everything works nicely: the blocks are grouped by colour, and can be referred to by colour, and we can even change the colour of an individual block during play, using a bit of extra trickery from later:
{**}Understand "paint [something] [colour]" as painting it. Painting it is an action applying to one thing and one colour. Check painting it: if the noun is not a block, say "Paints are only for blocks." instead. Carry out painting it: now the colour of the noun is the colour understood. Report painting it: say "The block is now [the colour of the noun]."
Test me with "get red block / get blue block / g / i / look / paint blue block red / i / look / paint me red".