Inform 7 Home Page / Documentation
§3.16. Vehicles and pushable things
Next in the tour of standard kinds is the "vehicle". This behaves like (indeed, is) an enterable container, except that it will not be portable unless this is specified.
In the Garage is a vehicle called the red sports car.
The player can enter the sports car and then move around riding inside it, by typing directions exactly as if on foot: and the story will print names of rooms with "(in the red sports car)" appended, lest this be forgotten.
We have already seen that some things are portable, others fixed in place. In fact we can also make a third sort of thing: those which, although not portable, can be pushed from one room to another with commands like "push the wheelbarrow north". At a pinch, we might just be willing to allow:
The red sports car is pushable between rooms.
But of course this is a property which almost any thing can have, not just a vehicle. (Only "almost" because Inform will not allow a door to be pushable between rooms, in the interests of realism rather than surrealism.)
If we need vehicles which the passenger sits on top of, like a horse or a tractor, the standard "vehicle" kind will not be ideal. However, by loading one of the extensions which comes ready-installed:
Include Rideable Vehicles by Graham Nelson.
...we are provided with two more kinds, "rideable vehicle" and "rideable animal", just right for the tractor and the horse respectively. (As with all extensions, the documentation can be seen by clicking Go on some source which contains the above line, and then turning to the Contents index; or from the Installed Extensions tab of the Extensions panel.)
See Going by, going through, going with for further ways to customize vehicle behaviour
|
ExamplePeugeot
A journey from one room to another that requires the player to be on a vehicle.
|
|
Let's say that our protagonist is about to flee . Obviously, he can't make the journey on foot; he needs transportation.
"Peugeot"
Include Rideable Vehicles by Graham Nelson.
The Lot is a room. The ten-speed bike is a rideable vehicle in the Lot.
We make the ten-speed bike a rideable vehicle because we want to say that the player is on it rather than in it. Then our other room:
Cambridge is east of the Lot.
And now we borrow from the Actions chapter to prevent travel without the proper equipment:
Instead of going to Cambridge when the player is not on the ten-speed bike:
say "It's a long journey to Cambridge: you'll never make it on foot."
After going to Cambridge:
say "You begin pedalling determinedly.";
continue the action.
Test me with "e / get on ten-speed bike / e".
We probably do not need a vehicle to ride around our boat, but there might be a heavy ice chest that can only be pushed from room to room:
The ice chest is a closed openable container in the Deck. "A very heavy ice chest sits on the ground." It is fixed in place and pushable between rooms. A quantity of ice is in the chest. The description is "Ready and waiting just in case there's any fish needing to be kept cool."
This anticipates a later chapter, but it would probably be a good idea to hint to the player, if he tries to take the ice chest, that there is another way to move it:
Instead of taking the chest: say "It's too heavy to lift, but you might be able to push it, and just inch it over the frame of the door."
Otherwise, attempts to pick it up will just reply with "That's fixed in place."
Suppose we want the player to see a modified room description when he's viewing the place from inside a vehicle. There are several conceivable ways of doing this; the example here shows a rather advanced way, but is very flexible and will let us write all sorts of special cases.
"Hover"
Use full-length room descriptions.
Emerald City is a room. "All the buildings are spires and none of them have doors." The Vast Desert is west of Emerald City. "[if the player is in a vehicle]Outside, a[otherwise]A[end if] trackless waste stretches as far as the eye can see in every direction."
The hover-bubble is a vehicle in the Emerald City. "Your hover-bubble awaits." The description is "The hover-bubble is a clear globe-shaped vehicle capable of transporting you anywhere you could walk, but faster." Understand "bubble" as the hover-bubble. The hover-bubble contains a chocolate wrapper and a parking ticket.
Here's the tricky part, which relies on material from the chapters on Activities and Rulebooks:
The container interior rule is listed before the room description body text rule in the carry out looking rules.
This is the container interior rule:
if the actor is the player and the player is in an enterable thing (called current cage), carry out the describing the interior activity with the current cage.
Describing the interior of something is an activity.
Now we've done that, we can write a "rule for describing the interior" of something, which will print whatever we like:
Rule for describing the interior of the hover-bubble:
say "The hover-bubble is transparent, but tints everything outside very faintly lavender."
In fact, as a special refinement, we could even say:
Rule for describing the interior of the hover-bubble when the hover-bubble contains more than one thing:
say "The hover-bubble is transparent, but tints everything outside very faintly lavender. Beside you you can see [a list of other things in the hover-bubble]."
Definition: a thing is other if it is not the player.
Rule for listing nondescript items of the hover-bubble when the player is in the hover-bubble: do nothing.
Test me with "get in bubble / look / west / take all / look / get out / east".
And now anything that's beside us in the vehicle will be described during that first paragraph, rather than later on.