The Dark Ages Revisited
This will be explored more in subsequent examples, but one of the things we can do with carry out rules is extend the function of existing commands so that they do more, or have special effects in specific situations. For instance, suppose we want to have a class of electric light:
This will not affect the behavior of any other devices when switched; it will also not change the way in which switching lights on and off is reported. The player will still see "You switch the sodium lamp on." or the like. In this case that is probably what we want. If we wanted a special way of describing turning on electric lights as opposed to all other devices, we could also add an after rule for the electric light class. Adding this rule to the carry out train does guarantee, though, that in no case will we manage to make the lamp lit without actually making it switched on (or vice versa).
So far so easy. Since we've built the description of its light or darkness into the lamp's description, though, we may want to get rid of the "…is switched on" line that automatically follows when we look at something. For this we do need to borrow from a later chapter:
Test me with "x lamp / switch lamp on / look / x lamp".
A low, square-cut corridor, running north to south, stooping you over.
The sodium lamp squats heavily on the ground.
>(Testing.)
>[1] x lamp
It is a heavy-duty archaeologist's lamp, currently off.
>[2] switch lamp on
You switch the sodium lamp on.
>[3] look
Stooped Corridor
A low, square-cut corridor, running north to south, stooping you over.
The sodium lamp squats on the ground, burning away.
>[4] x lamp
It is a heavy-duty archaeologist's lamp, blazing with brilliant yellow light.