Around ten years ago, I reached the halfway point in Aaron Reed’s Creating Interactive Fiction with Inform 7. Life intervened as it often does, and I set the project aside. Over the holidays, I spent some time reviving the project and decided to work through the source text for Sand-dancer from the beginning, using the latest version of Inform 7 (v10.1.2). While most of the source text works without modifications, the process has challenged me
- in part because of the evolution of the Inform 7 language and the deprecation of several popular extensions at the time the book was originally published, and
- in part, because I’m trying experiments that are beyond my current level of understanding about Inform’s syntax
In my version, I implemented cigarettes as a kind and pack of smokes as a container. I wanted to create cigarettes as a scarce resource, put several cigarettes in the pack of smokes, stow the pack of smokes in the glove box in the truck, and hide a few extra cigarettes like easter eggs the player could find.
Here’s my implementation of cigarettes:
Part 7 - Cigarettes
A cigarette is a kind of thing.
A cigarette is inedible.
The pack of smokes is an opaque, portable container.
Understand "pack of smokes" or "pack" or "pack of cigarettes" as the pack of smokes.
The carrying capacity of the pack of smokes is 20.
Ten cigarettes are in the pack of smokes.
The crumpled box is an opaque, portable container.
Understand "crumpled box" or "crumpled carton" or "crumpled pack" or "discarded pack" or "carton" as the crumpled box.
the carrying capacity of the crumpled box is 20.
3 cigarettes are in the crumpled box.
Check inserting something into in the pack of smokes:
if the noun is not a cigarette, say "There is nothing magical about the pack of smokes. You can't put that in there.".
Check inserting something into in the crumpled box:
if the noun is not a cigarette, say "There is nothing magical about the pack of smokes. You can't put that in there.".
Original cigarette count is a number variable. Original cigarette count is 10.
And here’s my implementation of smoking:
Smoking is an action applying to one thing.
Understand "smoke [something]" as smoking.
Instead of smoking for at least two turns: say "Hey, go easy on those."
Check smoking when the number of cigarettes in pack of smokes is 0 and pack of smokes is held: instead say "You're out of cigarettes."
Check smoking when noun is not cigarette: instead say "Sounds like something your high school buddies would try."
Check smoking when lighter is not held: instead say "You pat your pockets, but can't seem to find your lighter."
Instead of smoking when pack of smokes is not held: say "You wish you had a pack of smokes on you."
Before smoking when lighter is not held and lighter is visible: say "(first taking the lighter)"; try silently taking lighter.
Before smoking when cigarette is not held and pack of smokes is held: say "(first removing a cigarette from the pack of smokes)"; try silently taking the noun.
First report smoking: say "You pull out a cigarette and light the tip. The familiar smell of lighted tobacco calms you."
Report smoking at least three times: say "You're smoking like a chimney. [run paragraph on]".
Last report smoking: say "[paragraph break][if player is in pickup truck]You extinguish the butt in an empty cup[otherwise]You crush the butt under your heel[end if] and wonder where to go next."
Carry out smoking: now the noun is nowhere.
This worked exactly as I envisioned. I can take the pack of smokes, check inventory and see how many cigarettes I’m carrying. When I smoke, the number of cigarettes decrements as expected.
But one thing stumps me.
Later in the book there’s a section on scenes where you’re instructed to create a scene called Addicted which automatically triggers the smoking action.
I thought I should be able to implement this with the line:
try smoking a cigarette
This does not compile. It will compile if I enter:
try smoking the noun
…but during gameplay, when I reach the scene Addicted, and it randomly tries to trigger the try smoking action, it doesn’t carry out the action.
How do I tell Inform what I mean by “the noun” in these statements?
Before smoking when cigarette is not held and pack of smokes is held: say "(first removing a cigarette from the pack of smokes)"; try silently taking the noun.
Every turn when a dramatic scene is not happening and we are not smoking and a random chance of 1 in 5 succeeds during Addicted:
try smoking the noun.