Let's Play/Read: Inform 7 manuals (Done for now)

Regarding chapter 22, I haven’t really had an occasion to use the more abstract constructs in an actual IF project, but just recently I used the method from 22.8. Matching the names of kinds in a small example:

[...]

A car is a kind of vehicle.

A sedan is a kind of car.
A convertible is a kind of car. 

[...]

To paint (name of kind of value K):
	let palette be the list of colours;
	sort palette in random order;
	repeat with paint-target running through Ks in the carpool:
		now the colour of paint-target is entry 1 of palette;
		remove entry 1 from palette;
        
When play begins:
	paint sedans;
	paint convertibles;

There are doubtlessly other ways to do this, but I felt it made for relatively compact, yet readable code, and it’s very easy to add further kinds of car, like SUVs, hatchbacks, etc., without having to change or duplicate much code.

(In the particular example, I wanted each sedan (etc.) to have a unique colour, but didn’t want to simply paint all cars in one go, because I wanted to re-use colours for different types, so we can have a red sedan and a red convertible, for example.)


These threads have some further examples of how the techniques from chapter 22 might be used:

5 Likes